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

Bump CMake version to avoid CMP0048 warning #1

Merged
merged 13 commits into from
Jul 8, 2021

Conversation

fmessmer
Copy link

@fmessmer fmessmer commented Jan 7, 2021

@machinekoder
thanks for getting started with ros-perception#82
I'm no perception expert, but currently trying to set our robot up for Noetic and ar_track_alvar is one of our dependencies
I can confirm this branch compiles and runs under Noetic 👍

I just bumped the cmake version as suggested in the migration guide

when testing this branch (in a VM, with a rosbag), I found that sometimes /ar_pose_marker returns marker poses with nan entries - while in the next moment the detection returns the correct pose again:

  - 
    header: 
      seq: 0
      stamp: 
        secs: 1609837880
        nsecs: 549568892
      frame_id: "camera_color_optical_frame"
    id: 8
    confidence: 0
    pose: 
      header: 
        seq: 0
        stamp: 
          secs: 0
          nsecs:         0
        frame_id: ''
      pose: 
        position: 
          x: nan
          y: nan
          z: nan
        orientation: 
          x: nan
          y: nan
          z: nan
          w: nan

I don't know whether this is an issue of my testing setup (VM, rosbag) or something with the noetic-devel branch (or Noetic itself) - as the same rosbag test doesn't show this behavior under Melodic

still, do you intend to open up a PR against ros-perception, in order for ar_track_alvar to be tested by more people and finally be released?

@gtoff
Copy link

gtoff commented Jan 7, 2021

Just experienced the same behavior yesterday (in a container). Also published TFs have NaN quaternions. (Thank you for the work @machinekoder )

[ERROR] [1610030540.895047096, 39.979000000]: Ignoring transform for child_frame_id "ar_marker_7" from authority "unknown_publisher" because of an invalid quaternion in the transform (-nan -nan -nan -nan)

header: 
   seq: 72
   stamp: 
     secs: 0
     nsecs:         0
   frame_id: ''
 markers: 
   - 
     header: 
       seq: 0
       stamp: 
         secs: 39
         nsecs: 814000000
       frame_id: "arm_camera_color_optical_frame"
     id: 12
     confidence: 0
     pose: 
       header: 
         seq: 0
         stamp: 
           secs: 0
           nsecs:         0
         frame_id: ''
       pose: 
         position: 
           x: nan
           y: nan
           z: nan
         orientation: 
           x: nan
           y: nan
           z: nan
           w: nan

@fmessmer
Copy link
Author

@machinekoder @gtoff
are you aware of https://github.com/Intermodalics/ar_track_alvar/tree/noetic-devel?
I haven't tested this yet in order to see whether that branch also has the "nan"-issue...

@gtoff
Copy link

gtoff commented Jan 12, 2021

@machinekoder @gtoff
are you aware of https://github.com/Intermodalics/ar_track_alvar/tree/noetic-devel?
I haven't tested this yet in order to see whether that branch also has the "nan"-issue...

Yes indeed. That's the one I am using. Sorry, I should have mentioned it.

@smits
Copy link

smits commented Jan 18, 2021

@fmessmer , @machinekoder , we've seen these nan errors also in the kinetic-devel version. I assume it has nothing to do with the migration. This typically shows for ill-detected markers.

@gtoff
Copy link

gtoff commented Jan 18, 2021

@fmessmer , @machinekoder , we've seen these nan errors also in the kinetic-devel version. I assume it has nothing to do with the migration. This typically shows for ill-detected markers.

We're running simulations with both kinetic and noetic. With the former NaNs are extremely infrequent, while with the latter they happen often. Unfortunately, so many other components are involved (including simulated cameras) that the problem could indeed be somewhere else.

@fmessmer
Copy link
Author

@smits @gtoff
we tested this with a rosbag full of messages from a camera looking at markers...no simulated camera
and we also saw that the NaNs are much more frequent with this machinekoder/ar_track_alvar#noetic-devel branch than compared to ros-perception/ar_track_alvar#melodic-devel

@chriskeraly-rios
Copy link

I have tracked down the Nan issue and fixed this locally for individual markers by changing a few lines of code in nodes/InvididualMarkersNoKinect.cpp. Here is the fix (roughly line 112). Essentially the way the quaternions were retrieved didn't work properly.

 // Get the pose relative to the camera
    int id = (*(marker_detector.markers))[i].GetId();
    Pose p = (*(marker_detector.markers))[i].pose;
    double px = p.translation[0] / 100.0;
    double py = p.translation[1] / 100.0;
    double pz = p.translation[2] / 100.0;

    cv::Mat quat =cv::Mat(4, 1, CV_64F);
    p.GetQuaternion(quat);
    double qx = quat.at<double>(1,0); //p.quaternion[1]; #leaving these comments for the record of what was not working properly in machinekoder's version
    double qy = quat.at<double>(2,0); //p.quaternion[2];
    double qz = quat.at<double>(3,0); //p.quaternion[3];
    double qw = quat.at<double>(0,0); //p.quaternion[0];

I also modified the catch at the end of the callback to catch all exceptions, because I was randomly getting cv errors that would shut down the node, which was annoying.

catch (const std::exception& e)
{
  ROS_ERROR("Error in ar_track_alvar callback");
}

Now the node works well (albeit it seems slower than the melodic version)

Anyways, I don't have the time to go and dig deeper at the root cause of why the quaternion retrieval failed and propose a proper pull request, but this should help anyone trying to debug it, or get it running.

@miltzhaw
Copy link

I have tracked down the Nan issue and fixed this locally for individual markers by changing a few lines of code in nodes/InvididualMarkersNoKinect.cpp. Here is the fix (roughly line 112). Essentially the way the quaternions were retrieved didn't work properly.

 // Get the pose relative to the camera
    int id = (*(marker_detector.markers))[i].GetId();
    Pose p = (*(marker_detector.markers))[i].pose;
    double px = p.translation[0] / 100.0;
    double py = p.translation[1] / 100.0;
    double pz = p.translation[2] / 100.0;

    cv::Mat quat =cv::Mat(4, 1, CV_64F);
    p.GetQuaternion(quat);
    double qx = quat.at<double>(1,0); //p.quaternion[1]; #leaving these comments for the record of what was not working properly in machinekoder's version
    double qy = quat.at<double>(2,0); //p.quaternion[2];
    double qz = quat.at<double>(3,0); //p.quaternion[3];
    double qw = quat.at<double>(0,0); //p.quaternion[0];

I also modified the catch at the end of the callback to catch all exceptions, because I was randomly getting cv errors that would shut down the node, which was annoying.

catch (const std::exception& e)
{
  ROS_ERROR("Error in ar_track_alvar callback");
}

Now the node works well (albeit it seems slower than the melodic version)

Anyways, I don't have the time to go and dig deeper at the root cause of why the quaternion retrieval failed and propose a proper pull request, but this should help anyone trying to debug it, or get it running.

Great, thanks! I tested it and it worked.

To make it work with the marker bundles, similar changes are to be made to the code in the other scripts under the nodes/ folder. I tested this as well and it works now!

@machinekoder machinekoder merged commit a857aab into machinekoder:noetic-devel Jul 8, 2021
@tauzn-clock
Copy link

tauzn-clock commented Sep 20, 2022

Hello, I am still facing the same NaN issue. When trying to detect a Alvar AR tag, I encounter the following message.

header: 
    seq: 0
    stamp: 
      secs: 1663658260
      nsecs: 303707520
    frame_id: "/camera_depth_optical_frame"
  id: 1
  confidence: 0
  pose: 
    header: 
      seq: 0
      stamp: 
        secs: 0
        nsecs:         0
      frame_id: ''
    pose: 
      position: 
        x: nan
        y: nan
        z: nan
      orientation: 
        x: nan
        y: nan
        z: nan
        w: nan

I encountered the following problems when installing ar_track_alvar for ROS noetic via catkin.


[ 88%] Linking CXX executable /home/boomalope2/ar_track_ws/devel/lib/ar_track_alvar/createMarker
/usr/bin/ld: warning: libopencv_highgui.so.406, needed by /home/boomalope2/ar_track_ws/devel/lib/libar_track_alvar.so, may conflict with libopencv_highgui.so.4.2
/usr/bin/ld: warning: libopencv_calib3d.so.4.2, needed by /home/boomalope2/ar_track_ws/devel/lib/libar_track_alvar.so, may conflict with libopencv_calib3d.so.406
/usr/bin/ld: warning: libopencv_core.so.406, needed by /usr/local/lib/libopencv_calib3d.so.4.6.0, may conflict with libopencv_core.so.4.2
/usr/bin/ld: warning: libopencv_imgcodecs.so.406, needed by /usr/local/lib/libopencv_highgui.so.4.6.0, may conflict with libopencv_imgcodecs.so.4.2
[ 88%] Built target createMarker
Scanning dependencies of target trainMarkerBundle
[ 89%] Building CXX object ar_track_alvar/ar_track_alvar/CMakeFiles/trainMarkerBundle.dir/nodes/TrainMarkerBundle.cpp.o
[ 91%] Linking CXX executable /home/boomalope2/ar_track_ws/devel/lib/ar_track_alvar/findMarkerBundlesNoKinect
[ 93%] Linking CXX executable /home/boomalope2/ar_track_ws/devel/lib/ar_track_alvar/individualMarkers
/usr/bin/ld: warning: libopencv_highgui.so.406, needed by /home/boomalope2/ar_track_ws/devel/lib/libar_track_alvar.so, may conflict with libopencv_highgui.so.4.2
/usr/bin/ld: warning: libopencv_calib3d.so.4.2, needed by /home/boomalope2/ar_track_ws/devel/lib/libar_track_alvar.so, may conflict with libopencv_calib3d.so.406
/usr/bin/ld: warning: libopencv_core.so.406, needed by /usr/local/lib/libopencv_calib3d.so.4.6.0, may conflict with libopencv_core.so.4.2
[ 93%] Built target findMarkerBundlesNoKinect
Scanning dependencies of target findMarkerBundles
[ 94%] Building CXX object ar_track_alvar/ar_track_alvar/CMakeFiles/findMarkerBundles.dir/nodes/FindMarkerBundles.cpp.o
[ 96%] Linking CXX executable /home/boomalope2/ar_track_ws/devel/lib/ar_track_alvar/individualMarkersNoKinect
/usr/bin/ld: warning: libopencv_highgui.so.406, needed by /home/boomalope2/ar_track_ws/devel/lib/libar_track_alvar.so, may conflict with libopencv_highgui.so.4.2
/usr/bin/ld: warning: libopencv_calib3d.so.4.2, needed by /home/boomalope2/ar_track_ws/devel/lib/libar_track_alvar.so, may conflict with libopencv_calib3d.so.406
/usr/bin/ld: warning: libopencv_core.so.406, needed by /usr/local/lib/libopencv_calib3d.so.4.6.0, may conflict with libopencv_core.so.4.2
[ 96%] Built target individualMarkers
/usr/bin/ld: warning: libopencv_highgui.so.406, needed by /home/boomalope2/ar_track_ws/devel/lib/libar_track_alvar.so, may conflict with libopencv_highgui.so.4.2
/usr/bin/ld: warning: libopencv_calib3d.so.4.2, needed by /home/boomalope2/ar_track_ws/devel/lib/libar_track_alvar.so, may conflict with libopencv_calib3d.so.406
/usr/bin/ld: warning: libopencv_core.so.406, needed by /usr/local/lib/libopencv_calib3d.so.4.6.0, may conflict with libopencv_core.so.4.2
[ 96%] Built target individualMarkersNoKinect
[ 98%] Linking CXX executable /home/boomalope2/ar_track_ws/devel/lib/ar_track_alvar/trainMarkerBundle
/usr/bin/ld: warning: libopencv_highgui.so.406, needed by /home/boomalope2/ar_track_ws/devel/lib/libar_track_alvar.so, may conflict with libopencv_highgui.so.4.2
/usr/bin/ld: warning: libopencv_calib3d.so.4.2, needed by /home/boomalope2/ar_track_ws/devel/lib/libar_track_alvar.so, may conflict with libopencv_calib3d.so.406
/usr/bin/ld: warning: libopencv_core.so.406, needed by /usr/local/lib/libopencv_calib3d.so.4.6.0, may conflict with libopencv_core.so.4.2
[ 98%] Built target trainMarkerBundle
[100%] Linking CXX executable /home/boomalope2/ar_track_ws/devel/lib/ar_track_alvar/findMarkerBundles
/usr/bin/ld: warning: libopencv_core.so.406, needed by /usr/local/lib/libopencv_calib3d.so.4.6.0, may conflict with libopencv_core.so.4.2


Could this be causing the error? <\p>

@tauzn-clock
Copy link

Ok I think I figured out what is the issue. @chriskeraly-rios fixed the file node/IndividualMarkersNoKinect.cpp. However, the file node/IndividualMarkers.cpp also suffers from the same issue. So, if you were to apply the same chriskeraly-rios fix to IndividualMarkers.cpp, issue can be resolved.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants