diff --git a/OpenRobertaServer/src/test/resources/crossCompilerTests/_expected/robotSpecific/targetLanguage/spike/actionDiffDrive.py b/OpenRobertaServer/src/test/resources/crossCompilerTests/_expected/robotSpecific/targetLanguage/spike/actionDiffDrive.py index 1baf3c74b4..a1a5274062 100644 --- a/OpenRobertaServer/src/test/resources/crossCompilerTests/_expected/robotSpecific/targetLanguage/spike/actionDiffDrive.py +++ b/OpenRobertaServer/src/test/resources/crossCompilerTests/_expected/robotSpecific/targetLanguage/spike/actionDiffDrive.py @@ -7,29 +7,29 @@ def run(): # drive - diff_drive.move(10, 'cm', 0, 30) - diff_drive.move(10, 'cm', 0, -(30)) - diff_drive.start(0, 30) + diff_drive.move(10, 'cm', 0, int(30)) + diff_drive.move(10, 'cm', 0, int(-(30))) + diff_drive.start(0, int(30)) wait_for_seconds(500/1000) - diff_drive.start_at_power(-(30), 0) + diff_drive.start_at_power(int(-(30)), 0) wait_for_seconds(500/1000) diff_drive.set_stop_action('brake') diff_drive.stop() # turn - diff_drive.move(20 * math.pi / 360 * TRACKWIDTH, 'cm', 100, 30) - diff_drive.move(20 * math.pi / 360 * TRACKWIDTH, 'cm', -100, 30) - diff_drive.start(100, 30) + diff_drive.move(20 * math.pi / 360 * TRACKWIDTH, 'cm', 100, int(30)) + diff_drive.move(20 * math.pi / 360 * TRACKWIDTH, 'cm', -100, int(30)) + diff_drive.start(100, int(30)) wait_for_seconds(500/1000) - diff_drive.start_at_power(30, -100) + diff_drive.start_at_power(int(30), -100) wait_for_seconds(500/1000) diff_drive.set_stop_action('coast') diff_drive.stop() # steer - diff_drive.move_tank(20, 'cm', 10, 30) - diff_drive.move_tank(-(20), 'cm', 10, 30) - diff_drive.start_tank(10, 30) + diff_drive.move_tank(20, 'cm', int(10), int(30)) + diff_drive.move_tank(-(20), 'cm', int(10), int(30)) + diff_drive.start_tank(int(10), int(30)) wait_for_seconds(500/1000) - diff_drive.start_tank_at_power(-(10), -(30)) + diff_drive.start_tank_at_power(int(-(10)), int(-(30))) wait_for_seconds(500/1000) diff_drive.set_stop_action('coast') diff_drive.stop() diff --git a/OpenRobertaServer/src/test/resources/crossCompilerTests/_expected/robotSpecific/targetLanguage/spike/actionMotor.py b/OpenRobertaServer/src/test/resources/crossCompilerTests/_expected/robotSpecific/targetLanguage/spike/actionMotor.py index f95404477a..0171688a02 100644 --- a/OpenRobertaServer/src/test/resources/crossCompilerTests/_expected/robotSpecific/targetLanguage/spike/actionMotor.py +++ b/OpenRobertaServer/src/test/resources/crossCompilerTests/_expected/robotSpecific/targetLanguage/spike/actionMotor.py @@ -6,13 +6,13 @@ def run(): # motor - motorB.run_for_rotations(1, 30) - motorA.run_for_degrees(360, 30) - motorB.start(30) + motorB.run_for_rotations(1, int(30)) + motorA.run_for_degrees(360, int(30)) + motorB.start(int(30)) wait_for_seconds(500/1000) motorB.set_stop_action('coast') motorB.stop() - motorA.start_at_power(-30) + motorA.start_at_power(int(-30)) wait_for_seconds(500/1000) motorA.set_stop_action('brake') motorA.stop() diff --git a/RobotSpike/src/main/java/de/fhg/iais/roberta/visitor/SpikePythonVisitor.java b/RobotSpike/src/main/java/de/fhg/iais/roberta/visitor/SpikePythonVisitor.java index 495a83256e..d13a4885a7 100644 --- a/RobotSpike/src/main/java/de/fhg/iais/roberta/visitor/SpikePythonVisitor.java +++ b/RobotSpike/src/main/java/de/fhg/iais/roberta/visitor/SpikePythonVisitor.java @@ -105,7 +105,7 @@ public Void visitMainTask(MainTask mainTask) { public Void visitMotorDiffOnForAction(MotorDiffOnForAction motorDiffOnForAction) { src.add("diff_drive.move("); motorDiffOnForAction.distance.accept(this); - src.add(", 'cm', 0, "); + src.add(", 'cm', 0, int("); switch ( motorDiffOnForAction.direction ) { case "BACKWARD": src.add("-("); @@ -118,7 +118,7 @@ public Void visitMotorDiffOnForAction(MotorDiffOnForAction motorDiffOnForAction) default: throw new DbcException("Invalid drive direction: " + motorDiffOnForAction.direction); } - src.add(")"); + src.add("))"); return null; } @@ -137,8 +137,9 @@ public Void visitMotorDiffTurnForAction(MotorDiffTurnForAction motorDiffTurnForA default: throw new DbcException("Invalid turn direction: " + motorDiffTurnForAction.direction); } + src.add("int("); motorDiffTurnForAction.power.accept(this); - src.add(")"); + src.add("))"); return null; } @@ -152,6 +153,7 @@ public Void visitMotorDiffOnAction(MotorDiffOnAction motorDiffOnAction) { src.add("diff_drive.start_at_power("); end = ", 0)"; } + src.add("int("); switch ( motorDiffOnAction.direction ) { case "BACKWARD": src.add("-("); @@ -164,7 +166,7 @@ public Void visitMotorDiffOnAction(MotorDiffOnAction motorDiffOnAction) { default: throw new DbcException("Invalid drive direction: " + motorDiffOnAction.direction); } - src.add(end); + src.add(")", end); return null; } @@ -189,8 +191,9 @@ public Void visitMotorDiffTurnAction(MotorDiffTurnAction motorDiffTurnAction) { src.add("diff_drive.start_at_power("); end = ", " + String.valueOf(turn) + ")"; } + src.add("int("); motorDiffTurnAction.power.accept(this); - src.add(end); + src.add(")", end); return null; } @@ -209,11 +212,11 @@ public Void visitMotorDiffCurveForAction(MotorDiffCurveForAction motorDiffCurveF default: throw new DbcException("Invalid curve direction: " + motorDiffCurveForAction.direction); } - src.add(", 'cm', "); + src.add(", 'cm', int("); motorDiffCurveForAction.powerLeft.accept(this); - src.add(", "); + src.add("), int("); motorDiffCurveForAction.powerRight.accept(this); - src.add(")"); + src.add("))"); return null; } @@ -350,21 +353,22 @@ public Void visitMotorDiffCurveAction(MotorDiffCurveAction motorDiffCurveAction) } switch ( motorDiffCurveAction.direction ) { case "BACKWARD": - src.add("-("); + src.add("int(-("); motorDiffCurveAction.powerLeft.accept(this); - src.add("), -("); + src.add(")), int(-("); motorDiffCurveAction.powerRight.accept(this); src.add(")"); break; case "FORWARD": + src.add("int("); motorDiffCurveAction.powerLeft.accept(this); - src.add(", "); + src.add("), int("); motorDiffCurveAction.powerRight.accept(this); break; default: throw new DbcException("Invalid curve direction: " + motorDiffCurveAction.direction); } - src.add(")"); + src.add("))"); return null; } @@ -403,9 +407,9 @@ public Void visitMotorOnForAction(MotorOnForAction motorOnForAction) { } motorOnForAction.value.accept(this); - this.src.add(", "); + this.src.add(", int("); motorOnForAction.power.accept(this); - this.src.add(")"); + this.src.add("))"); return null; } @@ -417,8 +421,9 @@ public Void visitMotorOnAction(MotorOnAction motorOnAction) { } else { src.add(".start_at_power("); } + src.add("int("); motorOnAction.power.accept(this); - src.add(")"); + src.add("))"); return null; }