This repository contain code to simulate specific robots (Thymio2 and e-puck) and generic Aseba nodes in CoppeliaSim.
You can control the robots/nodes
- in lua, using the interpreter embedded in CoppeliaSim
- in Aseba using Aseba Studio, ThymioSuite, or even from CoppeliaSim (with a more limited support).
- in ROS, using my own Aseba-ROS bridge.
- Aseba (available as submodule)
- Dashel (available as submodule)
- CoppeliaSim v4.3, v4.4, v4.5, or v4.6
- xsltproc (CoppeliaSim plugins dependency)
- xmlschema (CoppeliaSim plugins dependency)
- Cmake >= 3.5
- a C++17 compiler
- OpenCV
- [optional, to parse Aseba scripts] libxml2
- [optional, for autodiscovery] Avahi or Bonjour
- [optional, to autogenerate the docs] Jinjia2
sudo apt install cmake libopencv-dev xsltproc [libxml2-dev] [libavahi-compat-libdnssd-dev]
[python3 -m pip install Jinja2 xmlschema]
brew install cmake opencv [libxml2]
[python3 -m pip install Jinja2 xmlschema]
To compile and then use the CoppeliaSim plugin you need ... CoppeliaSim. Download the latest release and export the location where you place it with
export COPPELIASIM_ROOT_DIR=<path to the folder containing the programming subfolder>
which on Linux is the root folder that you download, while on MacOs is /Applications/coppeliaSim.app/Contents/Resources
, if you install the app to the default location.
$ git clone --recursive https://github.com/jeguzzi/coppeliasim-aseba.git
$ cd coppeliasim-aseba
$ mkdir -p build
$ cd build
$ cmake -DCMAKE_BUILD_TYPE=Release ..
$ make install -j4
This will build the plugin and install it together with the robot model[s].
Launch CoppeliaSim. In the model browser, you will find models for Thymio, MightyThymio, and e-puck (called e-puck-aseba
to distinguish it from the model already installed) in robots > mobile
, which you can drag into the scene. Press play.
If you want to program your own custom Aseba node, in the init callback of a lua script, use
node = simAseba.create_node()
You can then add Aseba variables, functions and events using this lua API.
The simulated Thymio emulates the Aseba firmware available on real Thymios. Inside CoppeliaSim, we also expose a lua interface similar to the Aseba interface: take a look at the list of supported functions. For example, in Aseba, you can change the color of the large top LED like this (Aseba is integer-only and in this case a value of 32 corresponds to maximal brightness)
call leds.top(32, 0, 0)
while inside CoppeliaSim, you control the LED color like this
simThymio.set_led(0, 0, 1.0, 0.0, 0.0)
where the first two arguments identifies the robot and the LED, and where rgb colors are encoded in float instead.
If you want, you can customize the Aseba node of the simulated Thymio too, using the same API.
Similarly, the simulated e-puck, emulates the Aseba firmware available for real e-pucks, while we also expose a lua interface.
You can have as many robots/nodes as you like and attach them to the same or to different Aseba networks. Nodes on the same network will be assigned different IDs and can exchange Aseba events among themselves.
The simulated Thymio implements all features of the real robot (firmware v14).
- motors
- LEDs
- proximity sensors
- ground sensors
- accelerometer
- buttons (you can click on them)
- tap detection
- proximity communication
- SD card
- battery
- temperature sensor
- RC sensor
- Microphone
- speaker (accepts
sound.{play|replay|freq}
and triggers the eventsound.finished
after waiting during the sound duration without actually playing it.)
The implementation is heavily inspired by the excellent 2D simulator Enki. In particular, the Thymio LEDs and 3D model are taken directly from Enki. Enki provides the core functionality of Aseba playground, which is the simulator mostly commonly used with Thymios and Aseba.
With respect to Enki/Aseba playground, coppeliaSim together with this plugin, share these features:
- simulate one or more Thymios, emulating the Aseba-based firmware (and are therefore compatible with Aseba Studio and/or VPL)
- motors, LEDs, proximity sensors, buttons, ground sensors
- compatible with the new autodiscovery of Thymio Suite
CoppeliaSim together with this plugin, adds:
- fully featured 3D robotics simulation (this from CoppeliaSim alone :-))
- ground sensors detect steps/holes/ too
- proximity sensors responds to material color too
- some more LEDs (2 for ground sensors and 3 for the battery-level)
- accelerometer
- proximity communication
- tap detection from accelerometer
- basic support for rc, microphone, speaker, battery, and temperature sensor.
- option to enable the same behavior of the real robot that provides feedback about proximity and ground sensors, battery level, accelerometer, microphone, temperature and rc, when the LEDs are not controlled by an Aseba script.
- support for firmware v14
- multiple robots on the same Aseba network (without the need of running
asebaswitch
) - customizable Thymio Aseba node
- custom Aseba nodes implemented in lua
- loading Aseba scripts from lua
The simulated e-puck implements all features of the real robot exposed in the Aseba firmware.
- motors
- LEDs
- proximity sensors
- accelerometer
- gyroscope
- camera
- battery
- selector
- RC sensor
- microphones
Like for the Thymio, the object model is taken directly from Enki. With respect to Enki/Aseba playground, coppeliaSim together with this plugin, shares these features:
- simulate one or more e-puck, emulating the Aseba-based firmware (therefore compatible with Aseba Studio).
- motors, proximity sensors, camera
In addition to the list presented before for the Thymio, this simulation adds specific e-puck features:
- 8 red LED on the ring
- green body LED
- green front LED
- accelerometer
- gyroscope
- basic support for rc, microphones, battery, and selector
- customizable e-puck Aseba node