CMDoubleEngine Class Reference

Managing a double motor vehicle. More...

Collaboration diagram for CMDoubleEngine:
Collaboration graph
[legend]

Public Member Functions

 CMDoubleEngine (int acceleration, int min, int max)
 ~CMDoubleEngine ()
void go (int value)
void goForwardLeft (int diff)
void goForwardRight (int diff)
void goBackwardLeft (int diff)
void goBackwardRight (int diff)
void turnLeft (int diff)
void turnRight (int diff)
void stop ()
void update ()
int getLeftEngine ()
int getRightEngine ()

Private Attributes

CMSoftServo engine_left
CMSoftServo engine_right

Detailed Description

Header for easy managing the power of two engines.

Author:
Miguel Ángel Vílchez López 2010 <sacra@openmatica.es>

Codigo is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.

Codigo is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.

You should have received a copy of the GNU General Public License along with this program. If not, see <http://www.gnu.org/licenses/>.

Examples:

TestDoubleEngine.cpp.


Constructor & Destructor Documentation

CMDoubleEngine::CMDoubleEngine ( int  acceleration = 1,
int  min = -100,
int  max = 100 
)

Constructor.

Parameters:
[in] acceleration The acceleration.
[in] min The minimum power.
[in] max The maximum power.

00026                                                                          :engine_left(acceleration,min,max),engine_right(acceleration,min,max)
00027 {}

CMDoubleEngine::~CMDoubleEngine (  ) 

Destructor.

00030 {}


Member Function Documentation

int CMDoubleEngine::getLeftEngine (  ) 

Return the value of left engine.

Returns:
Returns 0 if succesfull, -1 if not.
Examples:
TestDoubleEngine.cpp.

00083 {
00084   return this->engine_left.getNow();
00085 }

int CMDoubleEngine::getRightEngine (  ) 

Return the value of right engine.

Returns:
Returns 0 if succesfull, -1 if not.
Examples:
TestDoubleEngine.cpp.

00088 {
00089   return this->engine_right.getNow();
00090 }

void CMDoubleEngine::go ( int  value  ) 

Forward or backward moviment.

Parameters:
[in] value The value of desired power.
Examples:
TestDoubleEngine.cpp.

00033 {
00034   this->engine_left.setEnd(value);
00035   this->engine_right.setEnd(value);
00036 }

void CMDoubleEngine::goBackwardLeft ( int  diff  ) 

Backward Left moviment, decreasing the power of left engine.

Parameters:
[in] diff The difference of power for turning.
Examples:
TestDoubleEngine.cpp.

00049 {
00050   this->engine_left.setEnd(this->engine_right.getNow()+diff);
00051 }

void CMDoubleEngine::goBackwardRight ( int  diff  ) 

Backward Right moviment, decreasing the power of right engine.

Parameters:
[in] diff The difference of power for turning.
Examples:
TestDoubleEngine.cpp.

00054 {
00055   this->engine_right.setEnd(this->engine_left.getNow()+diff);
00056 }

void CMDoubleEngine::goForwardLeft ( int  diff  ) 

Forward Left moviment, decreasing the power of left engine.

Parameters:
[in] diff The difference of power for turning.
Examples:
TestDoubleEngine.cpp.

00039 {
00040   this->engine_left.setEnd(this->engine_right.getNow()-diff);
00041 }

void CMDoubleEngine::goForwardRight ( int  diff  ) 

Forward Right moviment, decreasing the power of right engine.

Parameters:
[in] diff The difference of power for turning.
Examples:
TestDoubleEngine.cpp.

00044 {
00045   this->engine_right.setEnd(this->engine_left.getNow()-diff);
00046 }

void CMDoubleEngine::stop (  ) 

Motor emergency stop.

00071 {
00072   this->engine_left.stop();
00073   this->engine_right.stop();
00074 }

void CMDoubleEngine::turnLeft ( int  diff  ) 

Turn Left moviment.

Parameters:
[in] diff The value of desired power.
Examples:
TestDoubleEngine.cpp.

00059 {
00060   this->engine_left.setEnd((-1)*(int)(diff/2));
00061   this->engine_right.setEnd((int)(diff/2));
00062 }

void CMDoubleEngine::turnRight ( int  diff  ) 

Turn Right moviment.

Parameters:
[in] diff The value of desired power.
Examples:
TestDoubleEngine.cpp.

00065 {
00066   this->engine_left.setEnd((int)(diff/2));
00067   this->engine_right.setEnd((-1)*(int)(diff/2));
00068 }

void CMDoubleEngine::update (  ) 

Accelerate the motor from now to end.

Examples:
TestDoubleEngine.cpp.

00077 {
00078   this->engine_left.update();
00079   this->engine_right.update();
00080 }


Field Documentation

Engine Left.

Engine Right.

 All Data Structures Functions Variables
Generated on Mon Sep 12 07:59:09 2011 for API MokArdu by  doxygen 1.6.3