Digital Shadow for a Line Following Robot; using Unity3D and ROS2

Edward Hage 5debb97ed2 readme update 4 лет назад
ROS 1fbe580ee7 first commit Unity and ROS part 4 лет назад
Unity 1fbe580ee7 first commit Unity and ROS part 4 лет назад
README.md 5debb97ed2 readme update 4 лет назад

README.md

Line Robot

Linerobot digital shadow

This repo is the development of a digital shadow in Unity3D. It concerns a Lego line follower, for which the mechanics, a similar control-algirtm for linefollowing, is implemented. This basically is a red-sensor which follows the left-side of a white line.

Remarks: The mechanics have been altered to be able to be able for the control-strategy to be succesfull. The location of the sensor has been changed. Physically a sensor between the two driven wheels will not result in a feasbily linefollower.

The sensor is achieved with a camera with a limited scope (70x70 pixels) for which all "red" pixels are averaged. Thus an average value will result (0=no red, 1 = full red). Besised the sensor (part of the sensor actually) is a red spotlight.

Additonally a normal cameraimage (jpeg-stream) is created and also a depth-image (image-stream). The images are streamed over DDS and can be observed in any application that used DDS. The format in which the images are sent are standardised ROS-messages.

ROS2 relies on DDS and the topics are read by

Hardware configuration

Windows-10 and VMware Workstation is installed on a laptop. Unity3D runs on Windows-10. A Ubuntu-VM is made with ROS2 on it (but any ROS2 instance in "the" network will suffice).

DDS

Communication of DDS is specified in a configuration file. When you run the Unity-application (in the Editor or standalone) this configuration file needs to be called first. This is done in a batch-filw which runs Vortex DDS and than Unity (must be done in the same command window).

Vortex DDS needs to be installed. See https://bitbucket.org/edhage/dds-for-unity/src/master/.

For the use of DDS in Unity an open source repo is used (see above). Be aware that here the Vortex installer is placed (so you do not have to copy it from the Adlink-website).

ROS2

https://docs.ros.org/en/galactic/Installation/Ubuntu-Install-Binary.html I installed ROS2 Galactic, but newer versions are also okay (I wrote a package but typically they can be used for any newer version). ROS2 versions start with a letter in alphabetical order, "G" for Galactic, "F" for Foxy is older. Be aware that you DO NOT INSTALL ROS. Must be ROS2. https://docs.ros.org/en/galactic/index.html

Galactic works with Ubuntu Focal (20.04.3 LTS). Recommended is to install this Ubuntu.

The package in directory ROS contains python files and C++ files. You need to build the files in the "ROS2"-way (with colcon and lots of assisting files). The python you can run without building, it will not be "known" as part of the package, but it works.

In a terminal you can already watch some topics. "ros2 topic list" will list all available topics. If you installed rqt (done by default I think) you can run the GUI (easier). "ros2 run rqt_gui rqt_gui"

CV-bridge

if you have installed the CV-bridge you can use CV in ROS2. The file "pcd_publisher_node.py" uses the CV-bridge. It subscribed to the depth_image-topic (coming from Unity) and applies a colormap to it. Than it shows the image with a colormap (depth-2-colormap).

Additionally we would be able to re-pulish the topic under another topic-name, and than it could be shown in rqt_gui.