The XRP robot kit is an easy-to-use programmable robot for STEAM education. The standard kit has 2 wheels driven by encoded DC motors, a servo motor, a distance sensor, and a line sensor, all of which this library can control.
In addition, the XRP board can drive two extra encoded DC motors and 1 extra servo motors, and more. This library can control the second servo motor with no modifications, and can control the 3rd and 4th encoded DC motors with small modifications.
The units for blocks that control the wheels are:
The XRP library is entirely written in MicroBlocks, down to the PID control loop for the wheel motors. This means you can modify the software as you wish, including tweaking the control loop tuning parameters, providing an opportunity to learn about PID control.
For each block, there is a short description entry and a detailed block and component description. You can click on block pictures in the short description table to access the details.
Drive at the specified speed (mm/second). The speed can be different for the left and right wheels, so you can travel in an arc.
Drive straight for the specified distance (mm) at the specified speed (mm/second). Specify a negative distance (or a negative speed, but not both) to go backwards. Note: the speed cannot be zero, because the move would take forever.
Change the heading by the specified amount (degrees), moving the wheels at the specified speed (mm/sec). The robot turns about a point halfway between the wheels.
Stop both wheels.
Wait for both wheels to stop.
Set the specified servo motor to the specified angle (deg). The standard XRP kit includes one servo motor, but the board can drive 2.
Read roll rate (degrees/second). Positive roll tilts the left edge up.
Read pitch rate (degrees/second). Positive pitch tilts the nose up.
Read yaw rate (degrees/second). Positive yaw changes the heading to the right.
Read the distance sensor (cm).
Read the left and right line sensors.
Get the number of encoded DC motors connected to your XRP robot. If you have more 2, modify this block to return the actual number of motors. See Driving Additional Encoded DC Motors for more information.
The XRP robot kit can drive up to 4 encoded DC motors, but by default the XRP library only supports the first two (in order to speed up the feedback loop).
In order to control more motors, edit to return 3 or 4. Then use the Encoded DC Motors library to control the additional motors, using index 3 or 4. Note that the units are are different in the Encoded DC Motors library (encoder counts instead of mm).
You can also use any block in Encoded DC Motors to control the wheels. The left wheel is motor 1, the right wheel is motor 2. The robot moves forward when motor 1 moves in the positive direction and motor 2 moves in the negative direction.
If your additional motors need different control parameters than the main wheel motors, you can adjust the tuning parameters. See Tweaking Tuning Parameters
The XRP wheel motors use a PID loop and signal conditioning from the Encoded DC Motors library, which in turn uses the PID library. If you wish to try different tuning parameters:
show advanced blocks
in the gear menu_edcmotors_initSystemVariables
and select show block definition
to see and change what this block does. The tuning parameters are set starting with _edcmotors__pCoeff
and ending with _edcmotors__accel
Each is a list with one element per motor (the left wheel motor is motor 1, the right is motor 2).Notes:
_edcmotors__iCoeff
to a large value, the motion is likely to go unstable. You can reduce or fix this by setting _edcmotors__dCoeff
to a large value, and/or setting _edcmotors__maxIntegral
to a small value.Some useful XRP facts from the manufacturer's documentation:
Many thanks to Steve Spaeth, who wrote a preliminary version of this library.