-
Notifications
You must be signed in to change notification settings - Fork 0
Aruco Code Detection Broadcaster #57
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
base: main
Are you sure you want to change the base?
Conversation
Started learning with Python, but realized the OpenCV docs are written in C++, and ROS also runs on CMake => Switch to C++ OpenCV. Provided code for camera calibration (default code from the OpenCV docs translated from 4.13 to 4.6.0).
The file DetectAruco.cpp provides live feed aurco code pose estimation.
…nate transforms in ROS2. Ported the old aruco C++ code to work with ROS2. Should work as long as you change the live camera link in the aruco_tf2_node.cpp. "aruco_detection" is now archived. Use "aruco_track" instead.
…ger needed after adding "aruco_track" which implements aruco pose into ROS2.
…us camera calibration code has vanished. Gonna need to be reimplemented.
jarkad
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Some comments are only there to appease my inner pedant, I've marked those with nit:. Feel free to ignore them.
TL;DR: remove .vscode/, confirm that YOLO allows redistribution.
Otherwise: LGTM, good work!
.vscode/settings.json
Outdated
| { | ||
| "cmake.sourceDirectory": "${workspaceFolder}/src/aruco_detection", | ||
| "cmake.generator": "Ninja", | ||
| "cmake.configureOnOpen": true | ||
| } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This configures CMake to build src/arudo_detection for everyone. Please remove this file.
| { | |
| "cmake.sourceDirectory": "${workspaceFolder}/src/aruco_detection", | |
| "cmake.generator": "Ninja", | |
| "cmake.configureOnOpen": true | |
| } |
.vscode/c_cpp_properties.json
Outdated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This file configures VSCode's CMake plugin, but you shouldn't use CMake directly — ROS2 doesn't like that. Please remove this file and use colcon instead.
I don't think VSCode has a plugin for colcon, though it's possible to define a task that compiles everything if that's more convenient than just using colcon in the command line.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Even if we'd use CMake directly, I still don't like this file because it hardcodes compiler location, c++ version, and include path. CMake is perfectly capable of detecting that by itself, so I'm not sure why VSCode would even create it in the first place.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I tried using the VSCode CMake plugin initially but it was very BAD. So I ended up using colcon instead like a normal human being. I just forgor to remove the plugin and the .vscode files. I'll do it soon.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: it'll be a bit tidier if you move this file into assets/images/ or something, because assets/ contains all assets: pictures, worlds, robots...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please don't put source code in the assets/ directory, it belongs in src/ instead.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
"DisplayImage.cpp" is legacy code at this point. It was using the OpenCV C++ library without ROS2. The updated ROS2 broadcaster is '/src/aruco_track/src/aruco_tf2_node.cpp'.
We can probably just remove/archive it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I see. We can just remove it then, because git will store it either way. Unless you want to reference it later?
| from ultralytics import YOLO | ||
|
|
||
| # === CONFIG === | ||
| VIDEO_URL = "https://145.126.44.42:8080/video" # your live feed |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: this has your phone's IP address hardcoded. Maybe get it from command line arguments instead? Just so you don't have to make a commit every time your phone changes its IP.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah I also find this annoying. That IP address changes every time I start the camera local server. I'll make it a command line input for now, but once we move this code to the actual rover we will use something like "cv2.VideoCapture(0)" to use the digital/depth camera streams instead.
| <depend>tf2_ros</depend> | ||
| <depend>ament_index_cpp</depend> | ||
|
|
||
|
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| /build/ | ||
| /install/ | ||
| /log/ | ||
| /src/build/ | ||
| /src/install/ | ||
| /src/log/ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
These ignores are not needed unless you run colcon in src/? I don't think there's any harm in doing so, though.
If you'd prefer to run colcon from any directory, you can remove the / in the beginning:
| /build/ | |
| /install/ | |
| /log/ | |
| /src/build/ | |
| /src/install/ | |
| /src/log/ | |
| build/ | |
| install/ | |
| log/ |
I didn't write it like that because then I'll have 3 different build directories and get confused, e.g. building in one directory and checking logs from another.
| <version>0.0.0</version> | ||
| <description>TODO: Package description</description> | ||
| <maintainer email="d.khorsun@roboteamtwente.nl">Dmytro Khorsun</maintainer> | ||
| <license>GPL-3.0-only</license> | ||
| <maintainer email="badea.andrei1908@gmail.com">andrei</maintainer> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
😺
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
tip: this file can be shortened by quite a bit if you use ament_cmake_auto, which is the One Weird Trick They Don't Tell You About in the tutorials.
Check out src/path_planning/CMakeLists.txt for an example.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If you do use the Trick, it contains this line:
install(DIRECTORY assets/ DESTINATION share/${PROJECT_NAME})It installs everything in the assets/ directory on the rover, so be sure to move any files you don't need in some other directory.
| #include "rclcpp/rclcpp.hpp" | ||
| #include "geometry_msgs/msg/transform_stamped.hpp" | ||
| #include "tf2_ros/transform_broadcaster.h" | ||
|
|
||
| #include "tf2/LinearMath/Quaternion.hpp" | ||
| #include "tf2/LinearMath/Matrix3x3.hpp" | ||
|
|
||
| #include "ament_index_cpp/get_package_share_directory.hpp" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: you can use #include <…> syntax here.
Rule of thumb: <…> is for library headers, "…" is for headers you wrote.
6ce2f56 to
c1e8d21
Compare
Implemented Aruco Detection for ROS2