Formula Student Autonomous Systems
The code for the main driverless system
Loading...
Searching...
No Matches
vehicle.hpp
Go to the documentation of this file.
1#pragma once
2
3#include <message_filters/subscriber.h>
4#include <message_filters/sync_policies/approximate_time.h>
5#include <message_filters/synchronizer.h>
6#include <message_filters/time_synchronizer.h>
7
9#include "custom_interfaces/msg/imu_data.hpp"
10#include "custom_interfaces/msg/operational_status.hpp"
11#include "custom_interfaces/msg/steering_angle.hpp"
12#include "custom_interfaces/msg/wheel_rpm.hpp"
13#include "geometry_msgs/msg/vector3_stamped.hpp"
14#include "std_srvs/srv/empty.hpp"
15#include "std_srvs/srv/trigger.hpp"
16
17class SENode;
18
19class VehicleAdapter : public Adapter {
20 message_filters::Subscriber<custom_interfaces::msg::WheelRPM>
22 message_filters::Subscriber<custom_interfaces::msg::WheelRPM>
24 message_filters::Subscriber<custom_interfaces::msg::SteeringAngle>
26 rclcpp::Subscription<custom_interfaces::msg::OperationalStatus>::SharedPtr
28
29 message_filters::Subscriber<geometry_msgs::msg::Vector3Stamped> _free_acceleration_subscription_;
30 message_filters::Subscriber<geometry_msgs::msg::Vector3Stamped> _angular_velocity_subscription_;
31
32 message_filters::Subscriber<custom_interfaces::msg::ImuData> _roll_accx_imu_subscription_;
33 message_filters::Subscriber<custom_interfaces::msg::ImuData> _yaw_accy_imu_subscription_;
34
35 using ImuPolicy = message_filters::sync_policies::ApproximateTime<
36 custom_interfaces::msg::ImuData,
37 custom_interfaces::msg::ImuData>;
38 using XsensImuPolicy = message_filters::sync_policies::ApproximateTime<
39 geometry_msgs::msg::Vector3Stamped,
40 geometry_msgs::msg::Vector3Stamped>;
41 using WheelSteerPolicy = message_filters::sync_policies::ApproximateTime<
42 custom_interfaces::msg::WheelRPM, custom_interfaces::msg::WheelRPM,
43 custom_interfaces::msg::SteeringAngle>;
45 std::shared_ptr<message_filters::Synchronizer<WheelSteerPolicy>>
47
48 std::shared_ptr<message_filters::Synchronizer<ImuPolicy>> _imu_sync_;
49
50 std::shared_ptr<message_filters::Synchronizer<XsensImuPolicy>> _xsens_imu_sync_;
51
52 rclcpp::Client<std_srvs::srv::Trigger>::SharedPtr
54
60 const custom_interfaces::msg::WheelRPM& rl_wheel_rpm_msg,
61 const custom_interfaces::msg::WheelRPM& rr_wheel_rpm_msg,
62 const custom_interfaces::msg::SteeringAngle& steering_angle_msg);
63
71 void imu_subscription_callback(const custom_interfaces::msg::ImuData& roll_accx_data,
72 const custom_interfaces::msg::ImuData& yaw_accy_data);
73
83 const geometry_msgs::msg::Vector3Stamped::SharedPtr& free_acceleration_msg,
84 const geometry_msgs::msg::Vector3Stamped::SharedPtr& angular_velocity_msg);
85
86public:
87 explicit VehicleAdapter(std::shared_ptr<SENode> se_node);
88
89 void finish() final;
90};
Class that handles the communication between the SpeedEstimation node and the other nodes in the syst...
Definition adapter.hpp:21
friend class VehicleAdapter
Definition planning.hpp:88
Class representing the main speed_est node responsible for publishing the calculated vehicle state wi...
Definition se_node.hpp:33
Adapter for interfacing with the real vehicle hardware.
Definition vehicle.hpp:15
rclcpp::Client< std_srvs::srv::Trigger >::SharedPtr _finished_client_
Client for finished signal.
Definition vehicle.hpp:53
message_filters::Subscriber< custom_interfaces::msg::ImuData > _yaw_accy_imu_subscription_
Definition vehicle.hpp:33
message_filters::Subscriber< custom_interfaces::msg::WheelRPM > _rr_wheel_rpm_subscription_
Subscriber for rr wheel rpm.
Definition vehicle.hpp:23
message_filters::sync_policies::ApproximateTime< custom_interfaces::msg::ImuData, custom_interfaces::msg::ImuData > ImuPolicy
Policy for synchronizing IMU data.
Definition vehicle.hpp:37
message_filters::Subscriber< custom_interfaces::msg::ImuData > _roll_accx_imu_subscription_
Definition vehicle.hpp:32
message_filters::Subscriber< custom_interfaces::msg::SteeringAngle > _steering_angle_subscription_
Subscriber for steering angle.
Definition vehicle.hpp:25
void xsens_imu_subscription_callback(const geometry_msgs::msg::Vector3Stamped::SharedPtr &free_acceleration_msg, const geometry_msgs::msg::Vector3Stamped::SharedPtr &angular_velocity_msg)
Xsens IMU subscription callback, which receives both free acceleration and angular velocity data sepa...
Definition vehicle.cpp:65
std::shared_ptr< message_filters::Synchronizer< WheelSteerPolicy > > _sync_
Synchronizer for wheel speeds and steering angle.
Definition vehicle.hpp:46
message_filters::sync_policies::ApproximateTime< geometry_msgs::msg::Vector3Stamped, geometry_msgs::msg::Vector3Stamped > XsensImuPolicy
Policy for synchronizing Xsens IMU data.
Definition vehicle.hpp:40
rclcpp::Subscription< custom_interfaces::msg::OperationalStatus >::SharedPtr _operational_status_subscription_
Subscriber for operational status.
Definition vehicle.hpp:27
message_filters::sync_policies::ApproximateTime< custom_interfaces::msg::WheelRPM, custom_interfaces::msg::WheelRPM, custom_interfaces::msg::SteeringAngle > WheelSteerPolicy
Policy for synchronizing wheel speeds and steering angle.
Definition vehicle.hpp:44
message_filters::Subscriber< geometry_msgs::msg::Vector3Stamped > _free_acceleration_subscription_
Definition vehicle.hpp:29
void imu_subscription_callback(const custom_interfaces::msg::ImuData &roll_accx_data, const custom_interfaces::msg::ImuData &yaw_accy_data)
IMU subscriptio callback, which receives both roll and yaw acceleration data separately and synchroni...
Definition vehicle.cpp:55
std::shared_ptr< message_filters::Synchronizer< ImuPolicy > > _imu_sync_
Definition vehicle.hpp:48
message_filters::Subscriber< custom_interfaces::msg::WheelRPM > _rl_wheel_rpm_subscription_
Subscriber for rl wheel rpm.
Definition vehicle.hpp:21
message_filters::Subscriber< geometry_msgs::msg::Vector3Stamped > _angular_velocity_subscription_
Definition vehicle.hpp:30
void finish() final
Function that sends the finish signal to the respective node.
Definition vehicle.cpp:76
std::shared_ptr< message_filters::Synchronizer< XsensImuPolicy > > _xsens_imu_sync_
Definition vehicle.hpp:50
void wheel_speeds_subscription_callback(const custom_interfaces::msg::WheelRPM &rl_wheel_rpm_msg, const custom_interfaces::msg::WheelRPM &rr_wheel_rpm_msg, const custom_interfaces::msg::SteeringAngle &steering_angle_msg)
Wheel speed subscription callback, which receives both wheel speeds and steering angle through a sync...
Definition vehicle.cpp:44