@@ -89,6 +89,9 @@ class CanTransceiverIntf : public NetNode
89
89
90
90
sail_cmd_sub_ = this ->create_subscription <msg::SailCmd>(
91
91
ros_topics::SAIL_CMD, QUEUE_SIZE, [this ](msg::SailCmd sail_cmd_) { subSailCmdCb (sail_cmd_); });
92
+ desired_heading_sub_ = this ->create_subscription <msg::DesiredHeading>(
93
+ ros_topics::DESIRED_HEADING, QUEUE_SIZE,
94
+ [this ](msg::DesiredHeading desired_heading_) { subDesiredHeading (desired_heading_); });
92
95
93
96
if (mode == SYSTEM_MODE::DEV) { // Initialize the CAN Sim Intf
94
97
mock_ais_sub_ = this ->create_subscription <msg::AISShips>(
@@ -129,6 +132,7 @@ class CanTransceiverIntf : public NetNode
129
132
rclcpp::Publisher<msg::GenericSensors>::SharedPtr generic_sensors_pub_;
130
133
msg::GenericSensors generic_sensors_;
131
134
rclcpp::Subscription<msg::DesiredHeading>::SharedPtr desired_heading_sub_;
135
+ msg::DesiredHeading desired_heading_;
132
136
rclcpp::Subscription<msg::SailCmd>::SharedPtr sail_cmd_sub_;
133
137
msg::SailCmd sail_cmd_;
134
138
@@ -213,7 +217,7 @@ class CanTransceiverIntf : public NetNode
213
217
* @brief Publish a GPS frame
214
218
* Intended to be registered as a callback with the CAN Tranceiver instance
215
219
*
216
- * @param gps_frame gps CAN rfame read from the CAN bus
220
+ * @param gps_frame gps CAN frame read from the CAN bus
217
221
*/
218
222
void publishGPS (const CanFrame & gps_frame)
219
223
{
@@ -307,6 +311,23 @@ class CanTransceiverIntf : public NetNode
307
311
RCLCPP_INFO (this ->get_logger (), " %s %s" , getCurrentTimeString ().c_str (), ss.str ().c_str ());
308
312
}
309
313
314
+ /* *
315
+ * @brief Subscribe to a MAIN_HEADING frame
316
+ * Intended to be registered as a callback with the CAN Tranceiver instance
317
+ *
318
+ * @param heading_frame main_heading CAN frame read from the CAN bus
319
+ */
320
+ void subDesiredHeading (msg::DesiredHeading & desired_heading_input)
321
+ {
322
+ msg::HelperHeading helper_msg;
323
+ helper_msg = desired_heading_input.heading ;
324
+ desired_heading_.set__heading (helper_msg);
325
+ desired_heading_.set__steering (desired_heading_input.steering );
326
+ auto main_heading_frame = CAN_FP::DesiredHeading (desired_heading_, CanId::MAIN_HEADING);
327
+ can_trns_->send (main_heading_frame.toLinuxCan ());
328
+ RCLCPP_INFO (this ->get_logger (), " %s %s" , getCurrentTimeString ().c_str (), main_heading_frame.toString ().c_str ());
329
+ }
330
+
310
331
// SIMULATION CALLBACKS //
311
332
312
333
/* *
0 commit comments