Skip to content

Commit

Permalink
methods documentation
Browse files Browse the repository at this point in the history
  • Loading branch information
ediazidea committed Feb 15, 2021
1 parent c34c0b6 commit 69997f5
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 5 deletions.
37 changes: 37 additions & 0 deletions DifferentialSteering.cpp
Original file line number Diff line number Diff line change
@@ -1,14 +1,30 @@
#include "DifferentialSteering.h"

/**
* Constructor class.
*/
DifferentialSteering::DifferentialSteering() {
m_leftMotor = 0;
m_rightMotor = 0;
}

/**
* Initialize the threshold at which the pivot action starts.
*
* @param fPivYLimit: Threshold. Is measured in units on the Y-axis away from the X-axis (Y=0).
* A greater value will assign more of the joystick's range to pivot actions.
* Allowable range: (0..+127).
*/
void DifferentialSteering::begin(int fPivYLimit) {
m_fPivYLimit = fPivYLimit;
}

/**
* Compute differential steering from (x,y) values.
*
* @param XValue: X value in [-127, 127] range.
* @param YValue: Y value in [-127, 127] range.
*/
void DifferentialSteering::computeMotors(int XValue, int YValue) {
float nMotPremixL = 0; // Motor (left) premixed output (-127..+127)
float nMotPremixR = 0; // Motor (right) premixed output (-127..+127)
Expand Down Expand Up @@ -41,17 +57,38 @@ void DifferentialSteering::computeMotors(int XValue, int YValue) {
m_rightMotor = (1.0 - fPivScale) * nMotPremixR + fPivScale * (-nPivSpeed);
}

/*
* Returns the value of the left motor computed in computeMotors method.
*
* @return left computed motor, in [-127, 127] range.
*/
int DifferentialSteering::computedLeftMotor() {
return m_leftMotor;
}

/*
* Returns the value of the right motor computed in computeMotors method.
*
* @return right computed motor, in [-127, 127] range.
*/
int DifferentialSteering::computedRightMotor() {
return m_rightMotor;
}

/**
* Return the compute range used in the computeMotors method.
*
* @return the compute range.
*/
int DifferentialSteering::getComputeRange() {
return COMPUTERANGE;
}

/*
* Returns information about current computed motors and pivot threshold.
*
* @return a string with the information.
*/
String DifferentialSteering::toString() {
String str = "";
return (str + "Pivot threshold: " + m_fPivYLimit + " | Left Motor: " + m_leftMotor + " | Right Motor: " + m_rightMotor);
Expand Down
5 changes: 0 additions & 5 deletions DifferentialSteering.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,6 @@
class DifferentialSteering
{
private:
// - fPivYLimt : The threshold at which the pivot action starts
// This threshold is measured in units on the Y-axis
// away from the X-axis (Y=0). A greater value will assign
// more of the joystick's range to pivot actions.
// Allowable range: (0..+127)
int m_fPivYLimit;
int m_leftMotor;
int m_rightMotor;
Expand Down

0 comments on commit 69997f5

Please sign in to comment.