sourcebots / robot-api

(Legacy) API to interface with robotd
http://docs.sourcebots.co.uk/api/
MIT License
4 stars 1 forks source link

Vision API distance_metres behaving weirdly #52

Closed mxbi closed 6 years ago

mxbi commented 6 years ago

Hi, it's me again :)

We've been playing around with the vision API and some of the behaviour is a bit unusual, so I thought I would flag it up here:

The value of marker.distance_metres varies by a huge amount when calling camera.see() in a loop even when the entire scene is static, and I'm not sure why. When looking at marker.pixel_corners or marker.pixel_centre I can see that the values are staying constant (changing than less than 1 pixel),

Here's an example of what I mean:

image

You can see that the distance is all over the place (varying from 20 to 140 metres in this case), but the values of the detected centre and top left corner barely change by a single pixel. And if I manually superimpose the detected co-ordinates on an image taken from the webcam, it lines up basically perfectly - so the detection isn't incorrect - the issue is somewhere in the distance calculation I guess.

This also behaves differently on different tags: I'm testing on cube ID 44, and most of the faces give a distance varying between 1 and 8 metres (the real distance is about 2m). However, there is one specific face which is giving me the 20 to 140m in the plot above:

image

I also found something which might be causing the issue: Looking in robotd, the DISTANCE_MODEL is set to "c270" (https://github.com/sourcebots/robotd/blob/master/robotd/camera.py#L19). The camera we've been given is a Tecknet C016 and not a logitech c270. I haven't looked any deeper so I have no idea what this would affect, but it's suspicious.

Adimote commented 6 years ago

Hi, you're exactly correct with this, however it was not accidental. We initially shipped kits with an older training model for distances because there was an error with our measurements for the C016 data. We've fixed it and are verifying for shipping it on Monday.

mxbi commented 6 years ago

Hi @Adimote Is this fixed in the update you pushed out?

distance.metres, while changing less dramatically, is still giving us wildly incorrect results. For example, when this is the view of the camera: image

We are getting ~160 metres from marker.distance_metres

mxbi commented 6 years ago

Hi,

Just noticed that even after the update distance_metres still gets the value from the polar co-ordinate system, and not the supposedly fixed spherical coordinate system:

https://github.com/sourcebots/robot-api/blob/master/robot/markers.py#L132-L134

Should this be changed to access the spherical system instead?

RealOrangeOne commented 6 years ago

Yes, you are correct. This is an oversight on our part. I'll fix that now!

RealOrangeOne commented 6 years ago

The issue with getting the data from polar rather than spherical has been fixed (even though they do the same thing). The issue with its inaccuracies are still being worked on. Reopening this issue to track those.

mxbi commented 6 years ago

Can confirm this issue has been fixed with the recent overhaul to sb-vision, closing. :)

I will note however that the values we've obtained out of distance_metres with the new software has been off by a constant factor (around 1.14*actual distance) - we're correcting for this in our software but it may be something to look into.