making CoppeliaSim ROS1/ROS2 enabled on ubuntu18.04

Typically: "How do I... ", "How can I... " questions
Post Reply
masatomori
Posts: 5
Joined: 13 Dec 2019, 10:46

making CoppeliaSim ROS1/ROS2 enabled on ubuntu18.04

Post by masatomori » 16 Dec 2019, 06:57

Dear coppelia:

I am trying to have CoppeliaSim ROS1 and ROS 2 enabled.

First I copied files in CoppeliaSim/compiledROSPlugins to CoppeliaSim/, however it won't be loaded.
(In the case of ROS1, I have confirmed that roscore is running.)

I tried recompile packages following CoppeliaSim ROS tutorial page.
http://www.coppeliarobotics.com/helpFil ... torial.htm
However, build was failed both ROS1 and ROS2.

I haven't changed any of the files in simExtROSInterface/ (in case ROS1) and simExtROS2Interface/ (in case ROS2) directories.

How can I make recompile successful on ROS1/ROS2?

<Environment>
Ubuntu 18.04
(In the Ubuntu 16.04 environment - another PC - , I was able to load the supplied ROS1 Plugin file.)
CoppeliaSim Pro V4.0.0 rev1

ROS1 distro : melodic
Error Massage:

Code: Select all

$ catkin build --jobs 1 --cmake-args -DCMAKE_BUILD_TYPE=Release -DLIBPLUGIN_DIR=$COPPELIASIM_ROOT_DIR/programming/libPlugin -- --make-args -j1 --
-----------------------------------------------------------------------------------------------------
Profile:                     default
Extending:             [env] /opt/ros/melodic
Workspace:                   /home/user/coppelia_ws
-----------------------------------------------------------------------------------------------------
Build Space:        [exists] /home/user/coppelia_ws/build
Devel Space:        [exists] /home/user/coppelia_ws/devel
Install Space:      [unused] /home/user/coppelia_ws/install
Log Space:         [missing] /home/user/coppelia_ws/logs
Source Space:       [exists] /home/user/coppelia_ws/src
DESTDIR:            [unused] None
-----------------------------------------------------------------------------------------------------
Devel Space Layout:          linked
Install Space Layout:        None
-----------------------------------------------------------------------------------------------------
Additional CMake Args:       -DCMAKE_BUILD_TYPE=Release -DLIBPLUGIN_DIR=/home/user/Downloads/coppeliaSimProV400/programming/libPlugin
Additional Make Args:        -j1 --jobs 1
Additional catkin Make Args: None
Internal Make Job Server:    True
Cache Job Environments:      False
-----------------------------------------------------------------------------------------------------
Whitelisted Packages:        None
Blacklisted Packages:        None
-----------------------------------------------------------------------------------------------------
Workspace configuration appears valid.

NOTE: Forcing CMake to run for each package.
-----------------------------------------------------------------------------------------------------
[build] Found '1' packages in 0.0 seconds.                                                          
[build] Updating package table.                                                                     
Warning: generated devel space setup files have been deleted.
Starting  >>> catkin_tools_prebuild                                                                 
Finished  <<< catkin_tools_prebuild                [ 2.6 seconds ]                                  
Starting  >>> sim_ros_interface                                                                     
____________________________________________________________________________________________________
Errors     << sim_ros_interface:make /home/user/coppelia_ws/logs/sim_ros_interface/build.make.000.log
Traceback (most recent call last):
  File "/home/user/Downloads/coppeliaSimProV400/programming/libPlugin/simStubsGen/external/pycpp/pycpp.py", line 200, in <module>
    pycpp = PyCPP(input_str=input_str, params=params)
  File "/home/user/Downloads/coppeliaSimProV400/programming/libPlugin/simStubsGen/external/pycpp/pycpp.py", line 113, in __init__
    raise RuntimeError('line {:d}: expected "{}" to close "{}"'.format(line.no, cur.rule.close_tag, cur.tag))
RuntimeError: line 9: expected "endfor" to close "for"
make[2]: *** [generated/adv.cpp] Error 1
make[1]: *** [CMakeFiles/generate_ros_code.dir/all] Error 2
make: *** [all] Error 2
cd /home/user/coppelia_ws/build/sim_ros_interface; catkin build --get-env sim_ros_interface | catkin env -si  /usr/bin/make --jobserver-fds=6,7 -j; cd -
....................................................................................................
Failed     << sim_ros_interface:make               [ Exited with code 2 ]                           
Failed    <<< sim_ros_interface                    [ 3.0 seconds ]                                  
[build] Summary: 1 of 2 packages succeeded.                                                         
[build]   Ignored:   None.                                                                          
[build]   Warnings:  None.                                                                          
[build]   Abandoned: None.                                                                          
[build]   Failed:    1 packages failed.                                                             
[build] Runtime: 5.7 seconds total.         


ROS2 distro : dashing
Error Massage:

Code: Select all

$ colcon build --symlink-install --cmake-args -DCMAKE_BUILD_TYPE=Release -DLIBPLUGIN_DIR=$COPPELIASIM_ROOT_DIR/programming/libPlugin
Starting >>> ros2_bubble_rob
Starting >>> sim_ros2_interface
--- stderr: ros2_bubble_rob                                                                                 
CMake Warning:
  Manually-specified variables were not used by the project:

    LIBPLUGIN_DIR


---
Finished <<< ros2_bubble_rob [7.64s]
[Processing: sim_ros2_interface]                            
[Processing: sim_ros2_interface]                                    
--- stderr: sim_ros2_interface                                      
Traceback (most recent call last):
  File "/home/user/Downloads/coppeliaSimProV400/programming/libPlugin/simStubsGen/external/pycpp/pycpp.py", line 200, in <module>
Traceback (most recent call last):
  File "/home/user/Downloads/coppeliaSimProV400/programming/libPlugin/simStubsGen/external/pycpp/pycpp.py", line 200, in <module>
    pycpp = PyCPP(input_str=input_str, params=params)
  File "/home/user/Downloads/coppeliaSimProV400/programming/libPlugin/simStubsGen/external/pycpp/pycpp.py", line 113, in __init__
    raise RuntimeError('line {:d}: expected "{}" to close "{}"'.format(line.no, cur.rule.close_tag, cur.tag))
    pycpp = PyCPP(input_str=input_str, params=params)
RuntimeError:   File "/home/user/Downloads/coppeliaSimProV400/programming/libPlugin/simStubsGen/external/pycpp/pycpp.py", line 113, in __init__
line 9: expected "endfor" to close "for"
Traceback (most recent call last):
Traceback (most recent call last):
  File "/home/user/Downloads/coppeliaSimProV400/programming/libPlugin/simStubsGen/external/pycpp/pycpp.py", line 200, in <module>
      File "/home/user/Downloads/coppeliaSimProV400/programming/libPlugin/simStubsGen/external/pycpp/pycpp.py", line 200, in <module>
raise RuntimeError('line {:d}: expected "{}" to close "{}"'.format(line.no, cur.rule.close_tag, cur.tag))
RuntimeError: line 10: expected "endfor" to close "for"
Traceback (most recent call last):
        pycpp = PyCPP(input_str=input_str, params=params)
  File "/home/user/Downloads/coppeliaSimProV400/programming/libPlugin/simStubsGen/external/pycpp/pycpp.py", line 200, in <module>
pycpp = PyCPP(input_str=input_str, params=params)
  File "/home/user/Downloads/coppeliaSimProV400/programming/libPlugin/simStubsGen/external/pycpp/pycpp.py", line 113, in __init__
Traceback (most recent call last):
Traceback (most recent call last):
    pycpp = PyCPP(input_str=input_str, params=params)
      File "/home/user/Downloads/coppeliaSimProV400/programming/libPlugin/simStubsGen/external/pycpp/pycpp.py", line 200, in <module>
  File "/home/user/Downloads/coppeliaSimProV400/programming/libPlugin/simStubsGen/external/pycpp/pycpp.py", line 200, in <module>
    pycpp = PyCPP(input_str=input_str, params=params)
  File "/home/user/Downloads/coppeliaSimProV400/programming/libPlugin/simStubsGen/external/pycpp/pycpp.py", line 113, in __init__
    pycpp = PyCPP(input_str=input_str, params=params)
  File "/home/user/Downloads/coppeliaSimProV400/programming/libPlugin/simStubsGen/external/pycpp/pycpp.py", line 113, in __init__
  File "/home/user/Downloads/coppeliaSimProV400/programming/libPlugin/simStubsGen/external/pycpp/pycpp.py", line 113, in __init__
    raise RuntimeError('line {:d}: expected "{}" to close "{}"'.format(line.no, cur.rule.close_tag, cur.tag))
raise RuntimeError('line {:d}: expected "{}" to close "{}"'.format(line.no, cur.rule.close_tag, cur.tag))
    RuntimeError    : raise RuntimeError('line {:d}: expected "{}" to close "{}"'.format(line.no, cur.rule.close_tag, cur.tag))
RuntimeErrorline 22: expected "endfor" to close "for": raise RuntimeError('line {:d}: expected "{}" to close "{}"'.format(line.no, cur.rule.close_tag, cur.tag))
RuntimeError
: line 12: expected "endfor" to close "for"
RuntimeErrorline 10: expected "endfor" to close "for": line 28: expected "endfor" to close "for"

  File "/home/user/Downloads/coppeliaSimProV400/programming/libPlugin/simStubsGen/external/pycpp/pycpp.py", line 113, in __init__
    raise RuntimeError('line {:d}: expected "{}" to close "{}"'.format(line.no, cur.rule.close_tag, cur.tag))
RuntimeError: line 10: expected "endfor" to close "for"
Traceback (most recent call last):
  File "/home/user/Downloads/coppeliaSimProV400/programming/libPlugin/simStubsGen/external/pycpp/pycpp.py", line 200, in <module>
    pycpp = PyCPP(input_str=input_str, params=params)
  File "/home/user/Downloads/coppeliaSimProV400/programming/libPlugin/simStubsGen/external/pycpp/pycpp.py", line 101, in __init__
    raise RuntimeError('line {:d}: unexpected "{}" after "{}"'.format(line.no, line.text, cur.tag))
RuntimeError: line 69: unexpected "else:
" after "else"
make[2]: *** [generated/cli_new.cpp] Error 1
make[2]: *** Waiting for unfinished jobs....
make[2]: *** [generated/cli_del.cpp] Error 1
make[2]: *** [generated/pub_del.cpp] Error 1
make[2]: *** [generated/pub_publish.cpp] Error 1
make[2]: *** [generated/pub_new.cpp] Error 1
make[2]: *** [generated/cli_call.cpp] Error 1
make[2]: *** [generated/callbacks.cpp] Error 1
make[2]: *** [generated/callbacks.h] Error 1
make[1]: *** [CMakeFiles/generate_ros_code.dir/all] Error 2
make: *** [all] Error 2
---
Failed   <<< sim_ros2_interface	[ Exited with code 2 ]

Summary: 1 package finished [1min 10s]
  1 package failed: sim_ros2_interface
  2 packages had stderr output: ros2_bubble_rob sim_ros2_interface

I will appreciate your help with this situation.

masato

fferri
Posts: 532
Joined: 09 Sep 2013, 19:28

Re: making CoppeliaSim ROS1/ROS2 enabled on ubuntu18.04

Post by fferri » 16 Dec 2019, 09:08

masatomori wrote:
16 Dec 2019, 06:57
Error Massage:

Code: Select all

RuntimeError: line 9: expected "endfor" to close "for"
make[2]: *** [generated/adv.cpp] Error 1
That's weird. Has the file sim_ros_interface/templates/adv.cpp been modified somewhat (compare with reference: adv.cpp)? Can you show the content of this file?

Also, does running the following:

Code: Select all

cd /path/to/src/sim_ros_interface
python $COPPELIASIM_ROOT_DIR/programming/libPlugin/simStubsGen/external/pycpp/pycpp.py -P tools -p messages_file=meta/messages.txt -i templates/adv.cpp
produce the same error? And adding the -m tree option?

masatomori
Posts: 5
Joined: 13 Dec 2019, 10:46

Re: making CoppeliaSim ROS1/ROS2 enabled on ubuntu18.04

Post by masatomori » 18 Dec 2019, 03:01

Thank you for your reply.

I have not changed anything in adv.cpp.
I show the comparison results below.

Image


I also show the result of running python in addition.

Code: Select all

~/coppelia_ws/src/simExtROSInterface$ python $COPPELIASIM_ROOT_DIR/programming/libPlugin/simStubsGen/external/pycpp/pycpp.py -P tools -p messages_file meta/messages.txt -i templates/adv.cpp
usage: pycpp.py [-h] [-i INPUT_FILE] [-o OUTPUT_FILE]
                [-m {tree,python,output}] [-p key=value] [-P path]
pycpp.py: error: unrecognized arguments: meta/messages.txt


~/coppelia_ws/src/simExtROSInterface$ python $COPPELIASIM_ROOT_DIR/programming/libPlugin/simStubsGen/external/pycpp/pycpp.py -m tree -P tools -p messages_file meta/messages.txt -i templates/adv.cpp
usage: pycpp.py [-h] [-i INPUT_FILE] [-o OUTPUT_FILE]
                [-m {tree,python,output}] [-p key=value] [-P path]
pycpp.py: error: unrecognized arguments: meta/messages.txt

Just in case, I downloaded the source again from the github page and built it.
(Regarding ROS1)
The results are shown below.

Code: Select all

$ catkin build --jobs 1 --cmake-args -DCMAKE_BUILD_TYPE=Release -DLIBPLUGIN_DIR=$COPPELIASIM_ROOT_DIR/programming/libPlugin -- --make-args -j1 --
-------------------------------------------------------------------------------------------------------------------------------------
Profile:                     default
Extending:             [env] /opt/ros/melodic
Workspace:                   /home/user/coppelia_ws
-------------------------------------------------------------------------------------------------------------------------------------
Build Space:        [exists] /home/user/coppelia_ws/build
Devel Space:        [exists] /home/user/coppelia_ws/devel
Install Space:      [unused] /home/user/coppelia_ws/install
Log Space:         [missing] /home/user/coppelia_ws/logs
Source Space:       [exists] /home/user/coppelia_ws/src
DESTDIR:            [unused] None
-------------------------------------------------------------------------------------------------------------------------------------
Devel Space Layout:          linked
Install Space Layout:        None
-------------------------------------------------------------------------------------------------------------------------------------
Additional CMake Args:       -DCMAKE_BUILD_TYPE=Release -DLIBPLUGIN_DIR=/home/user/Downloads/coppeliaSimProV400/programming/libPlugin
Additional Make Args:        -j1 --jobs 1
Additional catkin Make Args: None
Internal Make Job Server:    True
Cache Job Environments:      False
-------------------------------------------------------------------------------------------------------------------------------------
Whitelisted Packages:        None
Blacklisted Packages:        None
-------------------------------------------------------------------------------------------------------------------------------------
Workspace configuration appears valid.
-------------------------------------------------------------------------------------------------------------------------------------
[build] Found '1' packages in 0.0 seconds.                                                                                                                                                                   
[build] Updating package table.                                                                                                                                                                              
Warning: generated devel space setup files have been deleted.
Starting  >>> catkin_tools_prebuild                                                                                                                                                                          
Finished  <<< catkin_tools_prebuild                [ 1.8 seconds ]                                                                                                                                           
Starting  >>> sim_ros_interface                                                                                                                                                                              
_____________________________________________________________________________________________________________________________________________________________________________________________________________
Errors     << sim_ros_interface:make /home/user/coppelia_ws/logs/sim_ros_interface/build.make.000.log                                                                                                        
Traceback (most recent call last):
  File "/home/user/Downloads/coppeliaSimProV400/programming/libPlugin/simStubsGen/generate.py", line 102, in <module>
    runprogram('xsltproc', '-o', output('reference.html'), rel('xsl/reference.xsl'), input_xml)
  File "/home/user/Downloads/coppeliaSimProV400/programming/libPlugin/simStubsGen/generate.py", line 56, in runprogram
    runsubprocess(what, [what] + list(cmdargs))
  File "/home/user/Downloads/coppeliaSimProV400/programming/libPlugin/simStubsGen/generate.py", line 46, in runsubprocess
    child = subprocess.Popen(cmdargs)
  File "/usr/lib/python2.7/subprocess.py", line 394, in __init__
    errread, errwrite)
  File "/usr/lib/python2.7/subprocess.py", line 1047, in _execute_child
    raise child_exception
OSError: [Errno 2] No such file or directory
make[2]: *** [generated/stubs.cpp] Error 1
make[2]: *** Deleting file 'generated/stubs.cpp'
make[1]: *** [CMakeFiles/simExtROSInterface.dir/all] Error 2
make: *** [all] Error 2
cd /home/user/coppelia_ws/build/sim_ros_interface; catkin build --get-env sim_ros_interface | catkin env -si  /usr/bin/make --jobserver-fds=6,7 -j; cd -
.............................................................................................................................................................................................................
Failed     << sim_ros_interface:make               [ Exited with code 2 ]                                                                                                                                    
Failed    <<< sim_ros_interface                    [ 10.5 seconds ]                                                                                                                                          
[build] Summary: 1 of 2 packages succeeded.                                                                                                                                                                  
[build]   Ignored:   None.                                                                                                                                                                                   
[build]   Warnings:  None.                                                                                                                                                                                   
[build]   Abandoned: None.                                                                                                                                                                                   
[build]   Failed:    1 packages failed.                                                                                                                                                                      
[build] Runtime: 12.3 seconds total.   
How can I solve this problem?

Thanks,

fferri
Posts: 532
Joined: 09 Sep 2013, 19:28

Re: making CoppeliaSim ROS1/ROS2 enabled on ubuntu18.04

Post by fferri » 18 Dec 2019, 09:14

masatomori wrote:
18 Dec 2019, 03:01
I also show the result of running python in addition.

Code: Select all

~/coppelia_ws/src/simExtROSInterface$ python $COPPELIASIM_ROOT_DIR/programming/libPlugin/simStubsGen/external/pycpp/pycpp.py -P tools -p messages_file meta/messages.txt -i templates/adv.cpp
usage: pycpp.py [-h] [-i INPUT_FILE] [-o OUTPUT_FILE]
                [-m {tree,python,output}] [-p key=value] [-P path]
pycpp.py: error: unrecognized arguments: meta/messages.txt


~/coppelia_ws/src/simExtROSInterface$ python $COPPELIASIM_ROOT_DIR/programming/libPlugin/simStubsGen/external/pycpp/pycpp.py -m tree -P tools -p messages_file meta/messages.txt -i templates/adv.cpp
usage: pycpp.py [-h] [-i INPUT_FILE] [-o OUTPUT_FILE]
                [-m {tree,python,output}] [-p key=value] [-P path]
pycpp.py: error: unrecognized arguments: meta/messages.txt
Sorry, I made a typo. There's an equal sign = between messages_file and meta/messages.txt, not a space.

fferri
Posts: 532
Joined: 09 Sep 2013, 19:28

Re: making CoppeliaSim ROS1/ROS2 enabled on ubuntu18.04

Post by fferri » 18 Dec 2019, 09:15

masatomori wrote:
18 Dec 2019, 03:01
Just in case, I downloaded the source again from the github page and built it.
(Regarding ROS1)
The results are shown below.

Code: Select all

Errors     << sim_ros_interface:make /home/user/coppelia_ws/logs/sim_ros_interface/build.make.000.log                                                                                                        
Traceback (most recent call last):
  File "/home/user/Downloads/coppeliaSimProV400/programming/libPlugin/simStubsGen/generate.py", line 102, in <module>
    runprogram('xsltproc', '-o', output('reference.html'), rel('xsl/reference.xsl'), input_xml)
  File "/home/user/Downloads/coppeliaSimProV400/programming/libPlugin/simStubsGen/generate.py", line 56, in runprogram
    runsubprocess(what, [what] + list(cmdargs))
  File "/home/user/Downloads/coppeliaSimProV400/programming/libPlugin/simStubsGen/generate.py", line 46, in runsubprocess
    child = subprocess.Popen(cmdargs)
  File "/usr/lib/python2.7/subprocess.py", line 394, in __init__
    errread, errwrite)
  File "/usr/lib/python2.7/subprocess.py", line 1047, in _execute_child
    raise child_exception
OSError: [Errno 2] No such file or directory
How can I solve this problem?

Thanks,
This is a different issue. You can solve this by installing the missing program (xsltproc) with sudo apt install xsltproc

masatomori
Posts: 5
Joined: 13 Dec 2019, 10:46

Re: making CoppeliaSim ROS1/ROS2 enabled on ubuntu18.04

Post by masatomori » 25 Dec 2019, 11:21

Thank you for your reply.

I have successfully enabled ROS1/ROS2 in Ubuntu 18.04.

I did this by installing xsltproc.
As follows:

Code: Select all

 sudo apt install xsltproc 
The problem was caused by the lack of xsltproc.

Thank you very much!!

masato

Higor
Posts: 4
Joined: 11 Feb 2020, 14:03

Re: making CoppeliaSim ROS1/ROS2 enabled on ubuntu18.04

Post by Higor » 11 Feb 2020, 17:07

I have the same problem, but I didn't understand the previous steps could you help me?

Higor
Posts: 4
Joined: 11 Feb 2020, 14:03

Re: making CoppeliaSim ROS1/ROS2 enabled on ubuntu18.04

Post by Higor » 11 Feb 2020, 17:10

I really need a step-by-step help with ROS Coppelia configuration and communication, I am new to this system, and I need it because I will do my TCC on top of that

Post Reply