Skip to content

Commit

Permalink
Merge pull request #136 from Achllle/iss134_odomzerodiv
Browse files Browse the repository at this point in the history
Fix #134 for ROS1, add warning
  • Loading branch information
Achllle authored May 24, 2021
2 parents 3f865ea + ef77362 commit c8a7ea6
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion ROS/osr/src/rover.py
Original file line number Diff line number Diff line change
Expand Up @@ -324,7 +324,12 @@ def forward_kinematics(self):
drive_angular_velocity = (self.curr_velocities['drive_left_middle'] + self.curr_velocities['drive_right_middle']) / 2.
self.curr_twist.twist.linear.x = drive_angular_velocity * self.wheel_radius
# now calculate angular velocity from its relation with linear velocity and turning radius
self.curr_twist.twist.angular.z = self.curr_twist.twist.linear.x / self.curr_turning_radius
try:
self.curr_twist.twist.angular.z = self.curr_twist.twist.linear.x / self.curr_turning_radius
except ZeroDivisionError:
rospy.logwarn_throttle(1, "Current turning radius was calculated as zero which"
"is an illegal value. Check your wheel calibration."
self.curr_twist.twist.angular.z = 0. # turning in place is currently unsupported


if __name__ == '__main__':
Expand Down

0 comments on commit c8a7ea6

Please sign in to comment.