MCPcopy Create free account
hub / github.com/RoboJackets/software-training / ObstaclesCallback

Method ObstaclesCallback

mapping/src/mapping_node.cpp:93–114  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

91 rclcpp::Subscription<nav_msgs::msg::OccupancyGrid>::SharedPtr obstacles_subscription_;
92
93 void ObstaclesCallback(const nav_msgs::msg::OccupancyGrid::SharedPtr obstacles_msg)
94 {
95 // BEGIN STUDENT CODE
96 // END STUDENT CODE
97
98 AddObstaclesToMap(*obstacles_msg);
99
100 nav_msgs::msg::OccupancyGrid map_msg;
101 map_msg.header.frame_id = map_frame_id_;
102 const auto current_time = now();
103 map_msg.header.stamp = current_time;
104 map_msg.info = map_info_;
105 map_msg.info.map_load_time = current_time;
106
107 std::transform(
108 map_data_.begin(), map_data_.end(), std::back_inserter(map_msg.data), [](
109 const auto & percent) {
110 return static_cast<int8_t>(fromLogOdds(percent) * 100);
111 });
112
113 map_publisher_->publish(map_msg);
114 }
115
116 geometry_msgs::msg::Point GetRobotLocation()
117 {

Callers

nothing calls this directly

Calls 1

fromLogOddsFunction · 0.70

Tested by

no test coverage detected