PsiSwarm Library  0.8
Motors Class Reference

#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)
 

Detailed Description

Motors class Functions to control the Psi Swarm robot motors

Example:

#include "psiswarm.h"
int main() {
init();
motors.forward(0.5); //Set the motors to forward at speed 0.5
wait(0.5);
motors.brake(); //Enable the hardware brake
wait(0.5);
motors.turn(0.5); //Turn clockwise at 50% speed
wait(0.5);
motors.stop(); //Sets motor speed to zero (but not hardware brake)
}

Definition at line 46 of file motors.h.

Member Function Documentation

§ backward()

void Motors::backward ( float  speed)

Sets both motors to the specified inverted speed

Parameters
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.

§ brake()

void Motors::brake ( void  )

Enable the active brake on the both motors

Definition at line 56 of file motors.cpp.

§ brake_left_motor()

void Motors::brake_left_motor ( void  )

Enable the active brake on the left motor

Definition at line 42 of file motors.cpp.

§ brake_right_motor()

void Motors::brake_right_motor ( void  )

Enable the active brake on the right motor

Definition at line 49 of file motors.cpp.

§ forward()

void Motors::forward ( float  speed)

Sets both motors to the specified speed

Parameters
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.

§ init_motors()

void Motors::init_motors ( void  )

Initialise the PWM settings for the motors

Definition at line 299 of file motors.cpp.

§ set_left_motor_speed()

void Motors::set_left_motor_speed ( float  speed)

Set the left motor to the specified speed

Parameters
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.

§ set_right_motor_speed()

void Motors::set_right_motor_speed ( float  speed)

Set the left motor to the specified speed

Parameters
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.

§ stop()

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.

§ time_based_forward()

void Motors::time_based_forward ( float  speed,
int  microseconds,
char  brake 
)

Make the robot move forward for a predetermined amount of time

Parameters
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.

§ time_based_turn()

void Motors::time_based_turn ( float  speed,
int  microseconds,
char  brake 
)

Make the robot turn for a predetermined amount of time

Parameters
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.

§ turn()

void Motors::turn ( float  speed)

Turn the robot on the spot by setting motors to equal and opposite speeds

Parameters
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.


The documentation for this class was generated from the following files: