Formula Student Autonomous Systems
The code for the main driverless system
Loading...
Searching...
No Matches
PacsimAdapter Class Reference

Adapter class to interface with the Pacsim simulator for SLAM. More...

#include <pacsim.hpp>

Inheritance diagram for PacsimAdapter:
Inheritance graph
Collaboration diagram for PacsimAdapter:
Collaboration graph

Public Member Functions

 PacsimAdapter (std::shared_ptr< SENode > se_node)
 
void finish () final
 Function that sends the finish signal to the respective node.
 
 PacsimAdapter (const SLAMParameters &params)
 Constructor of the pacsim adapter node.
 
void finish () override
 Function that sends the finish signal to the respective node.
 
 PacsimAdapter (const VEParameters &parameters)
 
void imu_callback (const sensor_msgs::msg::Imu::SharedPtr msg)
 callback that gets called when the IMU data is received
 
void wss_callback (const pacsim::msg::Wheels::SharedPtr msg)
 callback that gets called when the wheel speeds are received
 
void steering_angle_callback (const pacsim::msg::StampedScalar::SharedPtr msg)
 callback that gets called when the steering angle is received
 
- Public Member Functions inherited from Adapter
 Adapter (std::shared_ptr< SENode > se_node)
 
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 to update the motion.
 
virtual ~Adapter ()=default
 
- Public Member Functions inherited from SLAMNode
 SLAMNode (const SLAMParameters &params)
 Constructor that uses the parameters structure.
 
void init ()
 Initialize functions @description This method is used to initialize things that require the constructed node.
 
- Public Member Functions inherited from VENode
 VENode (const VEParameters &parameters)
 

Private Types

using WheelSteerPolicy = message_filters::sync_policies::ApproximateTime< pacsim::msg::Wheels, pacsim::msg::StampedScalar >
 Policy for synchronizing wheel speeds and steering angle.
 

Private Member Functions

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 synchronizer message filter.
 
void perception_detections_subscription_callback (const pacsim::msg::PerceptionDetections &msg)
 Callback for simulated perception detections from pacsim.
 
void _pacsim_perception_subscription_callback (const pacsim::msg::PerceptionDetections &msg)
 Callback for simulated perception detections from pacsim.
 
void _pacsim_velocities_subscription_callback (const geometry_msgs::msg::TwistWithCovarianceStamped &msg)
 Callback for simulated velocities from pacsim.
 
void _pacsim_imu_subscription_callback (const sensor_msgs::msg::Imu &msg)
 Callback for simulated IMU data from pacsim.
 
void fetch_discipline ()
 Fetches the mission from the parameters.
 

Private Attributes

message_filters::Subscriber< pacsim::msg::Wheels > _pacsim_wheel_speeds_subscription_
 Subscriber for wheel speeds.
 
message_filters::Subscriber< pacsim::msg::StampedScalar > _steering_angle_subscription_
 Subscriber for steering angle.
 
std::shared_ptr< message_filters::Synchronizer< WheelSteerPolicy > > _sync_
 Synchronizer for wheel speeds and steering angle.
 
rclcpp::Subscription< pacsim::msg::PerceptionDetections >::SharedPtr _perception_detections_subscription_
 Subscriber for simulated perception detections.
 
rclcpp::Client< std_srvs::srv::Empty >::SharedPtr _finished_client_
 Client for finished signal.
 
rclcpp::Subscription< geometry_msgs::msg::TwistWithCovarianceStamped >::SharedPtr _velocities_subscription_
 Subscriber for simulated velocities.
 
rclcpp::Subscription< sensor_msgs::msg::Imu >::SharedPtr _imu_subscription_
 Subscriber for simulated IMU data.
 
rclcpp::Client< rcl_interfaces::srv::GetParameters >::SharedPtr param_client_
 
rclcpp::Subscription< sensor_msgs::msg::Imu >::SharedPtr _imu_sub_
 
rclcpp::Subscription< pacsim::msg::Wheels >::SharedPtr wheel_speeds_sub_
 
rclcpp::Subscription< pacsim::msg::StampedScalar >::SharedPtr _steering_angle_sub_
 

Additional Inherited Members

- Public Attributes inherited from Adapter
std::shared_ptr< SENodenode_
 
rclcpp::Subscription< sensor_msgs::msg::Imu >::SharedPtr _imu_subscription_
 
- Protected Member Functions inherited from SLAMNode
void _perception_subscription_callback (const custom_interfaces::msg::PerceptionOutput &msg)
 Callback that updates everytime information is received from the perception module.
 
void _velocities_subscription_callback (const custom_interfaces::msg::Velocities &msg)
 Callback that updates everytime information is received from velocity estimation node.
 
void _imu_subscription_callback (const sensor_msgs::msg::Imu &msg)
 Callback that updates everytime information is received from the IMU.
 
void _publish_vehicle_pose ()
 publishes the localization ('vehicle_pose') to the topic vehicle_pose
 
void _publish_map ()
 publishes the map ('track_map') to the topic track_map
 
void _publish_associations ()
 Publishes the visualization of the associations by data association.
 
void _publish_covariance ()
 publishes the covariance of the state
 
void _publish_lap_counter ()
 publishes the lap counter
 
bool _is_mission_finished ()
 Checks if the mission is finished.
 
- Protected Member Functions inherited from VENode
void publish_velocities () const
 
- Protected Attributes inherited from SLAMNode
rclcpp::CallbackGroup::SharedPtr _callback_group_
 Callback group for subscriptions, used to control if they are concurrent or not.
 
rclcpp::Subscription< custom_interfaces::msg::PerceptionOutput >::SharedPtr _perception_subscription_
 
rclcpp::Subscription< custom_interfaces::msg::Velocities >::SharedPtr _velocities_subscription_
 
rclcpp::Publisher< custom_interfaces::msg::Pose >::SharedPtr _vehicle_pose_publisher_
 
rclcpp::Publisher< custom_interfaces::msg::ConeArray >::SharedPtr _map_publisher_
 
rclcpp::Publisher< visualization_msgs::msg::MarkerArray >::SharedPtr _visualization_map_publisher_
 
rclcpp::Publisher< visualization_msgs::msg::Marker >::SharedPtr _position_visualization_publisher_
 Publishes the vehicle position.
 
rclcpp::Publisher< visualization_msgs::msg::MarkerArray >::SharedPtr _trajectory_visualization_publisher_
 Publishes full vehicle trajectory.
 
rclcpp::Publisher< visualization_msgs::msg::MarkerArray >::SharedPtr _associations_visualization_publisher_
 
rclcpp::Publisher< std_msgs::msg::Float64MultiArray >::SharedPtr _execution_time_publisher_
 
rclcpp::Publisher< std_msgs::msg::Float64MultiArray >::SharedPtr _covariance_publisher_
 Publishes the covariance of the pose.
 
rclcpp::Publisher< std_msgs::msg::Float64 >::SharedPtr _lap_counter_publisher_
 
rclcpp::Publisher< std_msgs::msg::Float64 >::SharedPtr _perception_delta_publisher_
 
rclcpp::Time _last_perception_message_time_ = rclcpp::Time(0)
 
rclcpp::CallbackGroup::SharedPtr _parallel_callback_group_
 
std::shared_mutex mutex_
 
std::shared_ptr< tf2_ros::TransformBroadcaster > _tf_broadcaster_
 
rclcpp::TimerBase::SharedPtr _timer_
 timer
 
std::shared_ptr< SLAMSolver_slam_solver_
 SLAM solver object.
 
std::vector< common_lib::structures::Cone_perception_map_
 
common_lib::structures::Velocities _vehicle_state_velocities_
 
std::vector< common_lib::structures::Cone_track_map_
 
Eigen::VectorXi _associations_
 
Eigen::VectorXd _observations_global_
 Global observations of the cones.
 
Eigen::VectorXd _map_coordinates_
 Coordinates of the cones in the map.
 
common_lib::structures::Pose _vehicle_pose_
 
std::shared_ptr< std::vector< double > > _execution_times_
 
common_lib::competition_logic::Mission _mission_ = common_lib::competition_logic::Mission::NONE
 
bool _go_ = true
 
std::string _adapter_name_
 flag to start the mission
 
std::string _vehicle_frame_id_
 Frame id of the vehicle for the transform.
 
SLAMParameters _params_
 
- Protected Attributes inherited from VENode
VEParameters _parameters_
 
std::shared_ptr< VelocityEstimator_velocity_estimator_
 
rclcpp::Publisher< custom_interfaces::msg::Velocities >::SharedPtr _velocities_pub_
 

Detailed Description

Adapter class to interface with the Pacsim simulator for SLAM.

Adapter class for the pacsim simulator.

This class subscribes to the necessary topics from Pacsim and adapts the data for use in the SLAM node

This class subscribes to the IMU, wheel speeds, and steering angle topics published by the pacsim simulator. It then passes the data to the velocity estimator for processing.

Definition at line 17 of file pacsim.hpp.

Member Typedef Documentation

◆ WheelSteerPolicy

using PacsimAdapter::WheelSteerPolicy = message_filters::sync_policies::ApproximateTime< pacsim::msg::Wheels, pacsim::msg::StampedScalar>
private

Policy for synchronizing wheel speeds and steering angle.

Definition at line 23 of file pacsim.hpp.

Constructor & Destructor Documentation

◆ PacsimAdapter() [1/3]

PacsimAdapter::PacsimAdapter ( std::shared_ptr< SENode se_node)
explicit

Definition at line 10 of file pacsim.cpp.

Here is the call graph for this function:

◆ PacsimAdapter() [2/3]

PacsimAdapter::PacsimAdapter ( const SLAMParameters params)

Constructor of the pacsim adapter node.

Definition at line 10 of file pacsim.cpp.

Here is the call graph for this function:

◆ PacsimAdapter() [3/3]

PacsimAdapter::PacsimAdapter ( const VEParameters parameters)
explicit

Definition at line 3 of file pacsim_adapter.cpp.

Here is the call graph for this function:

Member Function Documentation

◆ _pacsim_imu_subscription_callback()

void PacsimAdapter::_pacsim_imu_subscription_callback ( const sensor_msgs::msg::Imu &  msg)
private

Callback for simulated IMU data from pacsim.

Parameters
msgMessage containing the IMU data of the vehicle

Definition at line 135 of file pacsim.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ _pacsim_perception_subscription_callback()

void PacsimAdapter::_pacsim_perception_subscription_callback ( const pacsim::msg::PerceptionDetections &  msg)
private

Callback for simulated perception detections from pacsim.

Parameters
msgMessage containing the array of perceived detections

Definition at line 98 of file pacsim.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ _pacsim_velocities_subscription_callback()

void PacsimAdapter::_pacsim_velocities_subscription_callback ( const geometry_msgs::msg::TwistWithCovarianceStamped &  msg)
private

Callback for simulated velocities from pacsim.

Parameters
msgMessage containing the velocities of the vehicle

Definition at line 120 of file pacsim.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ fetch_discipline()

void PacsimAdapter::fetch_discipline ( )
private

Fetches the mission from the parameters.

Definition at line 57 of file pacsim.cpp.

Here is the caller graph for this function:

◆ finish() [1/2]

void PacsimAdapter::finish ( )
finalvirtual

Function that sends the finish signal to the respective node.

Implements Adapter.

Definition at line 41 of file pacsim.cpp.

◆ finish() [2/2]

void PacsimAdapter::finish ( )
overridevirtual

Function that sends the finish signal to the respective node.

Implements Adapter.

◆ imu_callback()

void PacsimAdapter::imu_callback ( const sensor_msgs::msg::Imu::SharedPtr  msg)

callback that gets called when the IMU data is received

Definition at line 15 of file pacsim_adapter.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ perception_detections_subscription_callback()

void PacsimAdapter::perception_detections_subscription_callback ( const pacsim::msg::PerceptionDetections &  msg)
private

Callback for simulated perception detections from pacsim.

Parameters
msgMessage containing the array of perceived detections

Definition at line 49 of file pacsim.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ steering_angle_callback()

void PacsimAdapter::steering_angle_callback ( const pacsim::msg::StampedScalar::SharedPtr  msg)

callback that gets called when the steering angle is received

Definition at line 32 of file pacsim_adapter.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ wheel_speeds_subscription_callback()

void PacsimAdapter::wheel_speeds_subscription_callback ( const pacsim::msg::Wheels &  wheels_msg,
const pacsim::msg::StampedScalar &  steering_angle_msg 
)
private

Wheel speed subscription callback, which receives both wheel speeds and steering angle through a synchronizer message filter.

Definition at line 34 of file pacsim.cpp.

Here is the caller graph for this function:

◆ wss_callback()

void PacsimAdapter::wss_callback ( const pacsim::msg::Wheels::SharedPtr  msg)

callback that gets called when the wheel speeds are received

Definition at line 22 of file pacsim_adapter.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

Member Data Documentation

◆ _finished_client_

rclcpp::Client< std_srvs::srv::Empty >::SharedPtr PacsimAdapter::_finished_client_
private

Client for finished signal.

Definition at line 33 of file pacsim.hpp.

◆ _imu_sub_

rclcpp::Subscription<sensor_msgs::msg::Imu>::SharedPtr PacsimAdapter::_imu_sub_
private

Definition at line 17 of file pacsim_adapter.hpp.

◆ _imu_subscription_

rclcpp::Subscription<sensor_msgs::msg::Imu>::SharedPtr PacsimAdapter::_imu_subscription_
private

Subscriber for simulated IMU data.

Definition at line 24 of file pacsim.hpp.

◆ _pacsim_wheel_speeds_subscription_

message_filters::Subscriber<pacsim::msg::Wheels> PacsimAdapter::_pacsim_wheel_speeds_subscription_
private

Subscriber for wheel speeds.

Definition at line 19 of file pacsim.hpp.

◆ _perception_detections_subscription_

rclcpp::Subscription< pacsim::msg::PerceptionDetections >::SharedPtr PacsimAdapter::_perception_detections_subscription_
private

Subscriber for simulated perception detections.

Definition at line 30 of file pacsim.hpp.

◆ _steering_angle_sub_

rclcpp::Subscription<pacsim::msg::StampedScalar>::SharedPtr PacsimAdapter::_steering_angle_sub_
private

Definition at line 19 of file pacsim_adapter.hpp.

◆ _steering_angle_subscription_

message_filters::Subscriber<pacsim::msg::StampedScalar> PacsimAdapter::_steering_angle_subscription_
private

Subscriber for steering angle.

Definition at line 21 of file pacsim.hpp.

◆ _sync_

std::shared_ptr<message_filters::Synchronizer<WheelSteerPolicy> > PacsimAdapter::_sync_
private

Synchronizer for wheel speeds and steering angle.

Definition at line 27 of file pacsim.hpp.

◆ _velocities_subscription_

rclcpp::Subscription<geometry_msgs::msg::TwistWithCovarianceStamped>::SharedPtr PacsimAdapter::_velocities_subscription_
private

Subscriber for simulated velocities.

Definition at line 21 of file pacsim.hpp.

◆ param_client_

rclcpp::Client<rcl_interfaces::srv::GetParameters>::SharedPtr PacsimAdapter::param_client_
private

Definition at line 29 of file pacsim.hpp.

◆ wheel_speeds_sub_

rclcpp::Subscription<pacsim::msg::Wheels>::SharedPtr PacsimAdapter::wheel_speeds_sub_
private

Definition at line 18 of file pacsim_adapter.hpp.


The documentation for this class was generated from the following files: