Add behavior for i2cnode and choosing side

This commit is contained in:
2025-05-07 21:06:34 +02:00
parent 0677b9568e
commit 07cc056853
8 changed files with 138 additions and 18 deletions

View File

@ -28,7 +28,7 @@ namespace mg {
"/dynamicObstacle", rclcpp::QoS(1).keep_last(1), dynamic_cb, sub_opts);
side_sub_ = node_->create_subscription<std_msgs::msg::String>(
"/side", rclcpp::QoS(1).keep_last(1).transient_local(), [this](std_msgs::msg::String::ConstSharedPtr msg) {
"/side", rclcpp::QoS(1).keep_last(1), [this](std_msgs::msg::String::ConstSharedPtr msg) {
Json::Value json;
RCLCPP_INFO(node_->get_logger(), "Read file %s", (base_path + "/" + msg->data).c_str());
std::ifstream json_document(base_path + "/" + msg->data);
@ -38,7 +38,7 @@ namespace mg {
});
std::string obstacle_pkg;
std::string file_suffix = "/obstacles/obstacles.json";
std::string file_suffix = "/obstacles/yellow-side.json";
node_->declare_parameter("obstacles", rclcpp::PARAMETER_STRING);
node_->get_parameter_or<std::string>("obstacles", obstacle_pkg, "mg_obstacles/obstacles");
ulong n = obstacle_pkg.find_first_of('/');