Formula Student Autonomous Systems
The code for the main driverless system
Loading...
Searching...
No Matches
fsds.cpp
Go to the documentation of this file.
4
5FsdsAdapter::FsdsAdapter(std::shared_ptr<SENode> se_node) : Adapter(se_node) {
6 this->fsds_state_subscription_ = this->node_->create_subscription<fs_msgs::msg::GoSignal>(
7 "/signal/go", 10,
8 std::bind(&FsdsAdapter::mission_state_callback, this, std::placeholders::_1));
10 this->node_->create_publisher<fs_msgs::msg::FinishedSignal>("/signal/finished", 10);
11
13 this->node_->create_subscription<fs_msgs::msg::WheelStates>(
14 "/wheel_states", 10,
15 std::bind(&FsdsAdapter::wheel_speeds_subscription_callback, this, std::placeholders::_1));
16
17 this->_fs_imu_subscription_ = this->node_->create_subscription<sensor_msgs::msg::Imu>(
18 "/imu", rclcpp::QoS(10).reliability(RMW_QOS_POLICY_RELIABILITY_BEST_EFFORT),
19 std::bind(&Adapter::imu_subscription_callback, this, std::placeholders::_1));
20}
21
22void FsdsAdapter::mission_state_callback(const fs_msgs::msg::GoSignal& msg) const {
23 RCLCPP_DEBUG(this->node_->get_logger(), "Mission state received: %s",
24 std::string(msg.mission).c_str());
25 this->node_->_mission_ = common_lib::competition_logic::fsds_to_system.at(msg.mission);
26 this->node_->_go_ = true;
27}
28
30 auto message = fs_msgs::msg::FinishedSignal();
31 message.placeholder = true; // unnecessary
32
33 this->fsds_ebs_publisher_->publish(message);
34}
35
36void FsdsAdapter::wheel_speeds_subscription_callback(const fs_msgs::msg::WheelStates& msg) const {
37 double steering_angle = (msg.fl_steering_angle + msg.fr_steering_angle) / 2.0;
38 this->node_->_wheel_speeds_subscription_callback(msg.rl_rpm, msg.fl_rpm, msg.rr_rpm, msg.fr_rpm,
39 steering_angle, msg.header.stamp);
40}
Class that handles the communication between the SpeedEstimation node and the other nodes in the syst...
Definition adapter.hpp:21
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...
Definition adapter.cpp:8
std::shared_ptr< SENode > node_
Definition adapter.hpp:23
rclcpp::Subscription< fs_msgs::msg::WheelStates >::SharedPtr _fs_wheel_speeds_subscription_
Definition fsds.hpp:12
rclcpp::Subscription< sensor_msgs::msg::Imu >::SharedPtr _fs_imu_subscription_
Definition fsds.hpp:11
rclcpp::Publisher< fs_msgs::msg::FinishedSignal >::SharedPtr fsds_ebs_publisher_
Definition fsds.hpp:9
void wheel_speeds_subscription_callback(const fs_msgs::msg::WheelStates &msg) const
Definition fsds.cpp:36
void mission_state_callback(const fs_msgs::msg::GoSignal &msg) const
Definition fsds.cpp:22
void finish() final
Function that sends the finish signal to the respective node.
Definition fsds.cpp:29
rclcpp::Subscription< fs_msgs::msg::GoSignal >::SharedPtr fsds_state_subscription_
Definition fsds.hpp:8
friend class FsdsAdapter
Definition planning.hpp:87
const std::unordered_map< std::string, Mission > fsds_to_system