Python script to output MAVLink

kwagyeman, did you work up a py script to output MAVLink from the OpenMV module?

I’m one of the MAVlink contributors. What’s the use case you have in mind for this? Typically, if you want to work in MAVlink, you might be better connecting OpenMV to a Pixhawk or RaspberryPi running a native MAVLink stack such as PX4 or APM and let it do the translation.



No clue if they work. Just did them both today. I think I got the protocol right however.

Wow thanks! I’ll test them and let you know. BTW, will the scripts work with both versions the OpenMV cam (the current and the new M7)?

Just the M7 for the AprilTags one.

Did you order the OpenMV Cam M7? If so, what name is your order under? I have a few left from the initial 40 I can ship early. We’re still about 2 weeks out before the first batch of the new production run will be ready.

Yes, we did. It should be under the name Guy Power.

Awesome. So basically, each script turns the OpenMV board into a different MAVLink compatible sensor: optical flow and april tag, respectively.

I’ll try it with a Pixhawk and see if that works.

I don’t have a PixHawk to test with so, I don’t know if the scripts work. The optical flow one I think needs some work. I don’t really trust the find_displacement function. Need to work on that code. The apriltag one should work great however assuming I got the MAVLink protocol right.

Hello kwagyeman

Did initial setup and tests this morning with BBBMINI FC and I connected to QGroundControl using
UDP from my FC ethernet port and adjusted the Landing_Target (x-y) message so its spanning between -0.2 to 0.2 Rads.
Getting the Quad ready to fly with this setup, will post results pretty soon
See attached pics of setup & Message curves on the Ground Control Console.

So I got the protocol message format right?

Hello kwagyeman,

Well, you got pretty close to a perfect score :slight_smile:

The distance sensor need a single integer positive value = cm current_distance uint16_t Current distance reading
Changed this:

min(max(int(z_to_mm(tag.z_translation(), tag_size) / 10), MAV_DISTANCE_SENSOR_min_distance), MAV_DISTANCE_SENSOR_max_distance),

For this:
int(z_to_mm(tag.z_translation(), tag_size) / -10),

Getting ready for demonstration fly

Just a note concerning the Tag Distance, the new values are
Min : 30 = below 30 the Tag is exceeding the FoV
Max: 200 Over 200, the reading gets inaccurate and random, so it is limiting the landing range for a single sized Tag.

Super! Can you submit a PR for your script changes to our code base?

@kwagyeman Do you think the M7 has enough processing power to do April Tag tracking and Optical Flow at the same time ?
You said you were not happy with the OF code right now, do you have a timeline for enhancing this ?
Would it be possible to enable/disable with an incoming Mavlink message ? so the OpenMV is not running full speed all the time when we don’t need it ?

Thanks for your answers,
By the way, I ordered 2 M7 2 weeks ago for developpement with Ardupilot, do you still have stock ? or any idea of delivery date ?
Really looking forward to add the M7 to my collection of its older brothers (V1 , V2 ) :slight_smile:

Yes, but, optical flow would run at 10 FPS then which isn’t what you want. Without AprilTags it can do about 30 FPS.

As for enhancing the optical flow code, that’s next on my list of things to do after porting data matrix bar code support. That said, I’m quite busy with other things right now and it’s looking like I won’t be free until Mayish.

Disabling the code via a message code be done.

MacroFab should have produced 250 OpenMV Cams last week and will make another 250 this week. I don’t have any in stock in my ordering system yet however. Anyway, shipping for you should be done before the end of the month. I’m sorry for the wait but someone bought all the chips we use making it hard to get stock…

Hello Gentlemen,

Did some fly tests and I will need more experiments in order to make it fly properly.
Basically it is behaving like the Arruco Tag tracking, including the scarry zoom when it is loosing track.
I will step back to the blob tracking to confirm that I have an equivalent pattern before digging too deep.

Really like the flexibility of this new toy, easy to modify , just connect usb , do the mod, upload , reset and voilà :slight_smile:… and all this, done on the live quadcopter, no need to reboot (especially with this BBBMini, that generally takes 2-3 minutes)
Here is the picture of the ‘‘optical belly’’ = OpenMV , Optical Flow, Lidar Lite v3. You can see as well the ‘‘Monster Cable’’ angled microUsb that is semi-permanent, I need to find something more flexible in order not to transfert vibration.

More to come…

Cool, let me know if you need anything.

What do you mean by scarry zoom ? :slight_smile:

The Quad suddenly steer to a random direction at high speed . what Fnoop describe as a ‘’ Psychotic Wasp’’.
The problem we have here is when the tracker loose tag , it aim at the latest vector that generally is a large value of x-y vector.
This problem is less intense on the Blob Tracker… need to investigate.

@patrickpoirier51 If you hover at a low altitude (2m) can you output a good vector to target ? Can you post here a log or txt file with the X Y vector ? Are you able to to a precision loiter over the April Tag ? (you can easily add a condition to overwrite cmb_rate at 0 so it stops descending but still does precland (horizontal_control) )

Thanks :slight_smile: