Skip to content

Commit

Permalink
Fix for linear actuator target position instruction
Browse files Browse the repository at this point in the history
  • Loading branch information
JVerbruggen committed Jun 23, 2024
1 parent ef8d072 commit ad70458
Showing 1 changed file with 14 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,19 @@ public void setUpperOperatingRange(double upper) {

@Override
public void goTowards(double targetPosition, double fromPosition, double acceleration, FlatRideComponentSpeed componentSpeed) {
componentSpeed.accelerate(acceleration);
boolean shouldAccelerate;
double currentPosition = getInstructionPosition();

// If from position is lower than target
if(fromPosition <= targetPosition){
// Then it should accelerate while the current position is lower than the target
shouldAccelerate = currentPosition < targetPosition;
}else{
// Otherwise do the reverse
shouldAccelerate = targetPosition < currentPosition;
}

if(shouldAccelerate)
componentSpeed.accelerate(acceleration);
}
}

0 comments on commit ad70458

Please sign in to comment.