mirror of
https://github.com/SHC-ASTRA/rover-ros2.git
synced 2026-02-11 09:20:40 +00:00
fix: correct turning direction
This commit is contained in:
@@ -217,7 +217,7 @@ class SerialRelay(Node):
|
||||
|
||||
def cmd_vel_callback(self, msg: TwistStamped):
|
||||
linear = msg.twist.linear.x
|
||||
angular = msg.twist.angular.z
|
||||
angular = -msg.twist.angular.z
|
||||
|
||||
vel_left_rads = (linear - (angular * CORE_WHEELBASE / 2)) / CORE_WHEEL_RADIUS
|
||||
vel_right_rads = (linear + (angular * CORE_WHEELBASE / 2)) / CORE_WHEEL_RADIUS
|
||||
@@ -235,7 +235,8 @@ class SerialRelay(Node):
|
||||
if abs(linear) > 1 or abs(angular) > 1:
|
||||
# if speed is greater than 1, then there is a problem
|
||||
# make it look like a problem and don't just run away lmao
|
||||
drive_speed = 0.25
|
||||
linear = 0.25 * (linear / abs(linear))
|
||||
angular = 0.25 * (angular / abs(angular))
|
||||
|
||||
duty_left = linear - angular
|
||||
duty_right = linear + angular
|
||||
@@ -243,6 +244,10 @@ class SerialRelay(Node):
|
||||
duty_left /= scale
|
||||
duty_right /= scale
|
||||
|
||||
if (linear < 0): # reverse direction when going backwards
|
||||
duty_left *= -1
|
||||
duty_right *= -1
|
||||
|
||||
command = f"can_relay_tovic,core,19,{duty_left},{duty_right}\n"
|
||||
self.send_cmd(command)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user