Closed JLBicho closed 1 year ago
Hi there @biofotis, I've seen you recently updated to noetic the README and changelog. Is there a plan for ROS2-foxy?
Thank you very much!
Hello @JLBicho sorry i didnt get a notification before. We have plans for ROS2 but not in the near future. It would be after summer so I wont be able to help you here. Its not a complicated package so once you sort the dependencies it will be fine. If you do please let us know so we can port it as well
Hi tehre @biofotis ! Thanks for the answer. I was able to compile for ROS2-Foxy. It was just a minor problem in the CMakeLists.txt However, now I face the problem of the unlinked libraries when giving capabilities to the executable. It seems that this is the correct behavior. How did you resolve this in ROS1? I am currently using ROS2-Foxy on Ubuntu20.04
Example of the output of the launch:
[INFO] [mitsubishi_main-1]: process started with pid [59898]
[mitsubishi_main-1] /home/jose/ros2_ws/install/mitsubishi_servo/lib/mitsubishi_servo/mitsubishi_main: error while loading shared libraries: librcl_lifecycle.so: cannot open shared object file: No such file or directory
[ERROR] [mitsubishi_main-1]: process has died [pid 59898, exit code 127, cmd 'ethercat_grant /home/jose/ros2_ws/install/mitsubishi_servo/lib/mitsubishi_servo/mitsubishi_main --ros-args -r __ns:=/mitsubishi --params-file /home/jose/ros2_ws/install/mitsubishi_servo/share/mitsubishi_servo/params/mrj5n.yaml'].
Hello @JLBicho Have a look here: https://github.com/shadow-robot/ros_ethercat/blob/noetic-devel/ros_ethercat_hardware/CMakeLists.txt#L47 When you run ethercat_grant you are in superuser mode so the environment lost the library paths. So you need to add the ros_enable_rpath like we do above
Let me know if that helps
Sorry forgot to mention that this method is defined here: https://github.com/shadow-robot/ros_ethercat/blob/noetic-devel/ros_ethercat_model/cmake/ros_ethercat_model-extras.cmake.em
Hi there, @biofotis ! Thank you very much for you answer. It was very helpful to understand a little more about this. However, it does not seem to solve my problem.
I've added what you suggested in my CMakeLists with the additional function, changing the CATKIN libs for the AMENT paths. I also added some messages to check the libraries.
function(ros_enable_rpath target)
# Set ${target} with RPATH built in so that we can install it suid
set_target_properties(${target} PROPERTIES SKIP_BUILD_RPATH FALSE)
# Set the install RPATH to the install path
# set(RPATH "${CMAKE_INSTALL_PREFIX}/${CATKIN_PACKAGE_LIB_DESTINATION}")
set(RPATH "${CMAKE_PREFIX_PATH}/${AMENT_PREFIX_PATH}")
# If LD_LIBRARY_PATH is set, add it to the install RPATH
# this works in a normal catkin environment, but fails if the user unsets
# their LD_LIBRARY_PATH manually for some reason
if(DEFINED ENV{LD_LIBRARY_PATH})
set(RPATH "${RPATH}:$ENV{LD_LIBRARY_PATH}")
endif()
message("Install RPATH for ${target} is \n${RPATH}")
# Apply our computed RPATH to the target
set_target_properties(${target} PROPERTIES INSTALL_RPATH ${RPATH})
get_target_property(path ${target} INSTALL_RPATH)
message("\n\n === Path is ===\n" ${path})
# Don't use the final RPATH in devel space
set_target_properties(${target} PROPERTIES BUILD_WITH_INSTALL_RPATH FALSE)
endfunction()
jose@josel-portatil:~/ros2_ws$ colcon build --symlink-install --packages-select mitsubishi_servo
Starting >>> mitsubishi_servo
--- stderr: mitsubishi_servo
Install RPATH for mitsubishi_main is
/:/home/jose/ros2_ws/install/mitsubishi_msgs/lib:/usr/lib/x86_64-linux-gnu/gazebo-11/plugins:/opt/ros/foxy/opt/yaml_cpp_vendor/lib:/opt/ros/foxy/opt/rviz_ogre_vendor/lib:/opt/ros/foxy/lib/x86_64-linux-gnu:/opt/ros/foxy/lib
=== Path is ===
/:/home/jose/ros2_ws/install/mitsubishi_msgs/lib:/usr/lib/x86_64-linux-gnu/gazebo-11/plugins:/opt/ros/foxy/opt/yaml_cpp_vendor/lib:/opt/ros/foxy/opt/rviz_ogre_vendor/lib:/opt/ros/foxy/lib/x86_64-linux-gnu:/opt/ros/foxy/lib
---
Finished <<< mitsubishi_servo [0.78s]
Summary: 1 package finished [0.87s]
1 package had stderr output: mitsubishi_servo
jose@josel-portatil:~/ros2_ws$ source install/setup.bash
jose@josel-portatil:~/ros2_ws$ ros2 launch mitsubishi_servo mitsubishi_servo.launch.py
[INFO] [launch]: All log files can be found below /home/jose/.ros/log/2022-06-13-15-55-30-801029-josel-portatil-249195
[INFO] [launch]: Default logging verbosity is set to INFO
[INFO] [mitsubishi_main-1]: process started with pid [249198]
[mitsubishi_main-1] /home/jose/ros2_ws/install/mitsubishi_servo/lib/mitsubishi_servo/mitsubishi_main: error while loading shared libraries: librcl_lifecycle.so: cannot open shared object file: No such file or directory
[ERROR] [mitsubishi_main-1]: process has died [pid 249198, exit code 127, cmd 'ethercat_grant /home/jose/ros2_ws/install/mitsubishi_servo/lib/mitsubishi_servo/mitsubishi_main --ros-args -r __ns:=/mitsubishi --params-file /home/jose/ros2_ws/install/mitsubishi_servo/share/mitsubishi_servo/params/mrj5n.yaml'].
jose@josel-portatil:~/ros2_ws$
As you can see, the libraries for ROS2 are correctly linked in RPATH (/opt/ros/foxt/lib) and the librcl_lifecycle.so
is in this folder. However, when running the launch with ethercat_grant
as prefix, it still fails to find the libraries.
Could I be still missing something to understand?
Thank you!
Hi everyone ! Is there any news on this issue ? I'd really like to use this on ROS2 ! Thank you for your work ! Cheers
Hi @AntoineHX !
Last time I've tried, I'm still stuck on the same issue. Using the ethercat_grant
prefix provokes that the libraries are not found.
Right now what I'm doing is using a root user directly with the SOEM module, however it is not the best solution.
I'll try to check this issue again.
Thank you for your help !
I'm also using a root user for my ethercat programs in the meantime. But it seems that the ROS2 topics (maybe service & actions too) from my ethercat program are only visible by root users (on the same PC at least). Do you also have that kind of issue, @JLBicho ?
Hi @AntoineHX
I believe it's a FastDDS issue. FastDDS is the default DDS for ROS2-Foxy so what I've done is use CycloneDDS. Check these pages for more info: https://answers.ros.org/question/371315/ros2-communication-across-multiple-local-users/ https://docs.ros.org/en/foxy/Installation/DDS-Implementations/Working-with-Eclipse-CycloneDDS.html
I hope this can help, for now, until we solve the dynamic libraries issues.
I opted for a different profile configuration for FastRTPS, seemed to be lighter changes for temporary fix, and it works for my application. Thanks a lot for pointing me in the right direction !
Hi @AntoineHX , Could you please check the URL for the profile configuration? I think it's broken and I would love to see it :)
Thanks!
Fixed !
For everybody requiring a solution for ROS2, you may have a look at https://github.com/bitmeal/cap-grant-ld though it may still be in its infancy and using a different approach from ethercat_grant. It is a wrapper to grant capabilities and preserve LD_LIBRARY_PATH
without root privileges - without baking rpath or copying of the executable.
@bitmeal that looks like a nicer solution. Thanks for sharing.
Hi @bitmeal,
First of all, thanks for the help!
I've tried your package with ROS 2 Humble and although I don't have any problem with the LD_LIBRARY_PATH
, the EtherCAT interface fails to connect without the root user.
I've followed the instructions for ROS 2 in your repo and neither using the prefix for launch or directly running ros2 run works.
Could I be missing some steps?
Thanks in advance!
@JLBicho thanks for trying and reporting back!
To keep this conversation clean and on topic for this repo, I would kindly ask you to open an issue in https://github.com/bitmeal/cap-grant-ld/issues
Hi all!
The solution from @bitmeal works perfectly in ROS 2 Foxy and Humble, so I'm going to close this issue.
Thanks for the help!
Hi all!
First of all, thank you for creating this package. It is very useful! :smile:
Currently I am working on a migration to ROS2-Foxy in a fork I've made. I am having an issue with linking the libcap-dev in the CMakeList. I've tried to summarize it here: https://github.com/JLBicho/ethercat_grant/issues/1
If anyone could help me I would kindly appreciate it.
Thanks in advance!