mirror of
https://github.com/SHC-ASTRA/rover-ros2.git
synced 2026-02-11 09:20:40 +00:00
fix: correctly account for neg linear
Rover couldn't drive forwards lmao... Now correctly inverts turning direction when driving backwards... Could use some work tho, a little confusing rn. Also got some rough measurements from the rover with a tape measurement, updated wheelbase and wheel radius.
This commit is contained in:
@@ -26,8 +26,8 @@ from geometry_msgs.msg import TwistStamped, Twist
|
|||||||
serial_pub = None
|
serial_pub = None
|
||||||
thread = None
|
thread = None
|
||||||
|
|
||||||
CORE_WHEELBASE = 0.34 # meters -- TODO: verify
|
CORE_WHEELBASE = 0.84 # meters -- TODO: verify
|
||||||
CORE_WHEEL_RADIUS = 0.075 # meters -- TODO: verify
|
CORE_WHEEL_RADIUS = 0.015 # meters -- TODO: verify
|
||||||
CORE_GEAR_RATIO = 100 # Clucky: 100:1, Testbed: 64:1
|
CORE_GEAR_RATIO = 100 # Clucky: 100:1, Testbed: 64:1
|
||||||
|
|
||||||
control_qos = qos.QoSProfile(
|
control_qos = qos.QoSProfile(
|
||||||
@@ -232,6 +232,9 @@ class SerialRelay(Node):
|
|||||||
linear = msg.linear.x # [-1 1] for forward/back from left joy y
|
linear = msg.linear.x # [-1 1] for forward/back from left joy y
|
||||||
angular = -msg.angular.z # [-1 1] for left/right from right joy x
|
angular = -msg.angular.z # [-1 1] for left/right from right joy x
|
||||||
|
|
||||||
|
if (linear < 0): # reverse turning direction when going backwards
|
||||||
|
angular *= -1
|
||||||
|
|
||||||
if abs(linear) > 1 or abs(angular) > 1:
|
if abs(linear) > 1 or abs(angular) > 1:
|
||||||
# if speed is greater than 1, then there is a problem
|
# if speed is greater than 1, then there is a problem
|
||||||
# make it look like a problem and don't just run away lmao
|
# make it look like a problem and don't just run away lmao
|
||||||
@@ -244,10 +247,6 @@ class SerialRelay(Node):
|
|||||||
duty_left /= scale
|
duty_left /= scale
|
||||||
duty_right /= 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"
|
command = f"can_relay_tovic,core,19,{duty_left},{duty_right}\n"
|
||||||
self.send_cmd(command)
|
self.send_cmd(command)
|
||||||
|
|
||||||
@@ -258,7 +257,7 @@ class SerialRelay(Node):
|
|||||||
output.data = msg
|
output.data = msg
|
||||||
self.anchor_pub.publish(output)
|
self.anchor_pub.publish(output)
|
||||||
elif self.launch_mode == 'core':
|
elif self.launch_mode == 'core':
|
||||||
self.get_logger().info(f"[Core to MCU] {msg.data}")
|
self.get_logger().info(f"[Core to MCU] {msg}")
|
||||||
self.ser.write(bytes(msg, "utf8"))
|
self.ser.write(bytes(msg, "utf8"))
|
||||||
|
|
||||||
def anchor_feedback(self, msg: String):
|
def anchor_feedback(self, msg: String):
|
||||||
|
|||||||
Reference in New Issue
Block a user