Skip to content

Commit

Permalink
fixes #35
Browse files Browse the repository at this point in the history
  • Loading branch information
WolfgangFahl committed Jul 8, 2019
1 parent 11aa971 commit 7e9685f
Show file tree
Hide file tree
Showing 5 changed files with 212 additions and 205 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@
import javafx.scene.Scene;
import javafx.scene.layout.BorderPane;
import javafx.stage.Stage;
import nl.vaneijndhoven.dukes.common.Config;
import nl.vaneijndhoven.dukes.common.Environment;

/**
* JavaFx Lane Detection App
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import io.vertx.core.logging.Logger;
import io.vertx.core.logging.LoggerFactory;
import nl.vaneijndhoven.dukes.car.SteeringMap;
import nl.vaneijndhoven.dukes.common.Config;
import nl.vaneijndhoven.dukes.drivecontrol.Car;

/**
Expand Down Expand Up @@ -83,17 +84,17 @@ void handleServo(JsonObject messageBody) {

SteeringMap steeringMap = car.getSteering().getSteeringMap();

if ("left".equals(position)) {
if (Config.POSITION_LEFT.equals(position)) {
currentWheelPosition = currentWheelPosition - steeringMap.stepSize();
if (currentWheelPosition < steeringMap.maxLeft()) {
currentWheelPosition = steeringMap.maxLeft();
}
} else if ("right".equals(position)) {
} else if (Config.POSITION_RIGHT.equals(position)) {
currentWheelPosition = currentWheelPosition + steeringMap.stepSize();
if (currentWheelPosition > steeringMap.maxRight()) {
currentWheelPosition = steeringMap.maxRight();
}
} else if ("center".equals(position)) {
} else if (Config.POSITION_CENTER.equals(position)) {
currentWheelPosition = steeringMap.center();
}
turnWrapper(currentWheelPosition);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -159,13 +159,13 @@ public void testSteeringHandler() throws Exception {
SteeringHandler sh=new SteeringHandler(car);
Steering steering = car.getSteering();
JsonObject msg=new JsonObject();
msg.put("position","center");
msg.put("position",Config.POSITION_CENTER);
sh.handleServo(msg);
assertEquals(130,steering.getServo());
msg.put("position","left");
msg.put("position",Config.POSITION_RIGHT);
sh.handleServo(msg);
assertEquals(135,steering.getServo());
msg.put("position","left");
msg.put("position",Config.POSITION_LEFT);
sh.handleServo(msg);
assertEquals(140,steering.getServo());
if (debug)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,10 @@ public class Config {
public static final String ENGINE_MAX_SPEED_REVERSE = "engine.max.speed.reverse";
public static final String ENGINE_MIN_SPEED_FORWARD = "engine.min.speed.forward";
public static final String ENGINE_MAX_SPEED_FORWARD = "engine.max.speed.forward";
// Commands
public static final String POSITION_LEFT = "left";
public static final String POSITION_RIGHT = "right";
public static final String POSITION_CENTER = "center";

/**
* configure the logging
Expand Down
Loading

0 comments on commit 7e9685f

Please sign in to comment.