![]() |
PsiSwarm Library
0.8
|
#include <motors.h>
Public Member Functions | |
void | set_left_motor_speed (float speed) |
void | set_right_motor_speed (float speed) |
void | brake_left_motor (void) |
void | brake_right_motor (void) |
void | brake (void) |
void | stop (void) |
void | forward (float speed) |
void | backward (float speed) |
void | turn (float speed) |
void | init_motors (void) |
void | time_based_forward (float speed, int microseconds, char brake) |
void | time_based_turn (float speed, int microseconds, char brake) |
int | time_based_turn_degrees (float speed, float degrees, char brake) |
float | get_maximum_turn_angle (int microseconds) |
int | get_time_based_turn_time (float speed, float degrees) |
Motors class Functions to control the Psi Swarm robot motors
Example:
void Motors::backward | ( | float | speed | ) |
Sets both motors to the specified inverted speed
speed | - Set the motors to the specified speed (range -1.0 for max. forward to 1.0 for max. reverse) |
Definition at line 83 of file motors.cpp.
void Motors::brake | ( | void | ) |
Enable the active brake on the both motors
Definition at line 56 of file motors.cpp.
void Motors::brake_left_motor | ( | void | ) |
Enable the active brake on the left motor
Definition at line 42 of file motors.cpp.
void Motors::brake_right_motor | ( | void | ) |
Enable the active brake on the right motor
Definition at line 49 of file motors.cpp.
void Motors::forward | ( | float | speed | ) |
Sets both motors to the specified speed
speed | - Set the motors to the specified speed (range -1.0 for max. reverse to 1.0 for max. forward) |
Definition at line 74 of file motors.cpp.
void Motors::init_motors | ( | void | ) |
Initialise the PWM settings for the motors
Definition at line 299 of file motors.cpp.
void Motors::set_left_motor_speed | ( | float | speed | ) |
Set the left motor to the specified speed
speed | - The set motor to the specified (range -1.0 for max. reverse to 1.0 for max. forward) |
Definition at line 28 of file motors.cpp.
void Motors::set_right_motor_speed | ( | float | speed | ) |
Set the left motor to the specified speed
speed | - The set motor to the specified (range -1.0 for max. reverse to 1.0 for max. forward) |
Definition at line 35 of file motors.cpp.
void Motors::stop | ( | void | ) |
Stop both motors This sets the speed of both motors to 0; it does not enable the active brake
Definition at line 65 of file motors.cpp.
void Motors::time_based_forward | ( | float | speed, |
int | microseconds, | ||
char | brake | ||
) |
Make the robot move forward for a predetermined amount of time
speed | - Sets the motors to the specified speed (range -1.0 for max. forward to 1.0 for max. reverse) |
microseconds | - The duration to keep moving |
brake | - If set to 1, the brake instruction will be applied at the end of the move, else motors are just set to stop |
Definition at line 103 of file motors.cpp.
void Motors::time_based_turn | ( | float | speed, |
int | microseconds, | ||
char | brake | ||
) |
Make the robot turn for a predetermined amount of time
speed | - Sets the turning speed (range -1.0 for max. counter-clockwise to 1.0 for max. clockwise) |
microseconds | - The duration to keep moving |
brake | - If set to 1, the brake instruction will be applied at the end of the move, else motors are just set to stop |
Definition at line 115 of file motors.cpp.
void Motors::turn | ( | float | speed | ) |
Turn the robot on the spot by setting motors to equal and opposite speeds
speed | - Sets the turning speed (range -1.0 for max. counter-clockwise to 1.0 for max. clockwise) |
Definition at line 92 of file motors.cpp.