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

USB camera nodelet, monocular tag detector nodelet, corresponding navigation states #640

Merged
merged 2 commits into from
Apr 29, 2024

Conversation

alisonryckman
Copy link
Contributor

@alisonryckman alisonryckman commented Feb 3, 2024

Summary

#567, #607

What features did you add, bugs did you fix, etc?

  • New nodelet for long range usb camera
  • New long range tag detector nodelet
  • Refactoring tag detection into zed tag and long range tag
  • LongRangeState, ApproachObjectState, and ApproachTargetBaseState

Did you add documentation to the wiki?

No

How was this code tested?

Tested in sim and with the physical long range camera to verify detection distances

Did you test this in sim?

Yes

Did you test this on the rover?

No

Did you add unit tests?

No

Copy link
Collaborator

@ankithu ankithu left a comment

Choose a reason for hiding this comment

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

didn't have time to finish reviewing the whole thing but here are some initial comments for some of it

launch/long_range_cam.launch Outdated Show resolved Hide resolved
src/navigation/context.py Outdated Show resolved Hide resolved
src/navigation/context.py Outdated Show resolved Hide resolved
src/navigation/context.py Outdated Show resolved Hide resolved
src/navigation/context.py Outdated Show resolved Hide resolved
src/navigation/context.py Outdated Show resolved Hide resolved
Copy link
Collaborator

@ankithu ankithu left a comment

Choose a reason for hiding this comment

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

a few more comments. Still not through the whole thing.

Copy link
Collaborator

@ankithu ankithu left a comment

Choose a reason for hiding this comment

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

a few more comments

src/navigation/context.py Outdated Show resolved Hide resolved
src/navigation/approach_object.py Outdated Show resolved Hide resolved
src/navigation/approach_target_base.py Outdated Show resolved Hide resolved
src/navigation/approach_post.py Outdated Show resolved Hide resolved
src/navigation/long_range.py Outdated Show resolved Hide resolved
src/navigation/search.py Outdated Show resolved Hide resolved
src/navigation/waypoint.py Outdated Show resolved Hide resolved
src/navigation/waypoint.py Outdated Show resolved Hide resolved
src/navigation/navigation.py Outdated Show resolved Hide resolved
src/perception/long_range_cam/long_range_cam.cpp Outdated Show resolved Hide resolved
src/navigation/long_range.py Outdated Show resolved Hide resolved
src/navigation/search.py Outdated Show resolved Hide resolved
mImgPub = mNh.advertise<sensor_msgs::Image>("long_range_image", 1);
// While dtor not called
while (ros::ok()) {
cv::VideoCapture mCapture{std::format("v4l2src device=/dev/arducam ! videoconvert ! video/x-raw,width={},height={},format=I420,framerate={}/1 ! appsink", 1920, 1080, 5), cv::CAP_GSTREAMER};
Copy link
Collaborator

Choose a reason for hiding this comment

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

port should be a rosparam

Copy link
Collaborator

Choose a reason for hiding this comment

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

The topic name should also be a rosparam

if (frame.empty()) {
break;
}
cv::imshow("Sender", frame);
Copy link
Collaborator

Choose a reason for hiding this comment

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

we should add an option to disable this right

Copy link
Contributor Author

Choose a reason for hiding this comment

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

i just deleted it lol cuz it'll get published to ros anyway

src/navigation/search.py Outdated Show resolved Hide resolved
src/navigation/waypoint.py Outdated Show resolved Hide resolved
src/navigation/waypoint.py Outdated Show resolved Hide resolved
src/navigation/context.py Outdated Show resolved Hide resolved
src/navigation/context.py Outdated Show resolved Hide resolved
src/navigation/context.py Outdated Show resolved Hide resolved
src/navigation/context.py Outdated Show resolved Hide resolved
Copy link
Collaborator

@ankithu ankithu left a comment

Choose a reason for hiding this comment

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

few more comments, almost there!

@@ -0,0 +1,86 @@
#include "long_range_cam.hpp"
#include <opencv2/imgproc.hpp>
Copy link
Collaborator

Choose a reason for hiding this comment

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

All include should go into the "pch.hpp" file

If you are curious, this is called a pre-compiled header and it speeds up successive compilations.

try {
mGrabThread = std::jthread(&LongRangeCamNodelet::grabUpdate, this);
} catch (std::exception const& e) {
NODELET_FATAL("Exception while starting: %s", e.what());
Copy link
Collaborator

Choose a reason for hiding this comment

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

This won't ever get called. Starting a thread always works, and you can't catch exceptions that other threads throw. They have their own stack.

}

void fillImageMessage(cv::Mat& bgra, sensor_msgs::ImagePtr const& msg) {
assert(msg);
Copy link
Collaborator

Choose a reason for hiding this comment

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

I would add a couple of asserts. You need to make sure that bgra is continous (i.e. it is not a slice, bc then you can't just memcpy), and more importantly check the opencv mat type

Copy link
Collaborator

Choose a reason for hiding this comment

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

Also, shouldn't bgra be renamed to bgr?

}
}

void fillImageMessage(cv::Mat& bgra, sensor_msgs::ImagePtr const& msg) {
Copy link
Collaborator

Choose a reason for hiding this comment

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

bgra can be ref to const

mCamInfoPub = mNh.advertise<sensor_msgs::CameraInfo>("long_range_cam/camera_info", 1);
mImgPub = mNh.advertise<sensor_msgs::Image>("long_range_image", 1);
// While dtor not called
cv::VideoCapture mCapture{std::format("v4l2src device=/dev/arducam ! videoconvert ! video/x-raw,width={},height={},format=I420,framerate={}/1 ! appsink", 1920, 1080, 5), cv::CAP_GSTREAMER};
Copy link
Collaborator

Choose a reason for hiding this comment

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

m prefix is only used for member variables

while (ros::ok()) {
// while (true) {
mCapture.read(frame);
if (frame.empty()) {
Copy link
Collaborator

Choose a reason for hiding this comment

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

What is the failure condition of cv::VideoCapture? I feel like this should be an exception if empty

mCamInfoPub = mNh.advertise<sensor_msgs::CameraInfo>("long_range_cam/camera_info", 1);
mImgPub = mNh.advertise<sensor_msgs::Image>("long_range_image", 1);
// While dtor not called
cv::VideoCapture mCapture{std::format("v4l2src device=/dev/arducam ! videoconvert ! video/x-raw,width={},height={},format=I420,framerate={}/1 ! appsink", 1920, 1080, 5), cv::CAP_GSTREAMER};
Copy link
Collaborator

Choose a reason for hiding this comment

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

I would make the device file configurable, same with the width and height (use rosparams). That way we can use this node for the other USB cams.

@qhdwight
Copy link
Collaborator

Great job, thank you for getting it working!

The processing files look great.

However I am a little worried about the duplicate code between long_range_tag_detector.cpp and tag_detector.cpp. They are almost identical. Perhaps after SAR I or y'all can refactor this.

@qhdwight
Copy link
Collaborator

I think a solution could be making a base class between the long range detector and the zed detector. the onInit function could be shared. What do people think?

@qhdwight qhdwight changed the title Long range cam and long range ARTag detector nodelets + new navigation states USB camera nodelet, monocular tag detector nodelet, corresponding navigation states Mar 3, 2024
@qhdwight qhdwight force-pushed the integration branch 5 times, most recently from 8e721f6 to 65c9dc9 Compare April 19, 2024 04:46
@qhdwight qhdwight merged commit d44fa8c into integration Apr 29, 2024
1 check failed
@qhdwight qhdwight deleted the percep-second-cam branch April 29, 2024 17:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

8 participants