Skip to content

Commit

Permalink
Fixed review findings
Browse files Browse the repository at this point in the history
  • Loading branch information
gabryelreyes committed Oct 18, 2024
1 parent 36628c5 commit 363148b
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 12 deletions.
1 change: 0 additions & 1 deletion doc/architecture/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,6 @@ Linear speed right\
$v_R [\frac{steps}{s}] = \frac{w_r [\frac{rad}{s}] \cdot W [mm]}{2} \cdot \frac{ENC [\frac{steps}{m}]}{1000}$

Consider robot linear speed center\

Linear speed left\
$v_L [\frac{steps}{s}] = \frac{v_{Linear}}{2} [\frac{steps}{s}] -\frac{w_r [\frac{rad}{s}] \cdot W [mm]}{2} \cdot \frac{ENC [\frac{steps}{m}]}{1000}$

Expand Down
15 changes: 8 additions & 7 deletions lib/Service/src/DifferentialDrive.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -245,13 +245,14 @@ DifferentialDrive::DifferentialDrive() :
void DifferentialDrive::calculateLinearSpeedLeftRight(int16_t linearSpeedCenter, int16_t angularSpeed,
int16_t& linearSpeedLeft, int16_t& linearSpeedRight)
{
int32_t linearSpeedCenter32 = static_cast<int32_t>(linearSpeedCenter); /* [steps/s] */
int32_t halfLinearSpeedCenter32 = linearSpeedCenter32 / 2; /* [steps/s] */
int32_t angularSpeed32 = static_cast<int32_t>(angularSpeed); /* [mrad/s] */
int32_t wheelBase32 = static_cast<int32_t>(RobotConstants::WHEEL_BASE); /* [mm] */
int32_t encoderStepsPerM32 = static_cast<int32_t>(RobotConstants::ENCODER_STEPS_PER_M); /* [steps/m] */
int32_t linearSpeedTurnInPlace32 =
(angularSpeed32 * wheelBase32 * encoderStepsPerM32) / static_cast<int32_t>(2000000); /* [steps/s] */
static const int32_t ANGULAR_TO_LINEAR_SPEED_FACTOR = 2000000; /* 2 * 1000 mrad */
int32_t linearSpeedCenter32 = static_cast<int32_t>(linearSpeedCenter); /* [steps/s] */
int32_t halfLinearSpeedCenter32 = linearSpeedCenter32 / 2; /* [steps/s] */
int32_t angularSpeed32 = static_cast<int32_t>(angularSpeed); /* [mrad/s] */
int32_t wheelBase32 = static_cast<int32_t>(RobotConstants::WHEEL_BASE); /* [mm] */
int32_t encoderStepsPerM32 = static_cast<int32_t>(RobotConstants::ENCODER_STEPS_PER_M); /* [steps/m] */
int32_t linearSpeedTurnInPlace32 = (angularSpeed32 * wheelBase32 * encoderStepsPerM32) /
static_cast<int32_t>(ANGULAR_TO_LINEAR_SPEED_FACTOR); /* [steps/s] */

linearSpeedLeft = halfLinearSpeedCenter32 - linearSpeedTurnInPlace32; /* [steps/s] */
linearSpeedRight = halfLinearSpeedCenter32 + linearSpeedTurnInPlace32; /* [steps/s] */
Expand Down
8 changes: 4 additions & 4 deletions lib/Service/src/Util.h
Original file line number Diff line number Diff line change
Expand Up @@ -118,9 +118,9 @@ namespace Util
/**
* Convert a speed in encoder steps per second to a speed in mm/s.
*
* @param[in] speedStepsPerSec Speed in encoder steps per second
* @param[in] speedStepsPerSec Speed in encoder steps per second.
*
* @return Speed in mm/s
* @return Speed in mm/s.
*/
inline int32_t stepsPerSecondToMillimetersPerSecond(int16_t speedStepsPerSec)
{
Expand All @@ -131,9 +131,9 @@ namespace Util
/**
* Convert a speed in mm/s to a speed in encoder steps per second.
*
* @param[in] speedMmPerSec Speed in mm/s
* @param[in] speedMmPerSec Speed in mm/s.
*
* @return Speed in encoder steps per second
* @return Speed in encoder steps per second.
*/
inline int16_t millimetersPerSecondToStepsPerSecond(int32_t speedMmPerSec)
{
Expand Down

0 comments on commit 363148b

Please sign in to comment.