usrl-uofsc / stag_ros

A ROS package for the Stable Fiducial Marker System
45 stars 16 forks source link

Multiple markers detection #4

Closed dorkamotorka closed 3 years ago

dorkamotorka commented 3 years ago

Is there any configuration file I could refer to, so that I will be able to detect multiple markers at the same time, that has different IDs? I could replicate the single_config.cfg pattern, but I would assume that each marker has it's own corner matrix?

MikeK4y commented 3 years ago

If you want to detect multiple markers as a single bundle then you can refer to either the bundle_config_2.yaml or bundle_config_4.yaml. A bundle of markers is a set of markers that define a single object, so there is a single object origin and the corners of all the markers should refer to that origin.

If you want to detect multiple markers individually of each other then you can add more markers in the single_config.yaml in the tag group. For example, this config file will detect the two markers in the bundle_2.bag individually:

tags:
  [
    {
      frame: "tag_27",
      id: 27,
      corners: [
        [-0.127,  0.059, 0.0],
        [-0.009,  0.059, 0.0],
        [-0.009, -0.059, 0.0]
      ]
    },
    {
      frame: "tag_63",
      id: 63,
      corners : [
        [-0.127,  0.059, 0.0],
        [-0.009,  0.059, 0.0],
        [-0.009, -0.059, 0.0]
      ]
    }
  ]
bundles:
  [
  ]

# Marker corner order:
# 1          2
#  HD########
#  #ID#  ####
#  ##  ##  ##
#  ####  ####
#  ##########
# 4          3
dorkamotorka commented 3 years ago

I assume you got a better performance(pose estimation, detection rate etc.) with the bundle of markers?

MikeK4y commented 3 years ago

Our research has showed that using bundles can increase your detection rate but it won't affect the pose estimation significantly.

It all boils down to what you are trying to do however. If you want to track a single object (e.g. a single drone), then use a single bundle with multiple markers to help the detection in different distances and points of view. If you want to track multiple objects that move independently (e.g. a swarm of UGVs), then you need to use either multiple single markers (one for each) or you can use multiple bunldes (again one on each).

Finally, using bundles means that you must be able to measure the distances between the individual markers in the bundle set. If you want to put markers around a room (to help with navigation) then this might not be practical.

dorkamotorka commented 3 years ago

I am trying to use it for the mobile robot navigation. From what I understand is there is no problem when only one marker is detected - I just add markers into the single_config.yaml and it works. What I am concerned is that even if I add the markers to the config file, when there are multiple markers detected at the same time I would assume the pose estimation is done the same as for the bundle, because there is only one tf transform seen in the Rviz and does not distinguish between the two marker, It just makes one transform and rapidly changes the transforms name(frame_id).

I would assume that the detection node, wasn't coded with that intention to detect multiple markers and distinguish them. Is that right or am I missing something?

MikeK4y commented 3 years ago

The node should be able to track multiple markers and multiple bundles in a single frame.

I just used the attached config file in my first comment here to run the bundle_2.bag and I used rosrun tf view_frames to get the following tf tree:

frames.pdf

There are two tfs to the camera link one for each marker.

Check that your config file is correct and if the problem persists then record everything in a bag and upload it here

dorkamotorka commented 3 years ago

As you have pointed out, the transform are there when I run rosrun tf view_frames, but if you look into Rviz, the transformations seems to be in the same place. I am adding the video of the "problem" and the configuration files. image image stag_multiple_detect.mp4.tar.gz

dorkamotorka commented 3 years ago

Video is included in the compressed file.

MikeK4y commented 3 years ago

@tp4348 Turns out that every new marker was overwriting its pose on the previous ones. Thanks for catching this.

The last commit should fix the issue. Please check on your end and let us know.

ri-ceres commented 3 years ago

I also experienced this issue, and can confirm that https://github.com/usrl-uofsc/stag_ros/commit/3f372626543f3ab26db109b3bd479adb38eebf44 fixed it.

Brenn10 commented 3 years ago

@tp4348 please let us know if this works for you. If so, feel free to close this issue. Thanks for the help with debugging :smile:

dorkamotorka commented 3 years ago

Yes it's working. Nice, thank you!