2014-02-20

Getting started with V-Rep with Octave on Ubuntu for AMRx

This edX Autonomous Mobile Robots course started last week, and the V-Rep simulator with an octave/Matlab interface is going to be a big part of the optional exercises for the course.  There is a free temporary license available for Matlab, but I don't like installing proprietary binaries on my Linux system, especially temporarily (Linux and Ubuntu really needs a standard way of installing applications into per-user directories that don't require system root).  So I'm trying out the Octave route.

Octave 3.6.2 is available as a standard package for my Ubuntu 12.10 install, but didn't work initially with the AMRx exercise 1 test scripts, so I had to build my own remApi.oct.




Building remApi.oct

Get the mkoct binary for octave:

sudo apt-get install octave-pkg-dev

There is a file in the vrep tar ball to run within octave:

V-REP_PRO_EDU_V3_1_0_64_Linux/programming/remoteApiBindings/octave/buildLin.m

It needs some setup first, which is documented within it:

cd V-REP_PRO_EDU_V3_1_0_64_Linux/programming/remoteApiBindings/octave/
cp ../../remoteApi/* .
cp ../../include/* .
octave
octave:4> buildLin

extApiPlatform.c: In function ‘extApi_readFile’:
extApiPlatform.c:222:8: warning: ignoring return value of ‘fread’, declared with attribute warn_unused_result [-Wunused-result]
remApi.cc: In function ‘octave_value_list FsimxAddStatusbarMessage(const octave_value_list&, int)’:
remApi.cc:161:35: warning: ‘octave_value::octave_value(const charNDArray&, bool, char)’ is deprecated (declared at /usr/include/octave-3.6.2/octave/../octave/ov.h:237) [-Wdeprecated-declarations]
remApi.cc: In function ‘octave_value_list FsimxCopyPasteObjects(const octave_value_list&, int)’:
...
remApi.cc:2834:31: warning: ‘void Array<T>::resize(octave_idx_type) [with T = float; octave_idx_type = int]’ is deprecated (declared at /usr/include/octave-3.6.2/octave/../octave/Array.h:459) [-Wdeprecated-declarations]
remApi.cc: In function ‘octave_value_list FsimxUnpackInts(const octave_value_list&, int)’:
remApi.cc:2856:29: warning: ‘void Array<T>::resize(octave_idx_type) [with T = octave_int<int>; octave_idx_type = int]’ is deprecated (declared at /usr/include/octave-3.6.2/octave/../octave/Array.h:459) [-Wdeprecated-declarations]

octave:4> exit

cp remApi.oct ~/own/edx_amrx/exercise1/code/common/libs/octave/linuxLibrary64Bit

cd ~/own/edx_amrx/exercise1/code/common/vrep

octave

octave:1> test

And it works!  The connection from octave to the running V-REP is established, and then the script commands the simulation to start and then stops soon after.

Annoyances


The edX platform has some annoying quirks I've documented elsewhere.  But other than that it is pretty good.




V-REP is impressive also (coming from using Gazebo a great deal over the past six months), but has an annoying feature where a mouse right click can both rotate the view and open a context menu, the very first option is to close the 3D view window.  So it is very possible especially on a laptop trackpad to accidentally try to rotate but end up closing the window of the view that was to be rotated.


Debugging steps (not part of the solution)


The first thing I tried was to launch vrep.sh from the vrep tar ball, load the exercise 1 ttt scene, and then enter the exercise1/code/common/vrep/ directory, launch octave, and try to run test.m:

octave:2> conn = simulation_setup();
/home/lwalter/own/edx_amrx/exercise1/code/common/vrep/../libs/octave/linuxLibrary64Bit/remApi.oct
octave:3> robot_nb=0
robot_nb = 0
octave:4> conn = simulation_openConnection(conn, robot_nb )
error: simulation_openConnection: /home/lwalter/own/edx_amrx/exercise1/code/common/vrep/../libs/octave/linuxLibrary64Bit/remApi.oct: failed to load: liboctinterp.so: cannot open shared object file: No such file or directory
error: called from:
error:   /home/lwalter/own/edx_amrx/exercise1/code/common/vrep/simulation_openConnection.m at line 30, column 28

I have liboctinerp.so.1, but no liboctinterp.so, so in a user directory on my LD_LIBRARY_PATH I added links to it and other libraries that were subsequently not found:

ln -s /usr/lib/x86_64-linux-gnu/liboctinterp.so.1 ~/other/install/lib/liboctinterp.so
ln -s /usr/lib/x86_64-linux-gnu/liboctave.so.1 ~/other/install/lib/liboctave.so
ln -s /usr/lib/x86_64-linux-gnu/libcruft.so.1 ~/other/install/lib/libcruft.so

Update - on a 13.04 Ubuntu I built the remApi.oct first, these steps are unnecessary.

I tried test.m again and ran into this problem:

octave:3> connection = simulation_openConnection(connection, robotNb);
error: simulation_openConnection: /home/lwalter/own/edx_amrx/exercise1/code/common/vrep/../libs/octave/linuxLibrary64Bit/remApi.oct: failed to load: /home/lwalter/own/edx_amrx/exercise1/code/common/vrep/../libs/octave/linuxLibrary64Bit/remApi.oct: undefined symbol: _ZN5ArrayI12octave_valueED0Ev
error: called from:
error:   /home/lwalter/own/edx_amrx/exercise1/code/common/vrep/simulation_openConnection.m at line 30, column 28

I saw some references to being able to rebuild remApi.oct, so set out to do that next.



Post a Comment