Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[cooperative perception] Move motion model mapping default values to MotionModelMapping class #2203

Merged
merged 3 commits into from
Dec 4, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -72,11 +72,11 @@ auto to_detection_list_msg(const carma_v2x_msgs::msg::SensorDataSharingMessage &

struct MotionModelMapping
{
std::uint8_t small_vehicle_model;
std::uint8_t large_vehicle_model;
std::uint8_t motorcycle_model;
std::uint8_t pedestrian_model;
std::uint8_t unknown_model;
std::uint8_t small_vehicle_model{carma_cooperative_perception_interfaces::msg::Detection::MOTION_MODEL_CTRV};
std::uint8_t large_vehicle_model{carma_cooperative_perception_interfaces::msg::Detection::MOTION_MODEL_CTRV};
std::uint8_t motorcycle_model{carma_cooperative_perception_interfaces::msg::Detection::MOTION_MODEL_CTRV};
std::uint8_t pedestrian_model{carma_cooperative_perception_interfaces::msg::Detection::MOTION_MODEL_CTRV};
std::uint8_t unknown_model{carma_cooperative_perception_interfaces::msg::Detection::MOTION_MODEL_CTRV};
};

auto to_detection_msg(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -114,26 +114,6 @@ auto ExternalObjectListToDetectionListNode::handle_on_configure(
}
});

declare_parameter(
"small_vehicle_motion_model",
carma_cooperative_perception_interfaces::msg::Detection::MOTION_MODEL_CTRV);

declare_parameter(
"large_vehicle_motion_model",
carma_cooperative_perception_interfaces::msg::Detection::MOTION_MODEL_CTRV);

declare_parameter(
"motorcycle_motion_model",
carma_cooperative_perception_interfaces::msg::Detection::MOTION_MODEL_CTRA);

declare_parameter(
"pedestrian_motion_model",
carma_cooperative_perception_interfaces::msg::Detection::MOTION_MODEL_CV);

declare_parameter(
"unknown_motion_model",
carma_cooperative_perception_interfaces::msg::Detection::MOTION_MODEL_CV);

on_set_parameters_callback_ =
add_on_set_parameters_callback([this](const std::vector<rclcpp::Parameter> & parameters) {
rcl_interfaces::msg::SetParametersResult result;
Expand Down Expand Up @@ -164,6 +144,19 @@ auto ExternalObjectListToDetectionListNode::handle_on_configure(
return result;
});

// TODO(Adam Morrissett): Look into how the motion model mapping can be re-architected
// to avoid requiring this sequence. Maybe something like a mapping class that calls the
// declared parameters. Then the to_detected_object() function could be templated on a
// mapping strategy.

// Declarations must come after on_set_parameters_callback_ assignment because the ROS
// runtime will call the callback if declare_parameter() succeeds.
declare_parameter("small_vehicle_motion_model", motion_model_mapping_.small_vehicle_model);
declare_parameter("large_vehicle_motion_model", motion_model_mapping_.large_vehicle_model);
declare_parameter("motorcycle_motion_model", motion_model_mapping_.motorcycle_model);
declare_parameter("pedestrian_motion_model", motion_model_mapping_.pedestrian_model);
declare_parameter("unknown_motion_model", motion_model_mapping_.unknown_model);

return carma_ros2_utils::CallbackReturn::SUCCESS;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ auto make_detection(const carma_cooperative_perception_interfaces::msg::Detectio
return make_ctra_detection(msg);

case msg.MOTION_MODEL_CV:
break;
throw std::runtime_error("unsupported motion model type '3: constant velocity (CV)'");
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

actually why is this unsupported again?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

pedestrian seems to be using CV model
std::uint8_t pedestrian_model{carma_cooperative_perception_interfaces::msg::Detection::MOTION_MODEL_CV};

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That is the default, but in practice we will probably change it through parameters in the launch configuration. I will change the default to be CTRV since that is supported.

We don't support CV models because the multiple_object_tracking library does not have them. We can add it in, but that would be a different issue.

}

throw std::runtime_error("unkown motion model type '" + std::to_string(msg.motion_model) + "'");
Expand Down