Skip to content

SenseBox implementation

Reinhard Budde edited this page Apr 16, 2019 · 1 revision

Step 1.

Created SenseboxFactory.java, SenseboxCppVisitor.java and SenseboxCompilerWorkflow.java. The latter is needed only because we do not inject the appropriate language visitorand this is the only difference between all arduino compiler workflows.

In SenseboxCppVisitor.java methods for the main task and prefix were implemented.

Step 2.

Blockly needs some alterations to make sure that blocks needed for configuration and sensors exist.

in blockly/blocks/robConfigDefinitions.js a new object with SenseBox pins was created stating that there are 6 pins numbered from 0 to 5. Many config block definitions were copied from Arduino ones with the change of default pins, since Arduino has A0..Ax pins whereas SenseBox has 0..5 pins. If pins are not supposed to be a dropdown and instead only a single value, then instead of a function(a) a function with no parameters should be created that return an array of a tuple. conBlocks.humifity.sensebox is an example. there we simply put I2C instead of a dropdown with pin numbers.

In a similar fashion robSensorDefinitions.js was edited to add required sensors. When sensors are identical a simple assignement was used.

Step 3.

robActions.js has js code that defines the blocks with actors. In this particular case actors are similar with Arduino's, so in places when the workspace device is compared with arduino, sensebox was added. Another important change must have been done in core/constants.js - sensebox was added, so all needed variable types were available.

Step 4.

Code generation for a sample of actors and sensors was implemented. As well as the proper program prefix with the correct header file.

Step 5.

Arduino builder organises it's library paths, tool paths and hardware paths in a bit of a different way as was done before in robertalab and namely it has locations for built-in and later installed packages. Another issue is that these locations are organised differently in terms of the directory structure. Arduino builder can merge needed libraries and resources on it's own, so the structure resembling Arduino IDE installation was created with tow locations for packages. Later -hardware flag was provided twice in the *CompilerWorkflow.java files in order to load all the built-in boards and tools and the ones that can be installed from the IDE itself.

Step 6.

In order to implement a completely new block the following steps are needed to be taken:

  • implement the block in blockly For example a new sensor block should be added to blocks/robSensorDefinitions and if needed a corresponding configuration block should be added to blocks/robConfigDefinitions. Blocks are connected via the title paramter, so it must be the same for these two blocks. Messages should be written for each block if already not present. Two files need to be edited, robMsg/robMessages.js and robMsg/json/de.json for the translation. The scheme for the names is as follows: SENSOR_sensoName will be the text displayed on the block SENSOR_sensorName_GETSAMPLE_TOOLTIP will be the tooltip message, MODE_modeName (when used in the sensor block as modes) will be the text for the mode.

  • create a SensorNameSensor.java file that implements the sensor. The parameter in the constructor for this class comes from the robotCommon.yml and there the robConf_blockName and robSensors_sensorName must be mapped to this capitalised name. If new modes were added, they should be put there as well.

AN IMPORTANT NOTE: all names of blocks MUST be lower case, otherwise copying of blocks does not work, which includes dragging of the block from the toolbox.

Clone this wiki locally