Skip to content

Commit 58a1528

Browse files
committed
Add distances lookup table max z
Lowering the max z of the lookup table helps reduce the impact of drop ceilings.
1 parent 69d7fb6 commit 58a1528

File tree

5 files changed

+17
-5
lines changed

5 files changed

+17
-5
lines changed

cfg/AMCL.cfg

+1
Original file line numberDiff line numberDiff line change
@@ -103,6 +103,7 @@ gen.add("transform_frame_id", str_t, 0, "The name of the coordinate frame publis
103103
gen.add("off_object_penalty_factor", double_t, 0, "Penalty factor for points that miss an object on the static map.", 1000.0, 0.0, 100000.0)
104104

105105
gen.add("publish_distances_lut", bool_t, 0, "Whether to publish the Distances Lookup Table as a point cloud for debugging.", False)
106+
gen.add("lut_max_z", double_t, 0, "Add octopmap objects to the lookup table only if they have a z height below this value.", 10.0, 0.0, 10.0)
106107

107108
gen.add("restore_defaults", bool_t, 0, "Restore the default configuration", False)
108109

include/amcl/map/octomap.h

+2-1
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ class OctoMap : public Map
5959
{
6060
public:
6161
OctoMap(double resolution, std::string global_frame_id);
62-
OctoMap(double resolution, std::string global_frame_id, bool publish_distances_lut);
62+
OctoMap(double resolution, std::string global_frame_id, bool publish_distances_lut, double lut_max_z);
6363
virtual ~OctoMap() = default;
6464
virtual void initFromOctree(std::shared_ptr<octomap::OcTree> octree, double max_distance_to_object);
6565
// Convert from voxel indices to point in map frame
@@ -116,6 +116,7 @@ class OctoMap : public Map
116116
ros::NodeHandle nh_;
117117
ros::Publisher distances_lut_pub_;
118118
bool publish_distances_lut_;
119+
double lut_max_z_;
119120
std::string global_frame_id_;
120121
};
121122
} // namespace amcl

include/amcl/node/node_3d.h

+1
Original file line numberDiff line numberDiff line change
@@ -134,6 +134,7 @@ class Node3D : public NodeND
134134
double non_free_space_radius_;
135135
double z_hit_, z_short_, z_max_, z_rand_, sigma_hit_, lambda_short_;
136136
bool publish_distances_lut_;
137+
double lut_max_z_;
137138
double global_localization_off_map_factor_;
138139
double global_localization_non_free_space_factor_;
139140
bool global_localization_active_;

src/amcl/map/octomap.cpp

+10-3
Original file line numberDiff line numberDiff line change
@@ -35,11 +35,12 @@ namespace badger_amcl
3535
{
3636

3737
OctoMap::OctoMap(double resolution, std::string global_frame_id)
38-
: OctoMap(resolution, global_frame_id, false) {}
38+
: OctoMap(resolution, global_frame_id, false, 10.0) {}
3939

40-
OctoMap::OctoMap(double resolution, std::string global_frame_id, bool publish_distances_lut)
40+
OctoMap::OctoMap(double resolution, std::string global_frame_id, bool publish_distances_lut, double lut_max_z)
4141
: Map(resolution),
4242
publish_distances_lut_(publish_distances_lut),
43+
lut_max_z_(lut_max_z),
4344
cdm_(resolution, 0.0),
4445
global_frame_id_(global_frame_id)
4546
{
@@ -207,7 +208,11 @@ void OctoMap::updateDistancesLUT()
207208
if (publish_distances_lut_)
208209
{
209210
publishDistancesLUT();
210-
ROS_INFO("Octree published");
211+
ROS_INFO("Distances lookup table published");
212+
}
213+
else
214+
{
215+
ROS_INFO("Distances lookup table not published");
211216
}
212217
distances_lut_created_ = true;
213218
}
@@ -231,6 +236,8 @@ void OctoMap::iterateObstacleCells(CellDataQueue& q)
231236
point[0] = it.getX();
232237
point[1] = it.getY();
233238
point[2] = it.getZ();
239+
if (point[2] > lut_max_z_)
240+
continue;
234241
rasterize(point, &voxel);
235242
i = voxel[0];
236243
j = voxel[1];

src/amcl/node/node_3d.cpp

+3-1
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,8 @@ Node3D::Node3D(Node* node, std::mutex& configuration_mutex, std::string global_f
7878
private_nh_.param("global_localization_scanner_non_free_space_factor",
7979
global_localization_non_free_space_factor_, 1.0);
8080
private_nh_.param("map_scale_up_factor", occupancy_map_scale_up_factor_, 1);
81+
private_nh_.param("publish_distances_lut", publish_distances_lut_, false);
82+
private_nh_.param("lut_max_z", lut_max_z_, 10.0);
8183

8284
cloud_topic_ = "cloud";
8385
cloud_sub_ = std::unique_ptr<message_filters::Subscriber<sensor_msgs::PointCloud2>>(
@@ -208,7 +210,7 @@ std::shared_ptr<OctoMap> Node3D::convertMap(const octomap_msgs::Octomap& map_msg
208210
}
209211
double resolution = map_msg.resolution;
210212
std::shared_ptr<OctoMap> octomap = std::make_shared<OctoMap>(
211-
resolution, global_frame_id_, publish_distances_lut_);
213+
resolution, global_frame_id_, publish_distances_lut_, lut_max_z_);
212214
ROS_ASSERT(octomap);
213215
octomap->initFromOctree(octree_, max_distance_to_object_);
214216
octree_.reset();

0 commit comments

Comments
 (0)