2017-06-17

RobWork part 1 - Installation

Introduction

In this series of tutorials I will show some of the functionalities of RobWork (a set of libraries for robotic research). We will design and model a simple SCARA-type robot and then maybe go on with some fancier and cooler stuff. I will try to write these tutorials in easy-to-stomach pieces and I also can't promise to post them regularly.

Note. We will do these tutorials on Ubuntu system. I encourage you to give it a try even if you haven't tried it yet. It should be perfectly fine installed on a virtual machine.

RobWork (http://www.robwork.dk) is an extensive collection of C++ libraries for use in robotics. I used RobWork in the course of my PhD work on the automating of gripper design and also employed in in some other robotic-related projects (such as modelling of CNC machines and in my other research). I can certainly recommend it for your robotic needs!
RobWork is developed by the robotics group at the Maersk Mc-Kinney Moller Institute at the University of Southern Denmark (http://www.sdu.dk/en/Om_SDU/Institutter_centre/SDURobotics).

Features of RobWork are (among others):
  • modelling of robots (serial, tree and parallel),
  • kinematic and dynamic modelling of devices (manipulators, controllers and sensors),
  • robot forward and inverse kinematics,
  • path planning and optimization,
  • collision detection,
  • grasping simulation,
  • interfaces to ODE, Bullet and RWPE physics engines,
  • script interfaces to Python, LUA and JAVA (Matlab!),
  • all of this wrapped in a neat RobWorkStudio GUI.
You can read more about RobWork on its page, which also sports a comprehensive documentation of its functions.
Obviously, we have to start with the installation of RobWork. Further down I also describe the installation of Blender, which we will use as our 3D modelling tool.

RobWork

RobWork installation is described HERE. You should follow the guide on that page and install all parts of RobWork  software (with an exception for RobWorkHardware which we will not use). In a nutshell:

1. Install the build tools:
sudo apt-get install subversion git mercurial
sudo apt-get install gcc g++ cmake cmake-curses-gui

2. Install the RW, RWS and RWSIM dependencies (including some of the optional):
sudo apt-get install libboost-dev libboost-date-time-dev libboost-filesystem-dev libboost-program-options-dev libboost-regex-dev libboost-serialization-dev libboost-system-dev libboost-test-dev libboost-thread-dev
sudo apt-get install libxerces-c3.1 libxerces-c-dev
sudo apt-get install swig liblua5.2-dev python-dev default-jdk
sudo apt-get install qtdeclarative5-dev
sudo apt-get install libode-dev libode4

3. Create the RobWork directory and download the source code:
cd
mkdir robwork && cd robwork
svn co https://svnsrv.sdu.dk/svn/RobWork/trunk/
cd trunk

4. Create the build directory and issue the CMake command. If there are errors at this step, make sure that you have installed all the required dependencies.
mkdir build && cd build
cmake -DCMAKE_BUILD_TYPE=Release ..

5. (Optional) You can  use ccmake at this point to review the build settings. In particular, make sure that RobWork, RobWorkStudio and RobWorkSim are all enabled (see Fig. 1).
ccmake .

Fig. 1. Build settings.

6. If all is well, we can then proceed with the compilation. This will likely take quite some time. You can stop the make at any time and resume it afterwards; it will retain its progress. You can set the -j N parameter to run the compilation in N parallel threads.
make
or
make -j 4

Hopefully you did not get any build errors! You can verify that all is done correctly by navigating to the ~/robwork/trunk/RobWorkStudio/bin/release and trying to run the RobWorkStudio executable (see Fig. 2).
./RobWorkStudio
Fig. 2. RobWorkStudio.
It is reportedly possible to install RobWork also on Windows... but I don't recommend it (ugh, programming in Windows!). I might make a tutorial on that some other day.

Blender

Blender is an open-source 3D computer graphics software. Even though it is free, it's quite powerful - we won't even use a fraction of its capabilities to create the 3D geometry models for our robot's parts.
Installing Blender on Ubuntu is pretty straightforward. You can probably do it through the Ubuntu Software, but the following command executed in terminal will also do the job:

sudo apt install blender

We will also like to have an option of importing/exporting AC3D files, such that we can enhance our robot geometry with some color. In order to have that possibility you will have to install a 3rd party plugin available at https://github.com/majic79/Blender-AC3D. Download and unpack the ZIP of the repository.
It is important to run Blender at least once before installing the plugin. You should also edit and save the user settings while doing that, so that the config directory appears in your home folder. The plugin is installed by placing the io_scene_ac3d directory from the unpacked archive in your Blender configuration directory (for me it was ~/.config/blender/2.76 - press Ctrl+H to show hidden folders) in the sub-directory scripts/addons (that you likely have to create).
The next step is running Blender again, and going into File->User Preferences. In the Add-ons tab select the Import-Export category (on the left) and enable the
Import-Export: AC3D (.ac) format plugin (see Fig. 3).
Fig. 3. Enabling the AC3D support in Blender.


Summary

Okay! In this part we got acquainted with RobWork and installed our tools successfully. In the next part we will design our SCARA robot.

2017-06-11

Elementary Cellular Automata

I have previously wrote about various classic 2D cellular automata: WATOR, the voting game and Wireworld (here and here). There is a whole class of simpler one dimensional automatons though. These were researched by Stephen Wolfram (of Mathematica and WolframAlpha fame).

What is the elementary cellular automaton anyway?
Imagine a boundless tape of cells (not necessarily infinite; it could connect end to end like a loop). The cells can be in '1' or '0' state at any given moment. The time passes in turns in this universe, and each turn the cell changes its value depending on the state of its neighbours and itself. For example, consider a fragment of the tape stating '...010...'. For this combination of states, a rule might say that the value of the center cell in this fragment becomes '0' the next turn.

There is a limited number of such rules. Since only three bits govern the evolution of the center cell state, the combinations are '000', '001', '010' etc. (8 combinations) - and for each of these the center state can become either '0' or '1', the total number of rules is 2^8 = 256 rules. These are easily encoded as a number. For instance, rule 11010 = 011011102 says that the center cell becomes '1' when the tape fragment the turn before is wither '110', '101', '011', '010', '001' (see the picture below).

Fig. 1. Rule 110.

I made a simple demo for testing various elementary cellular automaton rules. The demo is available HERE, and its source code is hosted on Gitlab HERE. The demo lets you easily change the rules (even as the automaton is working) either by typing the number in or clicking on the graphical tape fragment representations on the left side. You can also modify the tape cells manually by clicking and moving a mouse in the view in the middle. The left mouse button sets the tape cells to '1' and the right mouse button clears them to '0'. You can also randomize the state of the tape the automaton starts from.

Fig. 2. Elementary Cellular Automata demo.

It's a simple world, but it can still yield interesting results. Some of them are presented below.

Rule 90
Starting from a single pixel in the middle we get a Sierpinski triangle of sorts:
Fig. 3. Rule 90 makes a Sierpinski triangle.

Rule 60
Rule 60 also makes a Sierpinski triangle but sort of kicked to its side:
Fig. 4. Rule 60.

Rule 30
It's an interesting one. Seemingly random structures emerge under this rule. It is reportedly used for some of the randomization routines in Wolfram's Mathematica.
Fig. 5. Rule 30.

Rule 110
This one produces curious structures that move across the tape and interact between themselves. It has been proven that rule 110 is Turing complete and thus can be used to model any calculation. I have no idea how to use it yet!
Fig. 6. Rule 110 is a Turing complete CA.

It could certainly be interesting to experiment with the remaining rules and see what they are capable of. Perhaps you have an idea of how this simple setup could be extended? Feel free to play around with the provided demo.

More reading: