Skip to content
This repository has been archived by the owner on Sep 6, 2024. It is now read-only.

Commit

Permalink
fix servo positioning bug
Browse files Browse the repository at this point in the history
Former-commit-id: 64a639bb37825090a8e2592781ef186bd35336a1
Former-commit-id: 7ddb20e
  • Loading branch information
rgatkinson committed Nov 29, 2015
1 parent 5805a45 commit 18868af
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
import com.qualcomm.robotcore.eventloop.opmode.OpMode;
import com.qualcomm.robotcore.hardware.*;
import com.qualcomm.robotcore.util.Range;
import com.qualcomm.robotcore.util.TypeConversion;
import org.swerverobotics.library.BuildConfig;
import org.swerverobotics.library.SynchronousOpMode;
import org.swerverobotics.library.interfaces.*;
Expand Down Expand Up @@ -270,7 +269,7 @@ public synchronized void setServoPosition(int servo, double position)
{
validateServo(servo);
position = Range.clip(position, positionMin, positionMax); // note: runtime formerly threw on range error
double bPosition = Range.scale(position, positionMin, positionMax, bPositionMin, bPositionMax);
double bPosition = Range.scale(position, positionMin, positionMax, regPositionMin, regPositionMax);
this.write(ADDRESS_CHANNEL_MAP[servo], bPosition);
this.pwmEnable();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,8 @@ public class EasyModernServoController extends EasyModernController implements S

public static final double positionMin = 0.0;
public static final double positionMax = 1.0;
public static final byte bPositionMin = 0;
public static final byte bPositionMax = (byte)255;
public static final double regPositionMin = 0;
public static final double regPositionMax = 255;

private List<Servo> servos;
private final double[] servoPositions;
Expand Down Expand Up @@ -233,7 +233,7 @@ public void setServoPosition(int servo, double position)
{
validateServo(servo);
position = Range.clip(position, positionMin, positionMax); // note: runtime formerly threw on range error
double bPosition = Range.scale(position, positionMin, positionMax, bPositionMin, bPositionMax);
double bPosition = Range.scale(position, positionMin, positionMax, regPositionMin, regPositionMax);
this.write(ADDRESS_CHANNEL_MAP[servo], bPosition);
this.pwmEnable();

Expand Down

0 comments on commit 18868af

Please sign in to comment.