Skip to content

Instantly share code, notes, and snippets.

@JasonRBowling
Created September 24, 2022 16:21
Show Gist options
  • Save JasonRBowling/16664659910432eea5924e83b5e5785b to your computer and use it in GitHub Desktop.
Save JasonRBowling/16664659910432eea5924e83b5e5785b to your computer and use it in GitHub Desktop.
Wheel Speed Calculations
# Calculate wheel speeds in m/s
#reference https://snapcraft.io/blog/your-first-robot-the-driver-4-5
left_wheel_vel = data.linear.x - ((data.angular.z * wheel_base) / 2.0)
right_wheel_vel = data.linear.x + ((data.angular.z * wheel_base) / 2.0)
# convert the required wheel speeds in m/s into rpms
c = math.pi * wheel_diameter # wheel circumference in meters
right_rpm = int((right_wheel_vel / c) * 60.0 * gear_ratio)
left_rpm = int((left_wheel_vel / c) * 60.0 * gear_ratio)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment