Formula Student Autonomous Systems
The code for the main driverless system
Loading...
Searching...
No Matches
vehicle.cpp
Go to the documentation of this file.
1#include "adapter/vehicle.hpp"
2
4 : ControlNode(params),
5 go_sub_(create_subscription<custom_interfaces::msg::OperationalStatus>(
6 "/vehicle/operational_status", 10,
7 std::bind(&VehicleAdapter::go_signal_callback, this, std::placeholders::_1))),
8 control_pub_(
9 create_publisher<custom_interfaces::msg::ControlCommand>("/control/command", 10)) {
10 RCLCPP_INFO(this->get_logger(), "Vehicle adapter created");
11}
12
14 auto message = custom_interfaces::msg::ControlCommand();
15
16 message.throttle_rr = cmd.throttle_rr;
17 message.throttle_rl = cmd.throttle_rl;
18 message.throttle_fr = cmd.throttle_fr;
19 message.throttle_fl = cmd.throttle_fl;
20 message.steering = cmd.steering_angle;
21
22 this->control_pub_->publish(message);
23}
24
25void VehicleAdapter::go_signal_callback(const custom_interfaces::msg::OperationalStatus msg) {
26 go_signal_ = msg.go_signal;
27 if (!(msg.as_mission == common_lib::competition_logic::Mission::TRACKDRIVE) &&
28 !(msg.as_mission == common_lib::competition_logic::Mission::AUTOCROSS) &&
29 !(msg.as_mission == common_lib::competition_logic::Mission::SKIDPAD) &&
30 !(msg.as_mission == common_lib::competition_logic::Mission::ACCELERATION) &&
31 !(msg.as_mission == common_lib::competition_logic::Mission::EBS_TEST)) {
32 go_signal_ = false;
33 }
34}
Class responsible for the ROS2 communication of the control module.
Definition ros_node.hpp:26
bool go_signal_
Definition ros_node.hpp:28
friend class VehicleAdapter
Definition planning.hpp:88
Adapter for interfacing with the real vehicle hardware.
Definition vehicle.hpp:15
rclcpp::Publisher< custom_interfaces::msg::ControlCommand >::SharedPtr control_pub_
Definition vehicle.hpp:24
void go_signal_callback(const custom_interfaces::msg::OperationalStatus msg)
Definition vehicle.cpp:25
void publish_command(common_lib::structures::ControlCommand cmd) override
Adapters override this function to publish control commands in their environment.
Definition vehicle.cpp:13
Hash function for cones.
Definition cone.hpp:36