From 2f2a29796ca97a7e8f73c3bac82d72404c1667eb Mon Sep 17 00:00:00 2001 From: Milosz Lagan Date: Wed, 4 Dec 2024 12:49:04 +0000 Subject: [PATCH] Add pad deadzone --- .../husarion_ugv_crsf_teleop/crsf_teleop_node.py | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/husarion_ugv_crsf_teleop/husarion_ugv_crsf_teleop/crsf_teleop_node.py b/husarion_ugv_crsf_teleop/husarion_ugv_crsf_teleop/crsf_teleop_node.py index 4dea357..fe6eb3e 100644 --- a/husarion_ugv_crsf_teleop/husarion_ugv_crsf_teleop/crsf_teleop_node.py +++ b/husarion_ugv_crsf_teleop/husarion_ugv_crsf_teleop/crsf_teleop_node.py @@ -38,6 +38,8 @@ LINK_QUALITY_VERY_LOW_THRESHOLD = 15 LINK_QUALITY_LOW_THRESHOLD = 30 +PAD_DEADZONE = 0.02 + # RC remote to channel id mapping class Switch(IntEnum): @@ -194,6 +196,11 @@ def handle_message(self, msg: CRSFMessage): t.linear.x = channels[Switch.RIGHT_HORIZONTAL] * linear_speed_modifier t.angular.z = -channels[Switch.LEFT_VERTICAL] * angular_speed_modifier + if abs(t.linear.x) < PAD_DEADZONE: + t.linear.x = 0 + if abs(t.angular.z) < PAD_DEADZONE: + t.angular.z = 0 + self.cmd_vel_publisher.publish(t) elif msg.msg_type == PacketType.LINK_STATISTICS: