Skip to content

Commit

Permalink
floating point for target speed; blocking options
Browse files Browse the repository at this point in the history
  • Loading branch information
gcl8a committed Jan 11, 2022
1 parent 11712df commit 29bfdf8
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 9 deletions.
6 changes: 3 additions & 3 deletions src/Chassis.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ void Chassis::setTwist(float forwardSpeed, float turningSpeed)
rightMotor.setTargetSpeed(ticksPerIntervalFwd + ticksPerIntervalTurn);
}

void Chassis::driveFor(float forwardDistance, float forwardSpeed)
void Chassis::driveFor(float forwardDistance, float forwardSpeed, bool block)
{
// ensure the speed and distance are in the same direction
forwardSpeed = forwardDistance > 0 ? fabs(forwardSpeed) : -fabs(forwardSpeed);
Expand All @@ -96,7 +96,7 @@ void Chassis::driveFor(float forwardDistance, float forwardSpeed)
}
}

void Chassis::turnFor(float turnAngle, float turningSpeed, bool block = false)
void Chassis::turnFor(float turnAngle, float turningSpeed, bool block)
{
// ensure angle and speed are in the same direction
turningSpeed = turnAngle > 0 ? fabs(turningSpeed) : -fabs(turningSpeed);
Expand Down Expand Up @@ -125,7 +125,7 @@ bool Chassis::checkMotionComplete(void)
* ISR for timing. On overflow of Timer4, the ISR takes a 'snapshot' of the encoder counts
* and then raises a flag to let the main program know it is time to execute the PID calculations.
*
* Do not edit this function -- adding length function calls will cause headaches.
* Do not edit this function -- adding lengthy function calls will cause headaches.
* */
ISR(TIMER4_OVF_vect)
{
Expand Down
2 changes: 1 addition & 1 deletion src/Chassis.h
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ class Chassis
bool checkMotionComplete(void);

void printSpeeds(void);
void Chassis::printEncoderCounts(void);
void printEncoderCounts(void);

inline void updateEncoderDeltas();
};
Expand Down
4 changes: 2 additions & 2 deletions src/Romi32U4Motors.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ void Romi32U4Motor::allowTurbo(bool turbo)
/**
* update() must be called regularly to update the control signals sent to the motors.
* */
void Romi32U4Motor::update(void)
void Romi32U4Motor::update(void)
{
if(ctrlMode == CTRL_SPEED || ctrlMode == CTRL_POS)
{
Expand All @@ -118,7 +118,7 @@ void Romi32U4Motor::update(void)
/**
* Sets the target speed in "encoder ticks/16 ms interval"
* */
void Romi32U4Motor::setTargetSpeed(int16_t target)
void Romi32U4Motor::setTargetSpeed(float target)
{
targetSpeed = target;

Expand Down
6 changes: 3 additions & 3 deletions src/Romi32U4Motors.h
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ class Romi32U4Motor
volatile int16_t speed = 0;

// used to set target speed or position (or both)
int16_t targetSpeed = 0;
float targetSpeed = 0;
int16_t targetPos = 0;

// Maximum effort (to protect the gear boxes). Can be changed by setting turbo mode
Expand Down Expand Up @@ -93,8 +93,8 @@ class Romi32U4Motor
int16_t getCount(void);
int16_t getAndResetCount(void);

void setTargetSpeed(int16_t targetSpeed);
void moveFor(int16_t amount);//, int16_t speed);
void setTargetSpeed(float targetSpeed);
void moveFor(int16_t amount);
bool checkComplete(void) {return ctrlMode == CTRL_DIRECT;}

void update(void);
Expand Down

0 comments on commit 29bfdf8

Please sign in to comment.