| 45 | { |
| 46 | public: |
| 47 | explicit MappingNode(const rclcpp::NodeOptions & options) |
| 48 | // BEGIN STUDENT CODE |
| 49 | : rclcpp::Node("mapping_node", options) |
| 50 | // END STUDENT CODE |
| 51 | { |
| 52 | map_frame_id_ = declare_parameter<std::string>("map_frame", "map"); |
| 53 | robot_frame_id_ = declare_parameter<std::string>("robot_frame", "base_link"); |
| 54 | distance_coefficient_ = declare_parameter<double>("distance_coefficient", 0.01); |
| 55 | hit_log_odds_ = toLogOdds(declare_parameter<double>("hit_probability", 0.7)); |
| 56 | miss_log_odds_ = toLogOdds(declare_parameter<double>("miss_probability", 0.3)); |
| 57 | |
| 58 | const auto map_width = declare_parameter<double>("map_width", 1.2192); // meters |
| 59 | const auto map_height = declare_parameter<double>("map_height", 0.762); // meters |
| 60 | const auto map_resolution = declare_parameter<double>("map_resolution", 0.01); // meters/cell |
| 61 | |
| 62 | map_info_.origin.position.x = -map_width / 2.0; |
| 63 | map_info_.origin.position.y = -map_height / 2.0; |
| 64 | map_info_.height = map_height / map_resolution; |
| 65 | map_info_.width = map_width / map_resolution; |
| 66 | map_info_.resolution = map_resolution; |
| 67 | |
| 68 | const auto map_data_size = map_info_.height * map_info_.width; |
| 69 | map_data_.reserve(map_data_size); |
| 70 | std::fill_n(std::back_inserter(map_data_), map_data_size, 0.0); |
| 71 | |
| 72 | map_publisher_ = create_publisher<nav_msgs::msg::OccupancyGrid>( |
| 73 | "~/map", |
| 74 | rclcpp::SystemDefaultsQoS()); |
| 75 | |
| 76 | // BEGIN STUDENT CODE |
| 77 | // END STUDENT CODE |
| 78 | } |
| 79 | |
| 80 | private: |
| 81 | // BEGIN STUDENT CODE |
nothing calls this directly
no test coverage detected