Difference between revisions of "ROS2"

From ElphelWiki
Jump to: navigation, search
(News)
 
(112 intermediate revisions by the same user not shown)
Line 1: Line 1:
==<font color='blue'>GitHub</font>==
+
==<font color='blue'>About</font>==
https://github.com/bmwcarit/meta-ros.git
+
Use ROS2 in Elphel single or multi-camera systems. The cameras are 10393 system boards based on Xilinx Zynq, ARM.
  
==<font color='blue'>ROS2</font>==
+
==<font color='blue'>Goals</font>==
 +
<font color='green'>'''Notes:'''
 +
* Controlling and initializing of multi-camera systems is already implemented using PHP API (autocampars.php), Python and lighttpd.
 +
* Using ROS2 is intended to simplify/standardize the above.
 +
* Using ROS2 is intended to make cameras compatible with other hardware supported by ROS1/2.
 +
</font>
 +
 
 +
Having ROS2 cross-compiled and installed on each camera:
 +
* '''Initialize cameras in a pre-defined multi-camera system''' - sync and sequence critical init
 +
* '''Control multiple cameras from any camera of the system''' - parameters, recording
 +
* '''Control multiple cameras from a PC''' (with ROS2 for PC installed).
 +
* '''Control multiple cameras from a network device''' (w/o ROS2 installed, but with a browser) - by accessing a web server running on a camera interfaced with ROS2 of the camera. Can use nodejs or just lighttpd+php.
 +
 
 +
==<font color='blue'>Status</font>==
 +
Development
 +
==<font color='blue'>News</font>==
 +
* [2019/01/03] Updated the cross-compiled version from '''ardent''' to '''bouncy'''. PC was already at '''bouncy''' because rclnodejs will work with '''bouncy''' only (not yet compatible with '''crystal''').
 +
Updated because ''bouncy'' would not 'see' ''ardent'' nodes & services and vice versa.
 +
 
 +
==<font color='blue'>Interfaces</font>==
 +
ROS2 nodes communicate over:
 +
* '''1 GigE LAN''' or (possibly) '''wifi''' (camera1-camera2..N, pc-camera1..N, pc1-pc2..M)
 +
* within a single device
 +
<font color='green'>'''Notes:'''
 +
* image sensors, IMS (or GPS & IMU), any other sensors are attached to cameras via a custom interface or USB, with appropriate driver support.
 +
* normally cameras in the system are synced with a custom trigger cable - this is setup over network
 +
* any device attached to PC?
 +
</font>
  
===Build===
+
==<font color='blue'>ROS2 on Zynq</font>==
 +
 
 +
===Installation===
 +
* For Embedded Linux (but not Ubuntu Distro) use [https://github.com/bmwcarit/meta-ros.git meta-ros.git]. What about <font color='red'>[https://github.com/erlerobot/meta-ros2 meta-ros2]</font>?
 +
<font color='green'><s>'''TODO:''' Include [https://github.com/bmwcarit/meta-ros.git meta-ros.git] in [https://git.elphel.com/Elphel/elphel393 elphel393] build system.</s></font>
 +
 
 +
<font color='green'>'''DONE:''' included a forked version [https://github.com/okdzhimiev/meta-ros/ okdzhimiev/meta-ros]</font>
 +
 
 +
====Include meta-ros to elphel393====
 
* Add path to bblayers.conf
 
* Add path to bblayers.conf
 
* Add to "IMAGE_INSTALL_append" of core-image-elphel393.bb:
 
* Add to "IMAGE_INSTALL_append" of core-image-elphel393.bb:
  ros2-demo-nodes-cpp \
+
  <font size='2'>packagegroup-ros2-world \</font>
  ros2topic \
+
 
  ros2msg \
+
===Notes===
  ros2run \
+
* Cross-compilation for ARM
 +
* ROS2 for python populates '''/usr/lib/python3.5/site-packages/''' so python scripts can live anywhere.
 +
* For command line apps, like ''ros2 ...'', if AMENT_PREFIX_PATH is not set then:
 +
<font size='1' color='red'>'''OSError: Environment variable 'AMENT_PREFIX_PATH' is not set or empty'''</font>
 +
* Useful commands (command line):
 +
<font size='2'>export AMENT_PREFIX_PATH=/usr</font>
 +
 
 +
<font size='2'>ros2 pkg list
 +
ros2 node list
 +
ros2 srv list
 +
ros2 srv show std_srvs/Trigger
 +
ros2 msg list
 +
ros2 msg show std_msgs/String</font>
 +
 
 +
===Demos===
 +
====talker-listener cpp====
 +
<font size='2'>''# terminal 1:''
 +
export AMENT_PREFIX_PATH=/usr
 +
ros2 run demo_nodes_cpp talker
 +
 +
''# terminal 2:''
 +
export AMENT_PREFIX_PATH=/usr
 +
ros2 run demo_nodes_cpp listener</font>
 +
 
 +
===Workflow===
 +
* Use example recipes from [https://github.com/bmwcarit/meta-ros.git meta-ros.git]
 +
* ''bitbake package-name'', check output and logs in the poky build tree
 +
* List package in core-image-elphel393.bb's ''IMAGE_INSTALL_append''
 +
<font color='green'>'''TODO:'''
 +
* Add ''target-scp'' and an example empty recipe</font>
 +
 
 +
==<font color='blue'>ROS2 on PC</font>==
 +
===Installation===
 +
* Google and follow the [https://index.ros.org/doc/ros2/ general instructions].
 +
 
 +
===Notes===
 +
* Switched to installing from a ''fat'' archive
 +
* Terminal setup:
 +
<font size='2'>''source /path/setup.bash''</font>
 +
 
 +
===Workflow===
 +
* Create a workspace
 +
* Create some packages inside or clone - they have a [https://github.com/dirk-thomas/vcstool vcs tool] to clone all repos from a text file.
 +
* Install [https://colcon.readthedocs.io/en/released/user/quick-start.html colcon]
 +
* Then build with colcon
 +
* New packages will not get installed anywhere. They live in their folders.
 +
* To use a package:
 +
  <font size='2'>source ~/ros2_ws/some-package/install/setup.bash
 +
  ros2 pkg list
 +
  then run anything in this terminal</font>
 +
* Python scripts can live anywhere - just run them from that sourced terminal
  
<font color='green'>'''Notes:'''
+
==<font color='blue'>ROS2 in Docker</font>==
* Is this a required minimum?
+
docker pull osrf/ros2:bouncy-desktop
* '''ROS_USE_PYTHON3 = "yes"''' no effect? It already uses python3?</font>
+
docker run -i -t osrf/ros2:bouncy-desktop
===Work===
+
No network, no colcon, no ament...
====1. Test Talker and Listener====
+
 
* SSH session 1:
+
==<font color='blue'>ROS2 General Notes</font>==
root@elphel393:~# export AMENT_PREFIX_PATH=/usr
+
===Notes===
root@elphel393:~# ros2 run demo_nodes_cpp talker
+
* SROS is Secure ROS or something
* SSH session 2:
+
 
root@elphel393:~# export AMENT_PREFIX_PATH=/usr
+
===Useful links===
root@elphel393:~# ros2 run demo_nodes_cpp listener
+
 
 +
* [http://docs.erlerobotics.com/robot_operating_system/ros2 ErleRobotics Tutorials on ROS2] - very useful
 +
 
 +
* [https://index.ros.org/doc/ros2/Ament-Tutorial/ Ament tutorial] - build system for new packages
 +
** works and supported in meta-ros
 +
** will not work for PC because repo hashes moved on?
  
<font color='green'>'''Notes:'''</font>
+
* [https://index.ros.org/doc/ros2/Colcon-Tutorial/ Colcon tutorial] - newest build system for new packages
* <font color='green'>If AMENT_PREFIX_PATH is not set then:</font>
+
** works for PC, even in 16.04
<font size='1'>Traceback (most recent call last):
+
** not supported in meta-ros (as of 2018/12/07)
  File "/usr/bin/ros2", line 11, in <module>
+
** [https://colcon.readthedocs.io/en/released/user/how-to.html#build-only-a-single-package-or-selected-packages colcon docs]
    load_entry_point('ros2cli==0.4.0', 'console_scripts', 'ros2')()
 
  File "/usr/lib/python3.5/site-packages/ros2cli/cli.py", line 64, in main
 
    rc = extension.main(parser=parser, args=args)
 
  File "/usr/lib/python3.5/site-packages/ros2run/command/run.py", line 59, in main
 
    executable_name=args.executable_name)
 
  File "/usr/lib/python3.5/site-packages/ros2run/api/__init__.py", line 30, in get_executable_path
 
    paths = get_executable_paths(package_name=package_name)
 
  File "/usr/lib/python3.5/site-packages/ros2pkg/api/__init__.py", line 41, in get_executable_paths
 
    prefix_path = get_prefix_path(package_name)
 
  File "/usr/lib/python3.5/site-packages/ros2pkg/api/__init__.py", line 34, in get_prefix_path
 
    prefix_path = get_package_prefix(package_name)
 
  File "/usr/lib/python3.5/site-packages/ament_index_python/packages.py", line 49, in get_package_prefix
 
    content, package_prefix = get_resource('packages', package_name)
 
  File "/usr/lib/python3.5/site-packages/ament_index_python/resources.py", line 37, in get_resource
 
    for path in get_search_paths():
 
  File "/usr/lib/python3.5/site-packages/ament_index_python/search_paths.py", line 30, in get_search_paths
 
    "Environment variable '{}' is not set or empty".format(AMENT_PREFIX_PATH_ENV_VAR))
 
<font color='red'>'''OSError: Environment variable 'AMENT_PREFIX_PATH' is not set or empty'''</font></font>
 
  
====2. Available packages====
+
* [https://discourse.ros.org/search?q=meta-ros%20order%3Alatest About meta-ros] and [https://discourse.ros.org/search?q=meta-ros2%20order%3Alatest about meta-ros2] - are they merged?
* SSH session:
 
root@elphel393:~# export AMENT_PREFIX_PATH=/usr
 
root@elphel393:~# ros2 pkg list
 
<font size='1'>builtin_interfaces
 
demo_nodes_cpp
 
example_interfaces
 
geometry_msgs
 
rcl
 
rcl_interfaces
 
rclcpp
 
rclpy
 
rcutils
 
rmw
 
rmw_fastrtps_cpp
 
rosidl_cmake
 
rosidl_generator_c
 
rosidl_generator_cpp
 
rosidl_parser
 
rosidl_typesupport_interface
 
rosidl_typesupport_introspection_c
 
rosidl_typesupport_introspection_cpp
 
sensor_msgs</font>
 
  
==<font color='blue'>ROS1</font>==
+
Networking:
  
===Build===
+
* [http://design.ros2.org/articles/ros_on_dds.html ROS on DDS]
<font color='red'>'''Won't build'''</font>
+
  <font size='2'>...
  <font size='1'>Build Configuration:
+
  if you are concerned about latency, like for soft real-time, you can basically tune DDS to be just a UDP blaster. In another scenario you might need something that behaves like TCP, but needs to be more
BB_VERSION          = "1.37.0"
+
  tolerant to long dropouts, and with DDS all of these things can be controlled by changing the QoS parameters.
  BUILD_SYS            = "x86_64-linux"
+
  ...</font>
  NATIVELSBSTRING      = "universal"
 
  TARGET_SYS          = "arm-poky-linux-gnueabi"
 
MACHINE              = "elphel393"
 
DISTRO              = "poky"
 
DISTRO_VERSION      = "2.4+snapshot-20181204"
 
TUNE_FEATURES        = "arm armv7a vfp neon cortexa9"
 
TARGET_FPU          = "softfp"
 
meta               
 
meta-poky           
 
meta-yocto-bsp      = "HEAD:72867393fe2004ab9f0ee23eb09a975c82938b9e"
 
meta-ezynq          = "rocko:046de13c06cc248b725cb7b9928f35d4a369b50f"
 
meta-elphel393      = "rocko:0cea9b9b8776f0fe725316f1be1501396c95feb4"
 
meta-ros            = "HEAD:72068b17e4192b51e09c8dc633805a35edac8701"
 
meta-xilinx-bsp      = "HEAD:a18947c20dba2c0c38db8bde1ad4684995df4bbd"
 
meta-oe             
 
meta-python         
 
meta-networking     
 
meta-webserver      = "HEAD:34aa4c3202b427f59f843dc43a4e1afda4f81d13"</font>
 
  
* Error 1:
+
* [http://www.eprosima.com/index.php/resources-all/performance/40-eprosima-fast-rtps-performance FastRTPS benchmarks]
** ROS_USE_PYTHON3 = "yes"
+
* [http://docs.eprosima.com/en/latest/advanced.html FastRTPS max message size]
** IMAGE_INSTALL += "roslaunch"
+
* [https://erlerobotics.gitbooks.io/erle-robotics-python-gitbook-free/udp_and_tcp/a_simple_tcp_client_and_server.html Good book about UDP?]
  
<font size='1'>NOTE: Resolving any missing task queue dependencies
+
ROS2 Services:
ERROR: Nothing RPROVIDES 'python3-pycrypto' (but /home/oleg/GIT/elphel393_rocko_clean_install/meta/meta-ros/recipes-devtools/python/python3-paramiko_1.16.0.bb RDEPENDS on or otherwise requires it)
 
NOTE: Runtime target 'python3-pycrypto' is unbuildable, removing...
 
Missing or unbuildable dependency chain was: ['python3-pycrypto']
 
NOTE: Runtime target 'python3-paramiko' is unbuildable, removing...
 
Missing or unbuildable dependency chain was: ['python3-paramiko', 'python3-pycrypto']
 
NOTE: Runtime target 'roslaunch' is unbuildable, removing...
 
Missing or unbuildable dependency chain was: ['roslaunch', 'python3-paramiko', 'python3-pycrypto']
 
ERROR: Required build target 'core-image-elphel393' has no buildable providers.
 
Missing or unbuildable dependency chain was: ['core-image-elphel393', 'roslaunch', 'python3-paramiko', 'python3-pycrypto']</font>
 
  
* Successful build:
+
* [https://wiki.ros.org/Services Request-Response is done with '''service''']. Format [https://wiki.ros.org/srv srv]
** IMAGE_INSTALL += "roslaunch"
+
* [https://discourse.ros.org/t/suggestions-for-std-srvs/1079/16 STD-SRVS '''discussion'''] & [https://github.com/ros2/examples/issues/4 ROS2 examples(?)]
  
<font size='1'>NOTE: Resolving any missing task queue dependencies
+
===Reference ROS repos===
ERROR: Nothing RPROVIDES 'python3-pycrypto' (but /home/oleg/GIT/elphel393_rocko_clean_install/meta/meta-ros/recipes-devtools/python/python3-paramiko_1.16.0.bb RDEPENDS on or otherwise requires it)
+
* [https://github.com/inertialsense/inertial_sense_ros.git inertial_sense_ros.git] - cpp
NOTE: Runtime target 'python3-pycrypto' is unbuildable, removing...
+
* [https://github.com/intel/ros2_intel_realsense.git ros2_intel_realsense.git] - cpp
Missing or unbuildable dependency chain was: ['python3-pycrypto']
+
* [https://github.com/ros-drivers/axis_camera.git axis_camera.git] - python
NOTE: Runtime target 'python3-paramiko' is unbuildable, removing...
+
* [https://github.com/bmwcarit/meta-ros.git meta-ros.git] - layer for Yocto
Missing or unbuildable dependency chain was: ['python3-paramiko', 'python3-pycrypto']
 
NOTE: Runtime target 'roslaunch' is unbuildable, removing...
 
Missing or unbuildable dependency chain was: ['roslaunch', 'python3-paramiko', 'python3-pycrypto']
 
ERROR: Required build target 'core-image-elphel393' has no buildable providers.
 
Missing or unbuildable dependency chain was: ['core-image-elphel393', 'roslaunch', 'python3-paramiko', 'python3-pycrypto']</font>
 
  
===Work===
+
==<font color='blue'>ROS1</font>==
* Won't work
+
<font color='red'>'''Won't build'''</font>. [[ROS1|More info]].

Latest revision as of 15:00, 3 January 2019

About

Use ROS2 in Elphel single or multi-camera systems. The cameras are 10393 system boards based on Xilinx Zynq, ARM.

Goals

Notes:

  • Controlling and initializing of multi-camera systems is already implemented using PHP API (autocampars.php), Python and lighttpd.
  • Using ROS2 is intended to simplify/standardize the above.
  • Using ROS2 is intended to make cameras compatible with other hardware supported by ROS1/2.

Having ROS2 cross-compiled and installed on each camera:

  • Initialize cameras in a pre-defined multi-camera system - sync and sequence critical init
  • Control multiple cameras from any camera of the system - parameters, recording
  • Control multiple cameras from a PC (with ROS2 for PC installed).
  • Control multiple cameras from a network device (w/o ROS2 installed, but with a browser) - by accessing a web server running on a camera interfaced with ROS2 of the camera. Can use nodejs or just lighttpd+php.

Status

Development

News

  • [2019/01/03] Updated the cross-compiled version from ardent to bouncy. PC was already at bouncy because rclnodejs will work with bouncy only (not yet compatible with crystal).

Updated because bouncy would not 'see' ardent nodes & services and vice versa.

Interfaces

ROS2 nodes communicate over:

  • 1 GigE LAN or (possibly) wifi (camera1-camera2..N, pc-camera1..N, pc1-pc2..M)
  • within a single device

Notes:

  • image sensors, IMS (or GPS & IMU), any other sensors are attached to cameras via a custom interface or USB, with appropriate driver support.
  • normally cameras in the system are synced with a custom trigger cable - this is setup over network
  • any device attached to PC?

ROS2 on Zynq

Installation

TODO: Include meta-ros.git in elphel393 build system.

DONE: included a forked version okdzhimiev/meta-ros

Include meta-ros to elphel393

  • Add path to bblayers.conf
  • Add to "IMAGE_INSTALL_append" of core-image-elphel393.bb:
packagegroup-ros2-world \

Notes

  • Cross-compilation for ARM
  • ROS2 for python populates /usr/lib/python3.5/site-packages/ so python scripts can live anywhere.
  • For command line apps, like ros2 ..., if AMENT_PREFIX_PATH is not set then:
OSError: Environment variable 'AMENT_PREFIX_PATH' is not set or empty
  • Useful commands (command line):
export AMENT_PREFIX_PATH=/usr
ros2 pkg list
ros2 node list
ros2 srv list
ros2 srv show std_srvs/Trigger
ros2 msg list
ros2 msg show std_msgs/String

Demos

talker-listener cpp

# terminal 1:
export AMENT_PREFIX_PATH=/usr
ros2 run demo_nodes_cpp talker

# terminal 2:
export AMENT_PREFIX_PATH=/usr
ros2 run demo_nodes_cpp listener

Workflow

  • Use example recipes from meta-ros.git
  • bitbake package-name, check output and logs in the poky build tree
  • List package in core-image-elphel393.bb's IMAGE_INSTALL_append

TODO:

  • Add target-scp and an example empty recipe

ROS2 on PC

Installation

Notes

  • Switched to installing from a fat archive
  • Terminal setup:
source /path/setup.bash

Workflow

  • Create a workspace
  • Create some packages inside or clone - they have a vcs tool to clone all repos from a text file.
  • Install colcon
  • Then build with colcon
  • New packages will not get installed anywhere. They live in their folders.
  • To use a package:
source ~/ros2_ws/some-package/install/setup.bash
ros2 pkg list
then run anything in this terminal
  • Python scripts can live anywhere - just run them from that sourced terminal

ROS2 in Docker

docker pull osrf/ros2:bouncy-desktop
docker run -i -t osrf/ros2:bouncy-desktop 
No network, no colcon, no ament...

ROS2 General Notes

Notes

  • SROS is Secure ROS or something

Useful links

  • Ament tutorial - build system for new packages
    • works and supported in meta-ros
    • will not work for PC because repo hashes moved on?
  • Colcon tutorial - newest build system for new packages
    • works for PC, even in 16.04
    • not supported in meta-ros (as of 2018/12/07)
    • colcon docs

Networking:

... 
if you are concerned about latency, like for soft real-time, you can basically tune DDS to be just a UDP blaster. In another scenario you might need something that behaves like TCP, but needs to be more 
tolerant to long dropouts, and with DDS all of these things can be controlled by changing the QoS parameters.
...

ROS2 Services:

Reference ROS repos

ROS1

Won't build. More info.