Go to Waypoint & Follow Terrain via pymavlink

Good morning,

I’m getting so close to having my entire system completed and getting really exited about doing the full testing of the system and getting into the field. My physical build is complete and the software is really close. Here’s where I am and I’m hoping someone can offer some guidance on the best way to move forward.

I want my BlueROV2 to navigate to a specific waypoint while following the terrain and keeping a height above the bottom at 2m. I will be providing the waypoints via a python script that generates my grid search pattern. I’ve got an Airmar DT800 installed in a tube that should hopefully work even at depth though I’m working very shallow at the moment. The DT800 is plugged into the companion computer via a USB/Serial adapter and a python script is processing that data and sending it out over MavLink every 0.5 seconds using code based off of the example in the Ardusub Gitbook. Additionally, I have the WaterLinked GPS setup so the ROV should know its depth, height, and position. What I want to be able to do is to tell the ROV to perform a transect to a specific GPS point while keeping a height hold over the terrain. Clearly this is two different flight modes, Depth Hold and Guided which I’m assuming is a no go.

Assuming that I can’t just tell the ROV to go to a point holding a specific height/depth, then I have to get creative. My understanding is that when I give the ROV an GPS point to navigate to that includes a Lat, Lon, and Alt (depth). My first problem is that the depth at that location is unknown. In fact, I don’t care about the depth, just the height from the bottom. Fortunately, in these transects, I’m not dealing with huge changes in depth, probably a meter, maybe 2 at the most. So, my thought is that when I send the waypoint data, I will just use the current depth of the ROV as a starting point.

My problem is then how do I make the ROV follow the terrain at 2m during the transect. One thought is to monitor the height during the transect and then update the destination waypoint with the appropriate depth as it changes to maintain height. However I think that will only result in a gradual change of height assuming it changes over the course of the entire distance of the transect. If I have a coral head or big head of seaweed show up then I don’t want such a gradual change.

The next step I can think of is to go one of two routes using Guided Mode for navigation and then either send RC Input simulating the joystick or manual control to move the ROV up or down in small steps until the appropriate depth is reached. I’m not sure if this is doable while in Guided mode.

Does anyone have any thoughts or suggestions on what might be the best approach?

Thank you!

The autonomous/gps enabled modes are not stable, but have been demonstrated. They are basically for developer use only right now, so there is not a lot of information and you will need to look at the source code to see exactly how it works. You should be able to use auto mode for the way points and the altitude frame specified as ‘altitude above terrain’ for the terrain following.

Thanks Jacob. I’ll dig into the source code and see what I can figure out. I suppose another option would be to forgo the gps modes and use depth/height hold mode and then basically use my own code to poll the current gps mode, set a heading, drive forward, poll the gps, and repeat. Basically that would be writing my own guided mode. Is it possible to set a heading using the onboard IMU/Compass via pymavlink. I recall seeing a post about that (Sending MAVProxy messages from a python program? - #32 by jwalser). If I’m understanding that correctly, I can’t set heading to 37° but that I would poll the ROV and get the current heading, then apply yaw to adjust the heading, poll the ROV for the heading again, and keep adjusting until it matches and then set yaw to 0. Would this be a better option? Basically it reverses my plan and uses the more stable depth hold mode to fly straight and follow the terrain and then i change my heading/bearing in order to get to my coordinate.

Thanks again for your help! I’ve got 4 days this week dedicated to sitting next to a pool and get this all figured out.

The heading target can be sent in guided mode. It cannot be sent without a gps system at the moment, that is the limitation. The process you describe to set the heading target manually/incrementally will work too.

I think if you have the gps system, you should try the gps modes. If you are looking at mavlink and writing pymavlink programs, that makes you a developer :).

Thanks Jacob. I’l go with the guided modes. I’ve been hesitate to do much of that sort of work since I have’t had a place to put the ROV in the water (I live on the 12th floor of an apartment building). I am driving today to visit family where I have access to a pool so I will have the next 4 days dedicated to the final programming. I already have the software written that will feed the waypoints to the ROV, I just have to actually write the code for that. Right now my software just pauses for a few seconds to simulate the ROV traveling to the next waypoint.

I’ve got Mavproxy installed and am ready to sit down and test with the ROV in the water and get it all figured out. My pile of batteries also just arrived this morning so I should have plenty of time/power to do it over the next few days.

Thanks for your help!

Also try software in the loop simulation for development. A real-world test is the best, but when it’s inconvenient, SITL will be able to provide most functionality for a lot of development purposes.

Will do!