Formula Student Autonomous Systems
The code for the main driverless system
Loading...
Searching...
No Matches
pacsim_adapter.cpp
Go to the documentation of this file.
2
3PacsimAdapter::PacsimAdapter(const VEParameters& parameters) : VENode(parameters) {
4 _imu_sub_ = this->create_subscription<sensor_msgs::msg::Imu>(
5 "/pacsim/imu/cog_imu", 1,
6 std::bind(&PacsimAdapter::imu_callback, this, std::placeholders::_1));
7 wheel_speeds_sub_ = this->create_subscription<pacsim::msg::Wheels>(
8 "/pacsim/wheelspeeds", 1,
9 std::bind(&PacsimAdapter::wss_callback, this, std::placeholders::_1));
10 _steering_angle_sub_ = this->create_subscription<pacsim::msg::StampedScalar>(
11 "/pacsim/steeringFront", 1,
12 std::bind(&PacsimAdapter::steering_angle_callback, this, std::placeholders::_1));
13}
14
15void PacsimAdapter::imu_callback(const sensor_msgs::msg::Imu::SharedPtr msg) {
16 common_lib::sensor_data::ImuData imu_data(msg->angular_velocity.z, msg->linear_acceleration.x,
17 msg->linear_acceleration.y, msg->header.stamp);
18 this->_velocity_estimator_->imu_callback(imu_data);
19 this->publish_velocities();
20}
21
22void PacsimAdapter::wss_callback(const pacsim::msg::Wheels::SharedPtr msg) {
23 common_lib::sensor_data::WheelEncoderData wheel_encoder_data(msg->rl, msg->rr, msg->fl, msg->fr,
24 0.0, msg->stamp);
25 this->_velocity_estimator_->wss_callback(wheel_encoder_data);
26 this->_velocity_estimator_->motor_rpm_callback(0.5 *
28 (msg->rl + msg->rr)); // Simulate resolver data
29 this->publish_velocities();
30}
31
32void PacsimAdapter::steering_angle_callback(const pacsim::msg::StampedScalar::SharedPtr msg) {
33 this->_velocity_estimator_->steering_callback(msg->value);
34 this->publish_velocities();
35}
void steering_angle_callback(const pacsim::msg::StampedScalar::SharedPtr msg)
callback that gets called when the steering angle is received
rclcpp::Subscription< pacsim::msg::Wheels >::SharedPtr wheel_speeds_sub_
void wss_callback(const pacsim::msg::Wheels::SharedPtr msg)
callback that gets called when the wheel speeds are received
PacsimAdapter(std::shared_ptr< SENode > se_node)
Definition pacsim.cpp:10
void imu_callback(const sensor_msgs::msg::Imu::SharedPtr msg)
callback that gets called when the IMU data is received
rclcpp::Subscription< sensor_msgs::msg::Imu >::SharedPtr _imu_sub_
rclcpp::Subscription< pacsim::msg::StampedScalar >::SharedPtr _steering_angle_sub_
Node class for the velocity estimation node.
Definition node.hpp:16
void publish_velocities() const
Definition node.cpp:10
VEParameters _parameters_
Definition node.hpp:18
std::shared_ptr< VelocityEstimator > _velocity_estimator_
Definition node.hpp:19
common_lib::car_parameters::CarParameters car_parameters_