Skip to content

Commit

Permalink
Issue #1656: Introduce Fischertechnik TxT 4.0 Controller Plugin
Browse files Browse the repository at this point in the history
  • Loading branch information
heini208 authored and bjost2s committed May 6, 2024
1 parent 93da2f1 commit 468e9e5
Show file tree
Hide file tree
Showing 277 changed files with 21,474 additions and 3,647 deletions.
3 changes: 2 additions & 1 deletion OpenRobertaRobot/constantsSource.txt
Original file line number Diff line number Diff line change
Expand Up @@ -359,4 +359,5 @@ WHERE2 = "where2"
WHILE = "WHILE"
WRITE_PIN_ACTION = "writePinAction"
X = "x"
Y = "y"
Y = "y"
COLOUR_COMPARE = "compareColour"
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
package de.fhg.iais.roberta.syntax.action.spike;
package de.fhg.iais.roberta.syntax.action;

import de.fhg.iais.roberta.syntax.action.Action;
import de.fhg.iais.roberta.transformer.forField.NepoField;
import de.fhg.iais.roberta.util.ast.BlocklyProperties;
import de.fhg.iais.roberta.util.syntax.BlocklyConstants;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package de.fhg.iais.roberta.syntax.action.spike;
package de.fhg.iais.roberta.syntax.action;

import de.fhg.iais.roberta.blockly.generated.Hide;
import de.fhg.iais.roberta.syntax.action.Action;
import de.fhg.iais.roberta.transformer.forField.NepoHide;
import de.fhg.iais.roberta.util.ast.BlocklyProperties;
import de.fhg.iais.roberta.util.syntax.WithUserDefinedPort;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package de.fhg.iais.roberta.syntax.action.mbot2;
package de.fhg.iais.roberta.syntax.action.light;

import de.fhg.iais.roberta.blockly.generated.Hide;
import de.fhg.iais.roberta.syntax.action.Action;
Expand All @@ -8,12 +8,12 @@
import de.fhg.iais.roberta.transformer.forField.NepoHide;
import de.fhg.iais.roberta.transformer.forField.NepoValue;
import de.fhg.iais.roberta.typecheck.BlocklyType;
import de.fhg.iais.roberta.util.dbc.Assert;
import de.fhg.iais.roberta.util.ast.BlocklyProperties;
import de.fhg.iais.roberta.util.dbc.Assert;
import de.fhg.iais.roberta.util.syntax.BlocklyConstants;
import de.fhg.iais.roberta.util.syntax.WithUserDefinedPort;

@NepoPhrase(category = "ACTOR", blocklyNames = {"robActions_led_setBrightness"}, name = "CYBERPI_SET_BRIGHTNESS_ACTION")
@NepoPhrase(category = "ACTOR", blocklyNames = {"robActions_led_setBrightness", "actions_led_set_brightness"}, name = "SET_BRIGHTNESS_ACTION")
public final class LedBrightnessAction extends Action implements WithUserDefinedPort {
@NepoValue(name = BlocklyConstants.BRIGHTNESS, type = BlocklyType.NUMBER_INT)
public final Expr brightness;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
import de.fhg.iais.roberta.transformer.forField.NepoHide;
import de.fhg.iais.roberta.util.ast.BlocklyProperties;

@NepoPhrase(name = "RGBLED_OFF_HIDDEN_ACTION", category = "ACTOR", blocklyNames = {"actions_rgbLed_hidden_off", "actions_rgbLed_hidden_off_calliope"})
@NepoPhrase(name = "RGBLED_OFF_HIDDEN_ACTION", category = "ACTOR", blocklyNames = {"actions_rgbLed_hidden_off", "actions_rgbLed_hidden_off_calliope", "actions_display_rgbLed_hidden_off_txt4"})
public final class RgbLedOffHiddenAction extends Action {
@NepoHide
public final Hide hide;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
import de.fhg.iais.roberta.typecheck.BlocklyType;
import de.fhg.iais.roberta.util.ast.BlocklyProperties;

@NepoPhrase(name = "RGBLED_ON_HIDDEN_ACTION", category = "ACTOR", blocklyNames = {"actions_rgbLed_hidden_on", "actions_rgbLed_hidden_on_calliope"})
@NepoPhrase(name = "RGBLED_ON_HIDDEN_ACTION", category = "ACTOR", blocklyNames = {"actions_rgbLed_hidden_on", "actions_rgbLed_hidden_on_calliope", "actions_display_rgbled_hidden_on_txt4"})
public final class RgbLedOnHiddenAction extends Action {
@NepoValue(name = "COLOUR", type = BlocklyType.COLOR)
public final Expr colour;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package de.fhg.iais.roberta.syntax.action.spike;
package de.fhg.iais.roberta.syntax.action.motor;

import de.fhg.iais.roberta.syntax.action.ActionWithUserChosenName;
import de.fhg.iais.roberta.syntax.lang.expr.Expr;
import de.fhg.iais.roberta.transformer.forClass.NepoPhrase;
import de.fhg.iais.roberta.transformer.forField.NepoField;
Expand All @@ -8,7 +9,7 @@
import de.fhg.iais.roberta.util.ast.BlocklyProperties;
import de.fhg.iais.roberta.util.syntax.BlocklyConstants;

@NepoPhrase(category = "ACTOR", blocklyNames = {"actions_motor_on_for"}, name = "MOTOR_ON_FOR_ACTION")
@NepoPhrase(category = "ACTOR", blocklyNames = {"actions_motor_on_for", "actions_motor_on_for_txt4"}, name = "MOTOR_ON_FOR_ACTION")
public final class MotorOnForAction extends ActionWithUserChosenName {
@NepoValue(name = BlocklyConstants.POWER, type = BlocklyType.NUMBER)
public final Expr power;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
import de.fhg.iais.roberta.util.dbc.Assert;
import de.fhg.iais.roberta.util.syntax.BlocklyConstants;

@NepoPhrase(category = "ACTOR", blocklyNames = {"robActions_play_file", "actions_play_file", "actions_play_file_port", "actions_play_expression"}, name = "PLAY_FILE_ACTION")
@NepoPhrase(category = "ACTOR", blocklyNames = {"robActions_play_file", "actions_play_file", "actions_play_file_port", "actions_play_expression", "actions_play_file_txt4"}, name = "PLAY_FILE_ACTION")
public final class PlayFileAction extends Action {

@NepoField(name = "ACTORPORT", value = BlocklyConstants.EMPTY_PORT)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
import de.fhg.iais.roberta.util.ast.ExternalSensorBean;

@NepoExpr(name = "COLOR_SENSING", category = "SENSOR", blocklyNames = {"robsensors_colourtcs3472_getsample", "sim_colour_getSample", "robSensors_colour_getSample"},
sampleValues = {@F2M(field = "COLOUR_COLOUR", mode = "COLOUR"), @F2M(field = "COLOUR_AMBIENTLIGHT", mode = "AMBIENTLIGHT"), @F2M(field = "COLOUR_LIGHT", mode = "LIGHT"), @F2M(field = "COLOUR_REDCHANNEL", mode = "REDCHANNEL"), @F2M(field = "COLOUR_GREENCHANNEL", mode = "GREENCHANNEL"), @F2M(field = "COLOUR_BLUECHANNEL", mode = "BLUECHANNEL")})
sampleValues = {@F2M(field = "COLOUR_COLOUR", mode = "COLOUR"), @F2M(field = "COLOUR_AMBIENTLIGHT", mode = "AMBIENTLIGHT"), @F2M(field = "COLOUR_LIGHT", mode = "LIGHT"), @F2M(field = "COLOUR_REDCHANNEL", mode = "REDCHANNEL"), @F2M(field = "COLOUR_GREENCHANNEL", mode = "GREENCHANNEL"), @F2M(field = "COLOUR_BLUECHANNEL", mode = "BLUECHANNEL"), @F2M(field = "CAMERA_COLOUR", mode = "COLOUR")})
public final class ColorSensor extends ExternalSensor {

public ColorSensor(BlocklyProperties properties, ExternalSensorBean externalSensorBean) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
import de.fhg.iais.roberta.transformer.forField.NepoField;
import de.fhg.iais.roberta.util.ast.BlocklyProperties;

@NepoPhrase(name = "ENCODER_RESET", category = "SENSOR", blocklyNames = {"robSensors_encoder_reset"})
@NepoPhrase(name = "ENCODER_RESET", category = "SENSOR", blocklyNames = {"robSensors_encoder_reset", "robSensors_encoder_reset_txt4"})
public final class EncoderReset extends Sensor {

@NepoField(name = "SENSORPORT")
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package de.fhg.iais.roberta.syntax.sensors.arduino.sensebox;
package de.fhg.iais.roberta.syntax.sensor.generic;

import de.fhg.iais.roberta.syntax.sensor.ExternalSensor;
import de.fhg.iais.roberta.transformer.forClass.F2M;
Expand All @@ -10,7 +10,8 @@
sampleValues = {@F2M(field = "ENVIRONMENTAL_TEMPERATURE", mode = "TEMPERATURE"), @F2M(field = "ENVIRONMENTAL_VOCEQUIVALENT", mode = "VOCEQUIVALENT"),
@F2M(field = "ENVIRONMENTAL_CALIBRATION", mode = "CALIBRATION"), @F2M(field = "ENVIRONMENTAL_IAQ", mode = "IAQ"),
@F2M(field = "ENVIRONMENTAL_PRESSURE", mode = "PRESSURE"), @F2M(field = "ENVIRONMENTAL_HUMIDITY", mode = "HUMIDITY"),
@F2M(field = "ENVIRONMENTAL_CO2EQUIVALENT", mode = "CO2EQUIVALENT")})
@F2M(field = "ENVIRONMENTAL_CO2EQUIVALENT", mode = "CO2EQUIVALENT"), @F2M(field = "ENVIRONMENTAL_ACCURACY", mode = "ACCURACY"),
@F2M(field = "ENVIRONMENTAL_CALIBRATIONNEED", mode = "CALIBRATIONNEED")})
public final class EnvironmentalSensor extends ExternalSensor {

public EnvironmentalSensor(BlocklyProperties properties, ExternalSensorBean externalSensorBean) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,13 @@
import de.fhg.iais.roberta.util.ast.BlocklyProperties;
import de.fhg.iais.roberta.util.ast.ExternalSensorBean;

@NepoExpr(name = "GESTURE_SENSING", category = "SENSOR", blocklyNames = {"robSensors_gesture_getSample"}, sampleValues = {@F2M(field = "GESTURE_UP", mode = "UP"),
@F2M(field = "GESTURE_DOWN", mode = "DOWN"), @F2M(field = "GESTURE_FACE_DOWN", mode = "FACE_DOWN"), @F2M(field = "GESTURE_FREEFALL", mode = "FREEFALL"),
@F2M(field = "GESTURE_ACTIVE", mode = "GESTURE_ACTIVE"), @F2M(field = "GESTURE_SHAKE", mode = "SHAKE"), @F2M(field = "GESTURE_FACE_UP", mode = "FACE_UP"),
@F2M(field = "GESTURE_TAPPED", mode = "TAPPED"), @F2M(field = "GESTURE_RIGHT", mode = "RIGHT"),
@F2M(field = "GESTURE_LEFT", mode = "LEFT"), @F2M(field = "GESTURE_FRONT", mode = "FRONT"), @F2M(field = "GESTURE_BACK", mode = "BACK")})
@NepoExpr(name = "GESTURE_SENSING", category = "SENSOR", blocklyNames = {"robSensors_gesture_getSample"},
sampleValues = {@F2M(field = "GESTURE_UP", mode = "UP"), @F2M(field = "GESTURE_DOWN", mode = "DOWN"), @F2M(field = "GESTURE_FACE_DOWN", mode = "FACE_DOWN"),
@F2M(field = "GESTURE_FREEFALL", mode = "FREEFALL"), @F2M(field = "GESTURE_ACTIVE", mode = "GESTURE_ACTIVE"), @F2M(field = "GESTURE_SHAKE", mode = "SHAKE"),
@F2M(field = "GESTURE_FACE_UP", mode = "FACE_UP"), @F2M(field = "GESTURE_TAPPED", mode = "TAPPED"), @F2M(field = "GESTURE_RIGHT", mode = "RIGHT"),
@F2M(field = "GESTURE_LEFT", mode = "LEFT"), @F2M(field = "GESTURE_FRONT", mode = "FRONT"), @F2M(field = "GESTURE_BACK", mode = "BACK"),
@F2M(field = "GESTURE_COLOUR", mode = "COLOUR"), @F2M(field = "GESTURE_AMBIENTLIGHT", mode = "AMBIENTLIGHT"),
@F2M(field = "GESTURE_GESTURE", mode = "GESTURE"), @F2M(field = "GESTURE_PROXIMITY", mode = "PROXIMITY")})
public final class GestureSensor extends ExternalSensor {

public GestureSensor(BlocklyProperties properties, ExternalSensorBean externalSensorBean) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

@NepoExpr(name = "GYRO_SENSING", category = "SENSOR", blocklyNames = {"robSensors_gyro_getSample"},
sampleValues = {@F2M(field = "GYRO_TILTED", mode = "TILTED"), @F2M(field = "GYRO_Y", mode = "Y"), @F2M(field = "GYRO_RATE", mode = "RATE"),
@F2M(field = "GYRO_Z", mode = "Z"), @F2M(field = "GYRO_X", mode = "X"), @F2M(field = "GYRO_ANGLE", mode = "ANGLE")})
@F2M(field = "GYRO_Z", mode = "Z"), @F2M(field = "GYRO_X", mode = "X"), @F2M(field = "GYRO_ANGLE", mode = "ANGLE"), @F2M(field = "IMU_GYRO", mode = "GYRO"), @F2M(field = "IMU_MAGNETICFLUX", mode = "MAGNETICFLUX"), @F2M(field = "IMU_ACCELERATION", mode = "ACCELERATION")})
public final class GyroSensor extends ExternalSensor {

public GyroSensor(BlocklyProperties properties, ExternalSensorBean externalSensorBean) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
import de.fhg.iais.roberta.util.ast.ExternalSensorBean;

@NepoExpr(name = "MOTION_SENSING", category = "SENSOR", blocklyNames = {"robSensors_motion_getSample"},
sampleValues = {@F2M(field = "MOTION_PRESENCE", mode = "PRESENCE")})
sampleValues = {@F2M(field = "MOTION_PRESENCE", mode = "PRESENCE"), @F2M(field = "CAMERA_MOTION", mode = "MOTION")})
public final class MotionSensor extends ExternalSensor {

public MotionSensor(BlocklyProperties properties, ExternalSensorBean externalSensorBean) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -178,6 +178,11 @@ private static ConfigurationComponent instance2NewConfigComp(Instance instance,
for ( int i = 1; i < firstBlock.getField().size(); i++ ) {
map.put(firstBlock.getField().get(i).getName(), firstBlock.getField().get(i).getValue());
}
for ( Value value : firstBlock.getValue() ) {
String name = value.getName();
String val = value.getBlock().getField().get(0).getValue().toString();
map.put(name, val);
}
// TODO in order to avoid robot specific workarounds in the Robot project:
// TODO this is workaround for the robot specific "robBrick_*-Brick" blocks, which have varying names for the "userDefinedPortName" from robot to robot
// TODO this this should be removed if possible
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ public class Util {
private static final Pattern PORT_NAME_PATTERN = Pattern.compile("^\\w+$");
private static final Pattern IFDEF_PATTERN = Pattern.compile("^\\s*#ifdef (.*)$");
private static final Pattern END_PATTERN = Pattern.compile("^\\s*#end$");
private static final Pattern HEX_VALUE_PATTERN = Pattern.compile("^#[0-9a-fA-F]+$");
private static final String INVALID = "invalid";
/**
* YAML parser. NOT thread-safe!
Expand Down Expand Up @@ -684,7 +685,7 @@ public static void sanitizeConfigurationProperties(Map<String, String> component
for ( Map.Entry<String, String> pair : componentProperties.entrySet() ) {
String key = pair.getKey();
String value = pair.getValue();
boolean isValid = key.equals("NAO_FILENAME") ? FILENAME_PATTERN.matcher(value).matches() : CONFIG_NAME_PATTERN.matcher(value).matches() || NUMBER_PATTERN.matcher(value).matches();
boolean isValid = key.equals("NAO_FILENAME") ? FILENAME_PATTERN.matcher(value).matches() : CONFIG_NAME_PATTERN.matcher(value).matches() || NUMBER_PATTERN.matcher(value).matches() || HEX_VALUE_PATTERN.matcher(value).matches();
if ( !isValid ) {
try {
pair.setValue(INVALID);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,13 +53,13 @@ public class AstFactory {
* the list of all legal modes used in the blockly frontend
*/
private static final String[] allLegalModesArray = {
"ALTITUDE", "AMBIENTLIGHT", "ANALOG", "ANGLE", "BACKWARD", "CALIBRATE", "CALIBRATION", "CLOSING", "CO2EQUIVALENT", "COLOUR", "COMPASS",
"ALTITUDE", "AMBIENTLIGHT", "ANALOG", "ANGLE", "BACKWARD", "BALL", "CALIBRATE", "CALIBRATION", "CLOSING", "CO2EQUIVALENT", "COLOUR", "COMPASS",
"DATE", "DEFAULT", "DEGREE", "DIGITAL", "DISTANCE", "DOWN", "EDISON_CODE", "FACE_DOWN", "FACE_UP", "FOREWARD", "FREEFALL",
"G3", "G6", "G8", "HUMIDITY", "IAQ", "IDALL", "IDONE", "LATITUDE", "LEFT", "LIGHT", "LIGHT_VALUE", "LINE", "LONGITUDE", "MODULATED",
"NAMEALL", "NAMEONE", "NONE", "OBSTACLE", "OFF", "OPENING", "PM10", "PM25", "PRESENCE", "PRESSED", "PRESSURE", "PULSEHIGH", "PULSELOW", "RATE",
"G3", "G6", "G8", "HUMIDITY", "IAQ", "IDALL", "IDONE", "LATITUDE", "LEFT", "LIGHT", "LIGHT_VALUE", "LINE", "LONGITUDE", "MODULATED", "MOTION",
"NAMEALL", "NAMEONE", "NONE", "OBSTACLE", "OFF", "OPENING", "NUMBERLINES", "PM10", "PM25", "PRESENCE", "PRESSED", "PRESSURE", "PULSEHIGH", "PULSELOW", "RATE",
"RCCODE", "RED", "REFLEXION", "RESET", "RGB", "RIGHT", "ROTATION", "SEEK", "SERIAL", "SHAKE", "SOUND", "SPEED", "START", "STOP", "STRENGTH", "TEMPERATURE",
"TILTED", "TIME", "UNMODULATED", "UP", "UVLIGHT", "VALUE", "VOCEQUIVALENT", "WAIT_FOR_PRESS", "WAIT_FOR_PRESS_AND_RELEASE", "X", "Y", "Z", "REDCHANNEL",
"GREENCHANNEL", "BLUECHANNEL", "FRONT", "BACK", "LEFT", "RIGHT", "TAPPED", "FORCE"
"GREENCHANNEL", "BLUECHANNEL", "FRONT", "BACK", "LEFT", "RIGHT", "TAPPED", "FORCE", "GYRO", "ACCELERATION", "MAGNETICFLUX", "PROXIMITY", "GESTURE", "CALIBRATIONNEED", "ACCURACY"
};
/**
* the hash set of all legal modes used in the blockly frontend
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -363,4 +363,5 @@ public class C {
public static final String WRITE_PIN_ACTION = "writePinAction";
public static final String X = "x";
public static final String Y = "y";
public static final String COLOUR_COMPARE = "compareColour";
}
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@ private BlocklyConstants() {
public static final String COL = "COL";
public static final String OUT = "OUT";
public static final String DEGREE = "DEGREE";
public static final String DEGREES = "DEGREES";
public static final String MOTORROTATION = "MOTORROTATION";
public static final String DISTANCE = "DISTANCE";
public static final String DIRECTION = "DIRECTION";
Expand Down
4 changes: 4 additions & 0 deletions OpenRobertaServer/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,10 @@
<groupId>de.fhg.iais.openroberta</groupId>
<artifactId>RobotSpike</artifactId>
</dependency>
<dependency>
<groupId>de.fhg.iais.openroberta</groupId>
<artifactId>RobotFischertechnik</artifactId>
</dependency>
<dependency>
<groupId>de.fhg.iais.openroberta</groupId>
<artifactId>OpenRobertaRobot</artifactId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@ public Response handle(JSONObject requestEntity) {
case "ev3dev":
case "mbot2":
case "spike":
case "txt4":
fileName = programName + ".py";
filePath = this.pathToCrosscompilerBaseDir + token + "/" + programName + "/source";
break;
Expand Down Expand Up @@ -121,4 +122,4 @@ public Response handle(JSONObject requestEntity) {
throw new DbcException("exception caught and rethrown", e);
}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ server.staticresources.dir = OpenRobertaServer/staticResources
# For instance, if your school offers nxt, calliope2017 and calliope2016 robots, use this white list:
# robot.whitelist = sim, nxt, calliope2017, calliope2016
# Usually overwritten by command line parameter -d
robot.whitelist = spike, spikePybricks, thymio, wedo, ev3lejosv1, ev3dev, ev3c4ev3, xNN, nxt, microbit, microbitv2, joycar, botnroll, nao, bob3, rob3rta, sensebox, mbot, mbot2, edison, festobionic, festobionicflower, uno, unowifirev2, nano, mega, nano33ble, calliope2017NoBlue, calliope2017, calliope2016, calliopev3, robotino
robot.whitelist = txt4, spike, spikePybricks, thymio, wedo, ev3lejosv1, ev3dev, ev3c4ev3, xNN, nxt, microbit, microbitv2, joycar, botnroll, nao, bob3, rob3rta, sensebox, mbot, mbot2, edison, festobionic, festobionicflower, uno, unowifirev2, nano, mega, nano33ble, calliope2017NoBlue, calliope2017, calliope2016, calliopev3, robotino
robot.default = ev3lejosv1
# account activation / verification / reset
# server.iptocountry.dir path where the db is located, db name is fix: IpToCountry.cvs
Expand Down
Loading

0 comments on commit 468e9e5

Please sign in to comment.