4#include "custom_interfaces/msg/cone.hpp"
5#include "custom_interfaces/msg/cone_array.hpp"
6#include "custom_interfaces/msg/point2d.hpp"
7#include "pacsim/msg/wheels.hpp"
12 "/pacsim/imu/cog_imu", 3,
18 this->
_sync_ = std::make_shared<message_filters::Synchronizer<WheelSteerPolicy>>(
22 if (this->
node_->_use_simulated_perception_) {
24 this->
node_->create_subscription<pacsim::msg::PerceptionDetections>(
25 "/pacsim/perception/lidar/landmarks", 1,
27 std::placeholders::_1));
31 this->
node_->create_client<std_srvs::srv::Empty>(
"/pacsim/finish_signal");
35 const pacsim::msg::Wheels& wheels_msg,
const pacsim::msg::StampedScalar& steering_angle_msg) {
36 this->
node_->_wheel_speeds_subscription_callback(wheels_msg.rl, wheels_msg.fl, wheels_msg.rr,
37 wheels_msg.fr, steering_angle_msg.value,
38 steering_angle_msg.stamp);
43 std::make_shared<std_srvs::srv::Empty::Request>(),
44 [
this](rclcpp::Client<std_srvs::srv::Empty>::SharedFuture) {
45 RCLCPP_INFO(this->
node_->get_logger(),
"Finished signal sent");
50 const pacsim::msg::PerceptionDetections& msg) {
51 custom_interfaces::msg::ConeArray cone_array_msg;
52 for (
const pacsim::msg::PerceptionDetection& detection : msg.detections) {
53 custom_interfaces::msg::Point2d position = custom_interfaces::msg::Point2d();
54 position.x = detection.pose.pose.position.x;
55 position.y = detection.pose.pose.position.y;
56 auto cone_message = custom_interfaces::msg::Cone();
57 cone_message.position = position;
58 cone_message.confidence = detection.detection_probability;
60 common_lib::competition_logic::Color::UNKNOWN);
61 cone_array_msg.cone_array.push_back(cone_message);
63 cone_array_msg.header.stamp = msg.header.stamp;
64 this->
node_->_perception_subscription_callback(cone_array_msg);
Class that handles the communication between the SpeedEstimation node and the other nodes in the syst...
void imu_subscription_callback(const sensor_msgs::msg::Imu &msg)
Function that parses the message sent from the ros IMU topic and calls the respective node's function...
std::shared_ptr< SENode > node_
rclcpp::Subscription< pacsim::msg::PerceptionDetections >::SharedPtr _perception_detections_subscription_
Subscriber for simulated perception detections.
rclcpp::Subscription< sensor_msgs::msg::Imu >::SharedPtr _imu_subscription_
Subscriber for simulated IMU data.
message_filters::Subscriber< pacsim::msg::Wheels > _pacsim_wheel_speeds_subscription_
Subscriber for wheel speeds.
message_filters::sync_policies::ApproximateTime< pacsim::msg::Wheels, pacsim::msg::StampedScalar > WheelSteerPolicy
Policy for synchronizing wheel speeds and steering angle.
std::shared_ptr< message_filters::Synchronizer< WheelSteerPolicy > > _sync_
Synchronizer for wheel speeds and steering angle.
PacsimAdapter(std::shared_ptr< SENode > se_node)
void perception_detections_subscription_callback(const pacsim::msg::PerceptionDetections &msg)
Callback for simulated perception detections from pacsim.
void wheel_speeds_subscription_callback(const pacsim::msg::Wheels &wheels_msg, const pacsim::msg::StampedScalar &steering_angle_msg)
Wheel speed subscription callback, which receives both wheel speeds and steering angle through a sync...
void finish() final
Function that sends the finish signal to the respective node.
rclcpp::Client< std_srvs::srv::Empty >::SharedPtr _finished_client_
Client for finished signal.
message_filters::Subscriber< pacsim::msg::StampedScalar > _steering_angle_subscription_
Subscriber for steering angle.
std::string get_color_string(int color)