ros-perception / ar_track_alvar

AR tag tracking library for ROS

Home Page:www.ros.org/wiki/ar_track_alvar

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Release ar_track_alvar into ROS Noetic?

sloretz opened this issue · comments

Would you mind releasing ar_track_alvar to ROS Noetic? It looks like all of its dependencies have been released, and recursively 14 repos need it.

I'm not sure how much work it will need. The Noetic Migration Guide or the guide about transitioning ROS packages to Python 3 may be useful.

ar_track_alvar doesn't use Python, so it's only a matter of publishing the package.

ar_track_alvar doesn't use Python, so it's only a matter of publishing the package.

modulo the port to OpenCV4..

@jspricke The API changes between OpenCV3 and 4 seem trivial. Once I have noetic running here I can give it a shot.

@machinekoder are you still working on this?

@wmmc88 I'm going for it next week as we finally moved to noetic.

Turns out porting is not as easy as first thought. ar_track_alvar uses the long dead C API for OpenCV. So conversion to the C++ is needed along the CV3→CV4 port which is small. Moreover, there has been a deprecation of some Eigen types in noetic, which we have to keep in mind, but nothing significant either. So the core effort of porting ar_track_alvar lies in converting the OpenCV C API calls with their C++ API equivalents. Easier said than done, I couldn't find nice porting guide, so this will require some manual lookup old API and replace procedure.

Turns out porting is not as easy as first thought. ar_track_alvar uses the long dead C API for OpenCV. So conversion to the C++ is needed along the CV3→CV4 port which is small. Moreover, there has been a deprecation of some Eigen types in noetic, which we have to keep in mind, but nothing significant either. So the core effort of porting ar_track_alvar lies in converting the OpenCV C API calls with their C++ API equivalents. Easier said than done, I couldn't find nice porting guide, so this will require some manual lookup old API and replace procedure.

Thanks for looking into this. Have you been able to make some progress?

@ajithcodesit I'm at it. There is quite a lot cv code in there that needs to be translated.

Here is my WIP, I already have it working: https://github.com/machinekoder/ar_track_alvar/tree/noetic-devel

There is quite some potential of reworking parts of the code aside from the port.

any chance this is going to get merged in and released?

looking at the Network of this repo ros-perception/ar_track_alvar, it looks like development of this repos has diverged onto forks
is this repo still actively maintained?

@130s you have the last commit to this repo
@sniekum are you still involved?
@sloretz do you know who maintains ros-perception?

I also see that Intermodalics has a noetic-devel branch, which sees recent contributions, e.g. Intermodalics@dcc8c40

@smits what is different between your version of Intermodalics/ar_track_alvar#noetic-devel and machinekoder/ar_track_alvar#noetic-devel

are you also experiencing the "nan"-issues mentioned in machinekoder#1 (comment)?

@fmessmer , I did not know of the machinekoder/ar_track_alvar#noetic-devel when I started my attempt. We're definitely not close to something that works. So I might consider taking a look at what machinekoder is doing.

Here is my WIP, I already have it working: https://github.com/machinekoder/ar_track_alvar/tree/noetic-devel

There is quite some potential of reworking parts of the code aside from the port.

@machinekoder I tried your WIP but I am not able to compile it with catkin_make

The machinekoder repo almost works well, however, if you look at some comments on this (unrelated) issue machinekoder#1 , you will notice that there is a problem where nan is published for a lot of the results. I have tracked down the 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.

@chriskeraly-rios
could you point us to proper commit/branch which contains your fix? or provide and link a pr, please - so people can build on top of your work and test it...

https://github.com/rios-ai/ar_track_alvar/tree/feature/rios_bug_fix

Here you go. As I said, this is probably not the "proper" way to fix it, but it gets the job done for what I need.

@chriskeraly-rios @machinekoder are either of you planning to make a noetic-devel PR? I see @haraisao also has a PR for a noetic devel branch.

Sorry for beginner question,
How to install @machinekoder 's ar_track_alvar?
Thank you

@cybernetchi

You can build his repo from source.

In your workspace:

$ git clone https://github.com/machinekoder/ar_track_alvar.git -b noetic-devel

Build with colcon

$ colcon build

Thank you @pmusau17 I successfully built in ROS noetic as well.

@cybernetchi

You can build his repo from source.

In your workspace:

$ git clone https://github.com/machinekoder/ar_track_alvar.git -b noetic-devel

Build with colcon

$ colcon build

you can also just use catkin_make

@machinekoder Thank you for releasing your code.
I tried your code on Ubuntu 20.04. However, I had a following error.

[ERROR] [1668810254.584122576]: Error in ar_track_alvar callback: OpenCV(4.5.4) /home/ubuntu/build_opencv/opencv/modules/core/src/matrix.cpp:250: error: (-215:Assertion failed) s >= 0 in function 'setSize'

How can I solve this issue??

@NHirose I got the same error on a Jetson Xavier NX/Jetpack 5.0.2. Fore some reason I got installed OpenCV 4.5.4 and 4.2.0. Uninstalled and reinstalled noetic-desktop-full but got the same problem. In my case I added the following to force 4.2.0 usage for libopencv_core.

export LD_PRELOAD=/usr/lib/aarch64-linux-gnu/libopencv_core.so.4.2.0

Switched to this branch. There should be a better way to do it, at least this way got the job done, hope it helps on your environment, regards

I cannot recognize the string type QR code when using ar_track_alvar, I have completed the camera calibration, and it can recognize the QR code with ID 0.

I don’t know why this is.