It is a library for controlling Wallbot

Dependents:   wallbot_test

Embed: (wiki syntax)

« Back to documentation index

wallbot Class Reference

wallbot Class Reference

wallbot control class More...

#include <wallbot.h>

Public Member Functions

 wallbot ()
 Create the wallbot object connected to the default 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.
float GetLinePosition (void)
 Get floorline position.
void GetLinePosition (int *bit)
 Get floorline position.
int GetLeftSw (void)
 Get left switch .
int GetRightSw (void)
 Get GetRightSw switch .

Detailed Description

wallbot control class

Example:

 // Drive the wwallbot forward, turn left, back, turn right, at half speed for half a second

#include "mbed.h"
#include "wallbot.h"

wallbot wb;
 
int main() {

    wait(0.5);
    
    wb.forward(0.5);
    wait (0.5);
    wb.left(0.5);
    wait (0.5);
    wb.backward(0.5);
    wait (0.5);
    wb.right(0.5);
    wait (0.5);
    
    wb.stop();

 }

Definition at line 66 of file wallbot.h.


Constructor & Destructor Documentation

wallbot (  )

Create the wallbot object connected to the default pins.

Definition at line 30 of file wallbot.cpp.


Member Function Documentation

void backward ( float  speed )

Drive both motors backward as the same speed.

Parameters:
speedA normalised number 0 - 1.0 represents the full range.

Definition at line 55 of file wallbot.cpp.

void forward ( float  speed )

Drive both motors forward as the same speed.

Parameters:
speedA normalised number 0 - 1.0 represents the full range.

Definition at line 50 of file wallbot.cpp.

int GetLeftSw ( void   )

Get left switch .

(switch OFF:0 or ON:1 return.)

Definition at line 121 of file wallbot.cpp.

float GetLinePosition ( void   )

Get floorline position.

(float value return.)

Definition at line 76 of file wallbot.cpp.

void GetLinePosition ( int *  bit )

Get floorline position.

(bit value return.)

Definition at line 105 of file wallbot.cpp.

int GetRightSw ( void   )

Get GetRightSw switch .

(switch OFF:0 or ON:1 return.)

Definition at line 125 of file wallbot.cpp.

void left ( float  speed )

Drive left motor backwards and right motor forwards at the same speed to turn on the spot.

Parameters:
speedA normalised number 0 - 1.0 represents the full range.

Definition at line 60 of file wallbot.cpp.

void left_motor ( float  speed )

Directly control the speed and direction of the left motor.

Parameters:
speedA normalised number -1.0 - 1.0 represents the full range.

Definition at line 42 of file wallbot.cpp.

void right ( float  speed )

Drive left motor forward and right motor backwards at the same speed to turn on the spot.

Parameters:
speedA normalised number 0 - 1.0 represents the full range.

Definition at line 65 of file wallbot.cpp.

void right_motor ( float  speed )

Directly control the speed and direction of the right motor.

Parameters:
speedA normalised number -1.0 - 1.0 represents the full range.

Definition at line 46 of file wallbot.cpp.

void stop ( void   )

Stop both motors.

Definition at line 70 of file wallbot.cpp.