Christian Burri / Mbed 2 deprecated autonomousRobotAndroid

Dependencies:   mbed

Fork of autonomousRobotAndroid by Christian Burri

Embed: (wiki syntax)

« Back to documentation index

RobotControl Class Reference

RobotControl Class Reference

This class controls the position of the robot. It has a run loop that is called periodically. This run loop reads the actual positions of the wheels, calculates the actual position and orientation of the robot, calculates to move the robot and writes these velocity values to the motor servo drives. This class offers methods to enable or disable the controller, and to set the desired x- and y-postion and the values of the robot. More...

#include <RobotControl.h>

Inherits Task.

Public Member Functions

 RobotControl (MaxonESCON *motorControllerLeft, MaxonESCON *motorControllerRight, float period)
 Creates a Robot Control object and initializes all private state variables.
virtual ~RobotControl ()
 Destructor of the Object to destroy the Object.
void setEnable (bool enable)
 Enables or disables the servo drives of the motors.
bool isEnabled ()
 Tests if the servo drives of the motors are enabled.
void setDesiredSpeed (float speed)
 Sets the desired translational speed of the robot.
void setDesiredOmega (float omega)
 Sets the desired rotational speed of the robot.
void setDesiredxPosition (float xposition)
 Sets the desired X-position of the robot.
void setDesiredyPosition (float yposition)
 Sets the desired Y-position of the robot.
void setDesiredTheta (float theta)
 Sets the desired of the robot.
float getDesiredxPosition ()
 Get the desired X-position of the robot.
float getDesiredyPosition ()
 Get the desired Y-position of the robot.
float getDesiredTheta ()
 Get the desired of the robot.
void setDesiredPositionAndAngle (float xposition, float yposition, float theta)
 Sets the desired Position and .
float getTheta ()
 Gets the desired of the goal point.
float getDesiredSpeed ()
 Gets the desired translational speed of the robot.
float getActualSpeed ()
 Gets the actual translational speed of the robot.
float getDesiredOmega ()
 Gets the desired rotational speed of the robot.
float getActualOmega ()
 Gets the actual rotational speed of the robot.
float getxActualPosition ()
 Gets the actual translational X-position of the robot.
float getxPositionError ()
 Gets the X-position following error of the robot.
float getyActualPosition ()
 Gets the actual translational Y-position of the robot.
float getyPositionError ()
 Gets the Y-position following error of the robot.
float getActualTheta ()
 Gets the actual orientation of the robot.
float getThetaError ()
 Gets the orientation following error of the robot.
float getDistanceError ()
 Gets the distance to disired point.
float getThetaErrorToGoal ()
 Gets the ot the pointing vector to the goal right the unicycle axis from actual point.
float getThetaGoal ()
 Gets the ot the pointing vector to the goal right the unicycle main axis.
void setAllToZero (float xZeroPos, float yZeroPos, float theta)
 Set all state to zero, except the X-position, y-position and .
void run ()
 Run method actualize every period.
float getPeriod ()
 Gets the period of this task.
void start ()
 Starts this task.
void stop ()
 Stops this task.

Detailed Description

This class controls the position of the robot. It has a run loop that is called periodically. This run loop reads the actual positions of the wheels, calculates the actual position and orientation of the robot, calculates to move the robot and writes these velocity values to the motor servo drives. This class offers methods to enable or disable the controller, and to set the desired x- and y-postion and the values of the robot.

Author:
Christian Burri

Copyright (c) 2013 HSLU Pren Team #1 Cruising Crêpe All rights reserved.

THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

Definition at line 34 of file RobotControl.h.


Constructor & Destructor Documentation

RobotControl ( MaxonESCON motorControllerLeft,
MaxonESCON motorControllerRight,
float  period 
)

Creates a Robot Control object and initializes all private state variables.

Parameters:
motorControllerLefta reference to the servo drive for the left motor
motorControllerRighta reference to the servo drive for the right motor
periodthe sampling period of the run loop of this controller, given in [s]

Definition at line 5 of file RobotControl.cpp.

~RobotControl (  ) [virtual]

Destructor of the Object to destroy the Object.

Definition at line 29 of file RobotControl.cpp.


Member Function Documentation

float getActualOmega (  )

Gets the actual rotational speed of the robot.

Returns:
the desired speed, given in [rad/s]

Definition at line 125 of file RobotControl.cpp.

float getActualSpeed ( void   )

Gets the actual translational speed of the robot.

Returns:
the desired speed, given in [m/s]

Definition at line 115 of file RobotControl.cpp.

float getActualTheta (  )

Gets the actual orientation of the robot.

Returns:
the orientation, given in [rad]

Definition at line 150 of file RobotControl.cpp.

float getDesiredOmega (  )

Gets the desired rotational speed of the robot.

Returns:
the desired speed, given in [rad/s]

Definition at line 120 of file RobotControl.cpp.

float getDesiredSpeed (  )

Gets the desired translational speed of the robot.

Returns:
the desired speed, given in [m/s]

Definition at line 110 of file RobotControl.cpp.

float getDesiredTheta (  )

Get the desired of the robot.

Returns:
theta the desired , given in [rad]

Definition at line 91 of file RobotControl.cpp.

float getDesiredxPosition (  )

Get the desired X-position of the robot.

Returns:
xposition the desired position, given in [m]

Definition at line 81 of file RobotControl.cpp.

float getDesiredyPosition (  )

Get the desired Y-position of the robot.

Returns:
yposition the desired position, given in [m]

Definition at line 86 of file RobotControl.cpp.

float getDistanceError (  )

Gets the distance to disired point.

Calculate with pythagoras.

Returns:
distance to goal, given in [m]

Definition at line 160 of file RobotControl.cpp.

float getPeriod (  ) [inherited]

Gets the period of this task.

Returns:
the period in seconds.

Definition at line 13 of file Task.cpp.

float getTheta (  )

Gets the desired of the goal point.

Returns:
the desired , given in [rad]

Definition at line 105 of file RobotControl.cpp.

float getThetaError (  )

Gets the orientation following error of the robot.

Returns:
the orientation following error, given in [rad]

Definition at line 155 of file RobotControl.cpp.

float getThetaErrorToGoal (  )

Gets the ot the pointing vector to the goal right the unicycle axis from actual point.

Returns:
theta to goal, given in [rad]

Definition at line 165 of file RobotControl.cpp.

float getThetaGoal (  )

Gets the ot the pointing vector to the goal right the unicycle main axis.

Returns:
theta from the goal, given in [rad]

Definition at line 170 of file RobotControl.cpp.

float getxActualPosition (  )

Gets the actual translational X-position of the robot.

Returns:
the actual position, given in [m]

Definition at line 130 of file RobotControl.cpp.

float getxPositionError (  )

Gets the X-position following error of the robot.

Returns:
the position following error, given in [m]

Definition at line 135 of file RobotControl.cpp.

float getyActualPosition (  )

Gets the actual translational Y-position of the robot.

Returns:
the actual position, given in [m]

Definition at line 140 of file RobotControl.cpp.

float getyPositionError (  )

Gets the Y-position following error of the robot.

Returns:
the position following error, given in [m]

Definition at line 145 of file RobotControl.cpp.

bool isEnabled ( void   )

Tests if the servo drives of the motors are enabled.

Returns:
true if the drives are enabled, false otherwise

Definition at line 51 of file RobotControl.cpp.

void run (  ) [virtual]

Run method actualize every period.

Reimplemented from Task.

Definition at line 187 of file RobotControl.cpp.

void setAllToZero ( float  xZeroPos,
float  yZeroPos,
float  theta 
)

Set all state to zero, except the X-position, y-position and .

Parameters:
xZeroPosSets the start X-position, given in [m]
yZeroPosSets the start y-position, given in [m]
thetaSets the start , given in [rad]

Definition at line 175 of file RobotControl.cpp.

void setDesiredOmega ( float  omega )

Sets the desired rotational speed of the robot.

Parameters:
omegathe desired rotational speed, given in [rad/s]

Definition at line 61 of file RobotControl.cpp.

void setDesiredPositionAndAngle ( float  xposition,
float  yposition,
float  theta 
)

Sets the desired Position and .

Parameters:
xpositionthe desired position, given in [m]
ypositionthe desired position, given in [m]
thetathe desired , given in [rad]

Definition at line 96 of file RobotControl.cpp.

void setDesiredSpeed ( float  speed )

Sets the desired translational speed of the robot.

Parameters:
speedthe desired speed, given in [m/s]

Definition at line 56 of file RobotControl.cpp.

void setDesiredTheta ( float  theta )

Sets the desired of the robot.

Parameters:
thetathe desired , given in [rad]

Definition at line 76 of file RobotControl.cpp.

void setDesiredxPosition ( float  xposition )

Sets the desired X-position of the robot.

Parameters:
xpositionthe desired position, given in [m]

Definition at line 66 of file RobotControl.cpp.

void setDesiredyPosition ( float  yposition )

Sets the desired Y-position of the robot.

Parameters:
ypositionthe desired position, given in [m]

Definition at line 71 of file RobotControl.cpp.

void setEnable ( bool  enable )

Enables or disables the servo drives of the motors.

Parameters:
enableif true enables the drives, false otherwise the servo drives are shut down.

Definition at line 45 of file RobotControl.cpp.

void start (  ) [inherited]

Starts this task.

Definition at line 18 of file Task.cpp.

void stop (  ) [inherited]

Stops this task.

Definition at line 23 of file Task.cpp.