Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ROS2 workspace and example nodes #256

Merged
merged 163 commits into from
Dec 23, 2022
Merged

ROS2 workspace and example nodes #256

merged 163 commits into from
Dec 23, 2022

Conversation

tsampazk
Copy link
Collaborator

@tsampazk tsampazk commented May 10, 2022

This PR contains a new ROS2 (Foxy-Fitzroy version) workspace located in the projects directory and, for now, it serves to test and finalize the structure, naming, etc., gather and finalize all ROS2 nodes in a unified PR. Right now there are no docstrings (docstrings added), documentation or READMEs. This description will get updated for any additions.

Contents:

  1. opendr_perception python package
    • Contains a pose estimation node
    • Contains fall detection node
    • Contains object detection 2d centernet/detr/ssd/yolov3 nodes
    • Contains face detection retinaface node
    • Contains face recognition node
    • Contains semantic segmentation bisenet node
    • Contains a subscriber tester node (tester), that subscribes to the messages published by the pose estimation node for
      testing
      Testing can be performed as described in steps 9 and 10 of Building and Running below.
  2. opendr_ros2_bridge python package
    • Contains bridge.py which includes a class with methods to convert images, poses, etc. from and to ROS2 messages
    • This uses cv_bridge which is included in the vision_opencv package
  3. opendr_ros2_messages CMake package

The logic behind the structuring of the packages and nodes is similar to OpenDR's ROS1 packages/nodes.

Below you can find instructions to install, build and run the nodes for testing. Note that i did everything on a system with ROS1 already installed.

I faced many issues along the way that might reappear in a fresh install of ROS2, etc., so if any problems/errors occur following the instructions please get in touch with me, to possibly save you some time.

Installation

  • To install ROS2 i followed this tutorial (section 2), which installs the 'foxy' release of ROS2. (Note that on '(7) configure environment variables', you need to replace dashing with foxy)
  • Edit: At this point you might need to run sudo apt-get install ros-foxy-vision-msgs as discussed below
  • Install colcon, basically just sudo apt install python3-colcon-common-extensions
  • Install ros2 usb cam to test with local webcam. In my case i use ros2 run usb_cam usb_cam_node_exe to run it after installation, which seems to work fine

Building and Running

  1. Navigate to your OpenDR installation and activate it as usual
  2. Navigate to workspace root, opendr_ws_2 directory
  3. Install cv_bridge via the instructions in its README, excluding the last step(build). There seems to be no need to build it, as it will get built along with the rest of the packages later.
  4. Navigate to the workspace root (opendr_ws_2) as the previous step leaves you inside vision_opencv dir
  5. Run colcon build
  6. Run . install/setup.bash
  7. Run ros2 run opendr_perception pose_estimation to start the pose estimation node (or any other existing node)
  8. In a new terminal run ros2 run usb_cam usb_cam_node_exe to grab images from a webcam
  9. In a new terminal run ros2 run rqt_image_view rqt_image_view and select the corresponding topic to view the image result
  10. In a new terminal run ros2 topic echo opendr/poses to view the pose message. Note that it is not really human readable in that form, it should be read in another node and converted into an OpenDR pose object to have access to human-friendly print methods.

* If you are using conda, check out Illia's comment down below. Thanks @iliiliiliili !

To be added

ROS2 nodes to be added according to what ROS1 nodes exist already:


Perception package:


Data generation package:


Simulation package:


Planning package:


Edit1: Updated the last steps of the instructions as well as the contents list as per the latest changes.
Edit2: Added information in contents list about the new opendr_ros2_messages. added TODO list for remaining nodes

@tsampazk tsampazk added the enhancement New feature or request label May 10, 2022
@tsampazk tsampazk self-assigned this May 10, 2022
@tsampazk
Copy link
Collaborator Author

tsampazk commented Jun 8, 2022

Hey @ad-daniel, i have started working on implementing ROS2 nodes for object detection and semantic segmentation.

Should i keep adding the new stuff on the ros2 branch and consequently on this PR, or do you think we should handle it differently?

@ad-daniel
Copy link
Collaborator

Ideally it would be better to merge a minimal version (with some changes like adding vision_opencv as a submodule, re-organize some stuff, ...) so that other partners can do their own branches from develop and begin the development in parallel. In practice however since develop is currently frozen in preparation for the release, we should probably wait for that (either way it will occur this week).

For you and others that wish to begin the ros2 development I think the best approach at the moment might be to create a branch from THIS branch. Once the release has occurred, we can do the necessary changes in this PR and merge it right after.
@passalis @stefaniapedrazzi unless you guys see a better way

@tsampazk
Copy link
Collaborator Author

tsampazk commented Jun 9, 2022

For you and others that wish to begin the ros2 development I think the best approach at the moment might be to create a branch from THIS branch. Once the release has occurred, we can do the necessary changes in this PR and merge it right after.

Alright Daniel, thanks! I also thought that might be a good potential way of doing things.

@vniclas
Copy link
Collaborator

vniclas commented Jun 20, 2022

@tsampazk thanks for your detailed instructions.
I tried following your steps but am running into the following issue ModuleNotFoundError: No module named 'vision_msgs'. Note that I am using a python virtual environment as created by the ./bin/install.sh script. Have you experienced something similar?

@tsampazk
Copy link
Collaborator Author

@tsampazk thanks for your detailed instructions. I tried following your steps but am running into the following issue ModuleNotFoundError: No module named 'vision_msgs'. Note that I am using a python virtual environment as created by the ./bin/install.sh script. Have you experienced something similar?

Hey @vniclas ! Could you run this rosdep install -i --from-path src --rosdistro foxy -y on the root workspace directory and try again?

@vniclas
Copy link
Collaborator

vniclas commented Jun 21, 2022

The tests as described in the vision_opencv/cv_bridge readme pass. Sadly, I cannot run your proposed command due to the same error cannot locate rosdep definition for [vision_msgs].
I tried rebuilding the entire OpenDR environment from scratch using this branch but it doesn't succeed anymore. However, I'm not sure that those errors are related. I'll open a bug ticket tomorrow. In a nutshell, I can't build the C++ package face_recognition anymore due to casting errors.

@tsampazk
Copy link
Collaborator Author

On my earlier deleted response i had some things mixed up, sorry, this is actually unrelated to vision_opencv.

Maybe if you still have the original installation of the toolkit saved, you try this sudo apt-get install ros-foxy-vision-msgs first, before the rosdep install... command. I think that i just missed one or both of these commands in the instructions, or mistakenly thought that they where included somewhere in the links i provided, so i omitted them. It seems curious though, because i think that @ad-daniel and @passalis both ran this successfully without mentioning anything.

If even the above doesn't work maybe you missed the steps in the ROS2 installation regarding the keys, etc.:

  1. sudo apt update && sudo apt install curl gnupg2 lsb-release
  2. curl http://repo.ros2.org/repos.key | sudo apt-key add -
  3. sudo sh -c 'echo "deb [arch=amd64,arm64] http://packages.ros.org/ros2/ubuntulsb_release -cs main" > /etc/apt/sources.list.d/ros2-latest.list'

from here steps 2 and 3 in the second section regarding ROS2 foxy installation.

If you get errors building the toolkit from scratch should be unrelated with this indeed.

@vniclas
Copy link
Collaborator

vniclas commented Jun 22, 2022

Running sudo apt-get install ros-foxy-vision-msgs solved it. Thanks! I also thought that this was included in the default installation.

tsampazk and others added 9 commits July 11, 2022 16:45
…n nodes (#273)

* Added to and from ros boxes bridge methods

* Added object detection 2d ssd node according to ros1 node

* Added object detection 2d centernet node according to ros1 node

* Added to and from bounding box list bridge methods

* Added object detection 2d detr node according to ros1 node

* Fixed some issues with type conversions in bridge

* Added object detection 2d yolov3 node according to ros1 node

* Added face detection retinaface node according to ros1 node

* Added retinaface ros2 node in setup.py

* Added semantic segmenation bisenet ROS2 node according to ROS1 node

* Added additional checks in learner download methods to stop redownloading

* Improved ROS2 packages names and bridge import

* Tester moved

* Changed bridge import and fixed some nms stuff causing errors

* Changed bridge import and made all queues 1 to avoid delays

* Minor pep8 fix

* Another minor pep8 fix

* Added licence check skip for setup.pys

* Added licence check skip for test.pys

* Added appropriate docstring on existing bridge methods

* Removed unused commented line

* Finalized ROS2 pose estimation node with argparse

* Minor formatting

* Finalized ROS2 bisenet semantic segmentation node with argparse

* Improved docstring

* Minor comment addition

* Finalized ROS2 face detection retinaface node with argparse

* Minor improvements

* Finalized ROS2 object detection 2d yolov3 node with argparse

* Finalized ROS2 object detection 2d centernet node with argparse

* Finalized ROS2 object detection 2d detr node with argparse

* Finalized ROS2 object detection 2d ssd node with argparse

* Fixed typo in package.xml description

Co-authored-by: Stefania Pedrazzi <stefaniapedrazzi@users.noreply.github.com>

Co-authored-by: Stefania Pedrazzi <stefaniapedrazzi@users.noreply.github.com>
* Fixed wrong argparse default values

* Some reordering for internal consistency and to/from face/face_id

* Initial version of ROS2 face recognition node

* Added annotated image publishing to ROS2 face recognition node

* Fixed face recognition node class name

* Fixed face recognition node class name in main

* Added ROS2 fall detection node

* Detr node now properly uses torch
@charsyme
Copy link
Collaborator

charsyme commented Aug 29, 2022

@tsampazk Is the licence of this file correct ?

# Copyright 2017 Open Source Robotics Foundation, Inc.

My implementation in #291 is failing due to not containing the usual OpenDR licence.

@tsampazk
Copy link
Collaborator Author

@tsampazk Is the licence of this file correct ?

# Copyright 2017 Open Source Robotics Foundation, Inc.

My implementation in #291 is failing due to not containing the usual OpenDR licence.

These are not OpenDR files so they contain their own licenses, which we shouldn't change. I think we could just delete them altogether, or add exceptions in the license testing as seen here for the simulation package also. Nevertheless, i think that we shouldn't put our own license on those files, as they are not are own.

@charsyme
Copy link
Collaborator

charsyme commented Aug 29, 2022

@tsampazk You are right, I didn't notice you added exceptions in checking the OpenDR licence to those files.

@ad-daniel
Copy link
Collaborator

As for the failure, from the error code it seems we are running once again out of RAM. I believe this tool was extended recently, which means two tests are occurring in the same job. We might need to split them further in the future

@tsampazk
Copy link
Collaborator Author

You beat me to it Daniel, thanks for the audio installation! 😆 I am now making the required changes in the readme.

@tsampazk tsampazk requested a review from ad-daniel December 23, 2022 15:58
Copy link
Collaborator

@ad-daniel ad-daniel left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Works for me, thank you!

@ad-daniel
Copy link
Collaborator

This PR should be reviewed in priority so that I can finalize #353 before synchronizing on master. Some missing dependencies were shadowed by the fact the test release installed multiple tools even in the separate wheel test, rather than just installing engine+tool. It might have been necessary before but doesn't seem to be the case anymore. Additionally, some issues emerge just in this scenario (typically cases where no version limits are specified). Things work if another tool indirectly sets a limit, but would break when installed on it's own.

Copy link
Collaborator

@passalis passalis left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Overall seems fine to me! Thank you all for the hard work!

@ad-daniel ad-daniel merged commit 65989cc into develop Dec 23, 2022
@ad-daniel ad-daniel deleted the ros2 branch December 23, 2022 19:53
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request test release Tests if a wheel created from a branch runs correctly test sources Run style checks
Projects
None yet
Development

Successfully merging this pull request may close these issues.