ZumoにFRDM KL-25Zを搭載した時のモーターコントロールライブラリです。 PWM用の端子が互換していないので、割り込みでパルスを作っています。 デフォルトは100Hzの10段階になっています。
ZumoControl Class Reference
Zumo motor control class. More...
#include <ZumoControl.h>
Public Member Functions | |
ZumoControl () | |
Create the Zumo object connected to the default pins. | |
ZumoControl (PinName rc, PinName rp, PinName lc, PinName lp) | |
Create the Zumo object connected to specific pins. | |
void | left_motor (float speed) |
Directly control the speed and direction of the left motor. | |
void | right_motor (float speed) |
Directly control the speed and direction of the right motor. | |
void | forward (float speed) |
Drive both motors forward as the same speed. | |
void | backward (float speed) |
Drive both motors backward as the same speed. | |
void | left (float speed) |
Drive left motor backwards and right motor forwards at the same speed to turn on the spot. | |
void | right (float speed) |
Drive left motor forward and right motor backwards at the same speed to turn on the spot. | |
void | stop (void) |
Stop both motors. |
Detailed Description
Zumo motor control class.
Example:
// Drive the Zumo forward, turn left, back, turn right, at half speed for half a second #include "mbed.h" #include "ZumoControl.h" ZumoControl zumo_ctrl; int main() { wait(0.5); zumo_ctrl.forward(0.5); wait (0.5); zumo_ctrl.left(0.5); wait (0.5); zumo_ctrl.backward(0.5); wait (0.5); zumo_ctrl.right(0.5); wait (0.5); zumo_ctrl.stop(); }
Definition at line 60 of file ZumoControl.h.
Constructor & Destructor Documentation
ZumoControl | ( | ) |
Create the Zumo object connected to the default pins.
- Parameters:
-
rc GPIO pin used for Right motor control. Default is PTC9 rp GPIO pin used for Right motor PWM. Default is PTD5 lc GPIO pin used for Left motor control. Default is PTA13 lp GPIO pin used for Left motor PWM. Default is PTD0
Definition at line 39 of file ZumoControl.cpp.
ZumoControl | ( | PinName | rc, |
PinName | rp, | ||
PinName | lc, | ||
PinName | lp | ||
) |
Create the Zumo object connected to specific pins.
Definition at line 27 of file ZumoControl.cpp.
Member Function Documentation
void backward | ( | float | speed ) |
Drive both motors backward as the same speed.
- Parameters:
-
speed A normalised number 0 - 1.0 represents the full range.
Definition at line 106 of file ZumoControl.cpp.
void forward | ( | float | speed ) |
Drive both motors forward as the same speed.
- Parameters:
-
speed A normalised number 0 - 1.0 represents the full range.
Definition at line 99 of file ZumoControl.cpp.
void left | ( | float | speed ) |
Drive left motor backwards and right motor forwards at the same speed to turn on the spot.
- Parameters:
-
speed A normalised number 0 - 1.0 represents the full range.
Definition at line 113 of file ZumoControl.cpp.
void left_motor | ( | float | speed ) |
Directly control the speed and direction of the left motor.
- Parameters:
-
speed A normalised number -1.0 - 1.0 represents the full range.
Definition at line 75 of file ZumoControl.cpp.
void right | ( | float | speed ) |
Drive left motor forward and right motor backwards at the same speed to turn on the spot.
- Parameters:
-
speed A normalised number 0 - 1.0 represents the full range.
Definition at line 120 of file ZumoControl.cpp.
void right_motor | ( | float | speed ) |
Directly control the speed and direction of the right motor.
- Parameters:
-
speed A normalised number -1.0 - 1.0 represents the full range.
Definition at line 87 of file ZumoControl.cpp.
void stop | ( | void | ) |
Stop both motors.
Definition at line 127 of file ZumoControl.cpp.
Generated on Thu Jul 14 2022 10:25:10 by 1.7.2