-
Notifications
You must be signed in to change notification settings - Fork 119
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Reinitialize global and storage maps with odometery #187
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -66,11 +66,11 @@ void LocalGlobalMapperNode::initParams() { | |
nh_.param("robot_r", robot_r_, 0.2); | ||
nh_.param("robot_h", robot_h_, 0.0); | ||
|
||
double global_map_cx, global_map_cy, global_map_cz; | ||
double global_map_cx_, global_map_cy_, global_map_cz_; | ||
nh_.param("global/resolution", global_map_info_.resolution, 2.0f); | ||
nh_.param("global/center_x", global_map_cx, 0.0); | ||
nh_.param("global/center_y", global_map_cy, 0.0); | ||
nh_.param("global/center_z", global_map_cz, 0.0); | ||
nh_.param("global/center_x", global_map_cx_, 0.0); | ||
nh_.param("global/center_y", global_map_cy_, 0.0); | ||
nh_.param("global/center_z", global_map_cz_, 0.0); | ||
nh_.param("global/range_x", global_map_dim_d_x_, 500.0); | ||
nh_.param("global/range_y", global_map_dim_d_y_, 500.0); | ||
nh_.param("global/range_z", global_map_dim_d_z_, 2.0); | ||
|
@@ -84,9 +84,9 @@ void LocalGlobalMapperNode::initParams() { | |
|
||
// map origin is the left lower corner of the voxel map, therefore, adding | ||
// an offset make the map centered around the given position | ||
global_map_info_.origin.x = global_map_cx - global_map_dim_d_x_ / 2; | ||
global_map_info_.origin.y = global_map_cy - global_map_dim_d_y_ / 2; | ||
global_map_info_.origin.z = global_map_cz - global_map_dim_d_z_ / 2; | ||
global_map_info_.origin.x = global_map_cx_ - global_map_dim_d_x_ / 2; | ||
global_map_info_.origin.y = global_map_cy_ - global_map_dim_d_y_ / 2; | ||
global_map_info_.origin.z = global_map_cz_ - global_map_dim_d_z_ / 2; | ||
global_map_info_.dim.x = static_cast<int>( | ||
ceil((global_map_dim_d_x_) / global_map_info_.resolution)); | ||
global_map_info_.dim.y = static_cast<int>( | ||
|
@@ -288,9 +288,38 @@ void LocalGlobalMapperNode::processCloud( | |
T_odom_lidar.translation().y(), | ||
T_odom_lidar.translation().z()); | ||
|
||
const Eigen::Vector3d global_center(global_map_cx_, | ||
global_map_cy_, | ||
global_map_cz_); | ||
|
||
ros::Time t0; | ||
cpu_times tc; | ||
|
||
// Reset global and storage maps if the robot is far from the map centers | ||
const auto diff = lidar_position_odom - global_center; | ||
const auto distance = diff.norm(); | ||
const auto threshold = std::min(global_map_dim_d_x_, global_map_dim_d_x_) / 40; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Dividing by 40 will make the update small. Maybe we should make this threshold a parameter in the mapper YAML file, maybe name it something like map_reinit_distance, and make the default value -1 (which means no reinitialization at all). |
||
ROS_INFO("[Mapper]: distance is %.2lf, threshold is %.2lf", distance, threshold); | ||
if (distance > threshold) { | ||
ROS_INFO("[Mapper]: resetting global and storage map"); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Please add a TODO here stating that we need to publish a stopping policy state trigger |
||
global_map_cx_ = lidar_position_odom(0, 0); | ||
global_map_cy_ = lidar_position_odom(1, 0); | ||
global_map_cz_ = lidar_position_odom(2, 0); | ||
|
||
global_map_info_.origin.x = global_map_cx_ - global_map_dim_d_x_ / 2; | ||
global_map_info_.origin.y = global_map_cy_ - global_map_dim_d_y_ / 2; | ||
global_map_info_.origin.z = global_map_cz_ - global_map_dim_d_z_ / 2; | ||
|
||
// storage map should have same x y z center and x_dim y_dim as global map | ||
storage_map_info_.origin.x = global_map_info_.origin.x; | ||
storage_map_info_.origin.y = global_map_info_.origin.y; | ||
storage_map_info_.origin.z = global_map_info_.origin.z; | ||
|
||
// Reinitialize maps. | ||
globalMapInit(); | ||
storageMapInit(); | ||
} | ||
|
||
double min_range = 0.75; // points within this distance will be discarded | ||
double min_range_squared; | ||
min_range_squared = min_range * min_range; | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please revert to default values (25)