@@ -89,18 +89,19 @@ std::string TsdfGradientOccupancyPublisher::printInfo() const {
8989
9090void TsdfGradientOccupancyPublisher::call (const HeightMap& height_map,
9191 const GradientMap& gradient_map,
92- const ActiveWindowOutput& output) const {
92+ const ActiveWindowOutput& output,
93+ const TsdfLayer& tsdf_layer) const {
9394 if (!pub_->get_subscription_count () && !height_map_pub_->get_subscription_count () &&
9495 !gradient_map_pub_->get_subscription_count ()) {
9596 return ;
9697 }
9798
9899 const uint64_t timestamp_ns = output.timestamp_ns ;
99- const auto & tsdf_layer = output.map ().getTsdfLayer ();
100100 const auto & world_T_body = output.world_T_body ();
101+ const float robot_z = static_cast <float >(world_T_body.translation ().z ());
101102
102- publishHeightMapViz (height_map, tsdf_layer, timestamp_ns);
103- publishGradientMapViz (gradient_map, tsdf_layer, timestamp_ns);
103+ publishHeightMapViz (height_map, tsdf_layer, timestamp_ns, robot_z );
104+ publishGradientMapViz (gradient_map, tsdf_layer, timestamp_ns, robot_z );
104105
105106 nav_msgs::msg::OccupancyGrid msg;
106107 msg.header .frame_id = GlobalInfo::instance ().getFrames ().map ;
@@ -143,7 +144,9 @@ void TsdfGradientOccupancyPublisher::fillOccupancyGrid(
143144 msg.info .height = std::ceil (dims.y ());
144145 msg.info .origin .position .x = x_min.x ();
145146 msg.info .origin .position .y = x_min.y ();
146- msg.info .origin .position .z = 0 .0f ;
147+ msg.info .origin .position .z =
148+ config.use_relative_height ? static_cast <float >(world_T_sensor.translation ().z ())
149+ : 0 .0f ;
147150 msg.info .origin .orientation .w = 1.0 ;
148151 msg.data .resize (msg.info .width * msg.info .height , -1 );
149152
@@ -277,7 +280,8 @@ int8_t TsdfGradientOccupancyPublisher::gradientToOccupancy(float gradient,
277280
278281void TsdfGradientOccupancyPublisher::publishHeightMapViz (const HeightMap& height_map,
279282 const TsdfLayer& layer,
280- uint64_t timestamp_ns) const {
283+ uint64_t timestamp_ns,
284+ float robot_z) const {
281285 if (!height_map_pub_->get_subscription_count ()) {
282286 return ;
283287 }
@@ -316,7 +320,7 @@ void TsdfGradientOccupancyPublisher::publishHeightMapViz(const HeightMap& height
316320 msg.info .height = std::ceil (dims.y ());
317321 msg.info .origin .position .x = x_min.x ();
318322 msg.info .origin .position .y = x_min.y ();
319- msg.info .origin .position .z = 0.0 ;
323+ msg.info .origin .position .z = config. use_relative_height ? robot_z : 0 . 0f ;
320324 msg.info .origin .orientation .w = 1.0 ;
321325 msg.data .resize (msg.info .width * msg.info .height , -1 );
322326
@@ -351,7 +355,8 @@ void TsdfGradientOccupancyPublisher::publishHeightMapViz(const HeightMap& height
351355void TsdfGradientOccupancyPublisher::publishGradientMapViz (
352356 const GradientMap& gradient_map,
353357 const TsdfLayer& layer,
354- uint64_t timestamp_ns) const {
358+ uint64_t timestamp_ns,
359+ float robot_z) const {
355360 if (!gradient_map_pub_->get_subscription_count ()) {
356361 return ;
357362 }
@@ -383,7 +388,7 @@ void TsdfGradientOccupancyPublisher::publishGradientMapViz(
383388 msg.info .height = std::ceil (dims.y ());
384389 msg.info .origin .position .x = x_min.x ();
385390 msg.info .origin .position .y = x_min.y ();
386- msg.info .origin .position .z = 0.0 ;
391+ msg.info .origin .position .z = config. use_relative_height ? robot_z : 0 . 0f ;
387392 msg.info .origin .orientation .w = 1.0 ;
388393 msg.data .resize (msg.info .width * msg.info .height , -1 );
389394
0 commit comments