mirror of
https://github.com/YikeStone/ros_arduino_bridge.git
synced 2025-08-03 19:24:09 +05:30
Fixed bug in base_controller.py that reversed left/right for encoder counts and motor speeds
This commit is contained in:
parent
b9913e6d6a
commit
8d89f851fc
Binary file not shown.
Binary file not shown.
Binary file not shown.
@ -118,7 +118,7 @@ class BaseController:
|
|||||||
if now > self.t_next:
|
if now > self.t_next:
|
||||||
# Read the encoders
|
# Read the encoders
|
||||||
try:
|
try:
|
||||||
right_enc, left_enc = self.arduino.get_encoder_counts()
|
left_enc, right_enc = self.arduino.get_encoder_counts()
|
||||||
except:
|
except:
|
||||||
self.bad_encoder_count += 1
|
self.bad_encoder_count += 1
|
||||||
rospy.logerr("Encoder exception count: " + str(self.bad_encoder_count))
|
rospy.logerr("Encoder exception count: " + str(self.bad_encoder_count))
|
||||||
@ -180,7 +180,6 @@ class BaseController:
|
|||||||
odom.twist.twist.linear.y = 0
|
odom.twist.twist.linear.y = 0
|
||||||
odom.twist.twist.angular.z = vth
|
odom.twist.twist.angular.z = vth
|
||||||
|
|
||||||
|
|
||||||
self.odomPub.publish(odom)
|
self.odomPub.publish(odom)
|
||||||
|
|
||||||
if now > (self.last_cmd_vel + rospy.Duration(self.timeout)):
|
if now > (self.last_cmd_vel + rospy.Duration(self.timeout)):
|
||||||
@ -189,10 +188,8 @@ class BaseController:
|
|||||||
|
|
||||||
# Set motor speeds in encoder ticks per PID loop
|
# Set motor speeds in encoder ticks per PID loop
|
||||||
if not self.stopped:
|
if not self.stopped:
|
||||||
if self.motors_reversed:
|
self.arduino.drive(self.v_left, self.v_right)
|
||||||
self.arduino.drive(self.v_left, self.v_right)
|
|
||||||
else:
|
|
||||||
self.arduino.drive(self.v_right, self.v_left)
|
|
||||||
|
|
||||||
def stop(self):
|
def stop(self):
|
||||||
self.stopped = True
|
self.stopped = True
|
||||||
|
Binary file not shown.
Loading…
x
Reference in New Issue
Block a user