Skip to content

Commit c8a7ea6

Browse files
authored
Merge pull request #136 from Achllle/iss134_odomzerodiv
Fix #134 for ROS1, add warning
2 parents 3f865ea + ef77362 commit c8a7ea6

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

ROS/osr/src/rover.py

+6-1
Original file line numberDiff line numberDiff line change
@@ -324,7 +324,12 @@ def forward_kinematics(self):
324324
drive_angular_velocity = (self.curr_velocities['drive_left_middle'] + self.curr_velocities['drive_right_middle']) / 2.
325325
self.curr_twist.twist.linear.x = drive_angular_velocity * self.wheel_radius
326326
# now calculate angular velocity from its relation with linear velocity and turning radius
327-
self.curr_twist.twist.angular.z = self.curr_twist.twist.linear.x / self.curr_turning_radius
327+
try:
328+
self.curr_twist.twist.angular.z = self.curr_twist.twist.linear.x / self.curr_turning_radius
329+
except ZeroDivisionError:
330+
rospy.logwarn_throttle(1, "Current turning radius was calculated as zero which"
331+
"is an illegal value. Check your wheel calibration."
332+
self.curr_twist.twist.angular.z = 0. # turning in place is currently unsupported
328333

329334

330335
if __name__ == '__main__':

0 commit comments

Comments
 (0)