A standard SnappyXO differential drive robot is the easiest way to use the Path Follower library. This tutorial will guide you through adding a path following feature to your SnappyXO robot.
A sample robot using the SnappyXO robotics kit have been put together in this page.
Change the baud rate of the HM10 as follows:
Upload the demo code by opening the Arduino App on your computer.
Go to File → Examples → PreMo - Precise Mover → SnappyXO_PathFollower
Note that this example code has two tabs:
loop()
and setup()
functions and this is where your custom code is going to go. Double check and change these constants in the "SnappyXO_PathFollower" tab:
RADIUS
- Wheel radius in mm.LENGTH
- Axle length in mm (distance from the left to right wheel).Before we upload the code, we need to validate and test the motors, encoders, and the bluetooth module.
testMotors()
in setup() and upload. Observe that the motors move according to the serial monitor prints.testMotors()
and Uncomment testEncoders()
in setup() and upload. Spin the left and right wheel one revolution, the left and right pulses should be close to PULSES__PER_REV.BLUETOOTH_TX
and BLUETOOTH_RX
set to the proper pins. Check that the bluetooth functionality is working by moving the joystick. You should see the steering and throttle values change as you move the joystick on the serial monitor. If any of the above tests fail, the path follower will not work. Troubleshoot and fix them first. Here are some troubleshooting tips:
First, try the provided values in the example code. If that does not work well, try the following.
First set the KD value to zero. Then increase the KP value until the robot can follow a path. Then, try increasing the KD value to improve the path following. The KD is typically much smaller than KP.
Follow these steps to have your robot follow a drawn path!
The triangle represents the robot location and heading and the blue dot is the goal point that the robot is trying to follow.