Formula Student Autonomous Systems
The code for the main driverless system
Loading...
Searching...
No Matches
vehicle_adapter.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
8#include "custom_interfaces/msg/imu_data.hpp"
9#include "custom_interfaces/msg/operational_status.hpp"
10#include "custom_interfaces/msg/steering_angle.hpp"
11#include "custom_interfaces/msg/wheel_rpm.hpp"
12#include "geometry_msgs/msg/vector3_stamped.hpp"
13#include "node/node.hpp"
14#include "std_srvs/srv/empty.hpp"
15#include "std_srvs/srv/trigger.hpp"
16
23class VehicleAdapter : public VENode {
24 message_filters::Subscriber<custom_interfaces::msg::WheelRPM>
26 message_filters::Subscriber<custom_interfaces::msg::WheelRPM>
28
29 message_filters::Subscriber<geometry_msgs::msg::Vector3Stamped> _free_acceleration_subscription_;
30 message_filters::Subscriber<geometry_msgs::msg::Vector3Stamped> _angular_velocity_subscription_;
31 using XsensImuPolicy = message_filters::sync_policies::ApproximateTime<
32 geometry_msgs::msg::Vector3Stamped,
33 geometry_msgs::msg::Vector3Stamped>;
34 using WheelSSPolicy = message_filters::sync_policies::ApproximateTime<
35 custom_interfaces::msg::WheelRPM,
36 custom_interfaces::msg::WheelRPM>;
37 std::shared_ptr<message_filters::Synchronizer<WheelSSPolicy>>
39 std::shared_ptr<message_filters::Synchronizer<XsensImuPolicy>> _xsens_imu_sync_;
40
41 rclcpp::Subscription<custom_interfaces::msg::SteeringAngle>::SharedPtr _steering_angle_sub_;
42
43 rclcpp::Subscription<custom_interfaces::msg::WheelRPM>::SharedPtr _resolver_sub_;
44
46 double average_imu_bias = 0.0;
48
49public:
50 explicit VehicleAdapter(const VEParameters& parameters);
55 void imu_callback(const geometry_msgs::msg::Vector3Stamped::SharedPtr& free_acceleration_msg,
56 const geometry_msgs::msg::Vector3Stamped::SharedPtr& angular_velocity_msg);
61 void wss_callback(const custom_interfaces::msg::WheelRPM& rl_wheel_rpm_msg,
62 const custom_interfaces::msg::WheelRPM& rr_wheel_rpm_msg);
63
67 void steering_angle_callback(const custom_interfaces::msg::SteeringAngle msg);
68
72 void resolver_callback(custom_interfaces::msg::WheelRPM msg);
73};
friend class VehicleAdapter
Definition planning.hpp:88
Node class for the velocity estimation node.
Definition node.hpp:16
Adapter for interfacing with the real vehicle hardware.
Definition vehicle.hpp:15
rclcpp::Subscription< custom_interfaces::msg::WheelRPM >::SharedPtr _resolver_sub_
void wss_callback(const custom_interfaces::msg::WheelRPM &rl_wheel_rpm_msg, const custom_interfaces::msg::WheelRPM &rr_wheel_rpm_msg)
Wheel speed subscription callback, which receives both wheel speeds through a synchronizer message fi...
std::shared_ptr< message_filters::Synchronizer< WheelSSPolicy > > _wss_sync_
Synchronizer for wheel speeds.
rclcpp::Subscription< custom_interfaces::msg::SteeringAngle >::SharedPtr _steering_angle_sub_
message_filters::sync_policies::ApproximateTime< geometry_msgs::msg::Vector3Stamped, geometry_msgs::msg::Vector3Stamped > XsensImuPolicy
Policy for synchronizing Xsens IMU data.
Definition vehicle.hpp:40
void imu_callback(const geometry_msgs::msg::Vector3Stamped::SharedPtr &free_acceleration_msg, const geometry_msgs::msg::Vector3Stamped::SharedPtr &angular_velocity_msg)
IMU subscription callback, which receives both free acceleration and angular velocity through a synch...
message_filters::Subscriber< custom_interfaces::msg::WheelRPM > _fl_wheel_rpm_subscription_
Subscriber for fl wheel rpm.
double last_decent_fl_wss_reading
void steering_angle_callback(const custom_interfaces::msg::SteeringAngle msg)
Callback for the subscription of the steering angle sensor.
void resolver_callback(custom_interfaces::msg::WheelRPM msg)
Callback for the subscription of the resolver which measures the motor RPM.
message_filters::Subscriber< geometry_msgs::msg::Vector3Stamped > _free_acceleration_subscription_
Definition vehicle.hpp:29
message_filters::sync_policies::ApproximateTime< custom_interfaces::msg::WheelRPM, custom_interfaces::msg::WheelRPM > WheelSSPolicy
Policy for synchronizing wheel speeds.
message_filters::Subscriber< custom_interfaces::msg::WheelRPM > _fr_wheel_rpm_subscription_
Subscriber for fr wheel rpm.
message_filters::Subscriber< geometry_msgs::msg::Vector3Stamped > _angular_velocity_subscription_
Definition vehicle.hpp:30
std::shared_ptr< message_filters::Synchronizer< XsensImuPolicy > > _xsens_imu_sync_
Definition vehicle.hpp:50