From fd24a16ce0a8d0890f7f3a8ce8656a7408e8398d Mon Sep 17 00:00:00 2001 From: Alexander Entinger Date: Tue, 23 Jan 2024 06:10:00 +0100 Subject: [PATCH] Change the RPM set-point to zero when an emergency button is pressed. --- src/Node.cpp | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/src/Node.cpp b/src/Node.cpp index 14f7a8e..96cd209 100644 --- a/src/Node.cpp +++ b/src/Node.cpp @@ -47,7 +47,7 @@ Node::Node() declare_parameter("can_node_id", 100); RCLCPP_INFO(get_logger(), - "configuring CAN bus:\n\tDevice: %s\n\tNode Id: %ld", + "configuring CAN bus:\n\tDevice: %s\n\tNode Id: %ld", get_parameter("can_iface").as_string().c_str(), get_parameter("can_node_id").as_int()); @@ -205,7 +205,10 @@ void Node::motor_left_ctrl_loop() float const motor_left_rpm = 60. * motor_left_rps.numerical_value_in(Hz); uavcan::primitive::scalar::Real32_1_0 rpm_left_msg; - rpm_left_msg.value = motor_left_rpm; + if (!_is_estop_active) + rpm_left_msg.value = motor_left_rpm; + else + rpm_left_msg.value = 0.f; { std::lock_guard lock(_node_mtx); @@ -278,7 +281,10 @@ void Node::motor_right_ctrl_loop() float const motor_right_rpm = 60. * motor_right_rps.numerical_value_in(Hz); uavcan::primitive::scalar::Real32_1_0 rpm_right_msg; - rpm_right_msg.value = motor_right_rpm; + if (!_is_estop_active) + rpm_right_msg.value = motor_right_rpm; + else + rpm_right_msg.value = 0.f; { std::lock_guard lock(_node_mtx);