[Autonomous BlueROV2] MavLink/Ardusub help

Hi! I am starting a project where i will need to automatize a BlueROV2. For that i need to send basic controller commands via a script, for example up or down, and receive sensor information on the same script.
Can anyone tell me where is the best place to start? I am a bit lost in the ardusub/mavlink/qgroundcontrol documentation!

Thanks!

Hi @gilpinheiro,

You can use ROS (mavros package) or pymavlink.
Take a look in Using MAVLinks commands to intepret RC command inputs for use in ArduSub and Simulating Manual Control using Mavros, both can be useful.

What exactly do you want to accomplish ?

2 Likes

Thank you for your answer!
So the mavros package and pymavlink have the same roll right?
It will be something quite simple. We will only use the internal sensors (gyroscope, accelarometer and baromete) and we are planning to run the mission offline (no tether connected). So, the robot will need to be completely autonomous.
The mission itself will be only image capturing of the bottom of a square tank!!

  • pymavlink is a python implementation of the MAVLink protocol, actually it’s a submodule of the mavlink package.
  • mavros is a ROS-MAVLink abstraction package, it’ll provide /mavros/* topics for ROS development.

Mavros need the mavlink package (that comes with a specific version of pymavlink) to operate properly, if you need to change the mavlink or pymavlink version, in the both cases are possible.

It’s a nice project that you are working on, please feedback us with the news :slight_smile:
Are you planning to create an orthomosaic of the surface ?

1 Like

Thanks a lot for your input @patrickelectric!
Unfortunately no, it will be a rather simple project, as me and the rest of the team have a severe lack o time :frowning:
I hope to give you news soon!

1 Like

I am trying to install pymavlink on ubuntu through their installation README, but i get the following error when testing:
from pymavlink import mavlinkv10 as mavlink
Traceback (most recent call last):

File “”, line 1, in
from pymavlink import mavlinkv10 as mavlink

File “/home/gilp/anaconda3/envs/seai/lib/python2.7/site-packages/pymavlink/mavlinkv10.py”, line 10, in
from …generator.mavcrc import x25crc

ValueError: Attempted relative import beyond toplevel package

Any advice?

Can you say exactly what are you doing and which step are you in the readme ?
If you want to test pymavlink, you can try this simple udp example, if you’re not running the SITL, please change the localhost to 192.168.2.1

1 Like

SITL is a simulator right? No, i am not running it!
So, can i test without SITL or the BlueROV2 connected?
I completed the README (although not sure if i have done it correctly…) and in the installation i chose the developer option, right?

I will try the example you gave me later and give you some feedback

The best option if you want to start working with this kind of integration is with S.I.T.L (Software In The Loop), you can run ArduSub with it.

As far as I know, you’ll need something to communicate via mavlink with your code, like: BlueRov2, SITL, pixhawk and etc. SITL in the best option for development.

If you want to install pymavlink use pip: pip install pymavlink.

If you have any further question related to mavlink, check this link for FAQ, API documentation, messages and etc.

I will test the simple code you gave me today with the BlueROV and I will give you feedback later!
This is the main idea of what we want to do:

Bluerov

But there is still a lot of confusion on how to accomplish it…
Our main two doubts reside in these main points:

  • How to receive the sensor data in our python program, running in the Odroid? This program will calculate our robot current location using this sensor data received.
  • How to send (with the same python program) the location to Qgroundcontrol, that will use the already implemented auto-mode to follow the waypoints defined by a user?

The Odroid will be added in a different cylinder and will act as our computer (having ubuntu installed), running Qgroundcontrol and being connected to the ROV by the tether.

Sorry for the persistence…

EDIT: I’ve run your test code and I think pymavlink is correctly installed. Using SITL, this is what I’ve got:

Waiting for APM heartbeat
Heartbeat from APM (system 1 component 1)
HEARTBEAT {type : 1, autopilot : 3, base_mode : 81, custom_mode : 0, system_status : 3, mavlink_version : 3}

Hi @gilpinheiro,

How to receive the sensor data in our python program, running in the Odroid? This program will calculate our robot current location using this sensor data received.

With pymavlink, you can use my example as a prove of concept.
You can get more information about pymavlink api here.

How to send (with the same python program) the location to Qgroundcontrol, that will use the already implemented auto-mode to follow the waypoints defined by a user?

Probably the best idea is to use odroid as a man-in-the-middle, you can pass the data to odroid and than odroid can deal with QGC doing what you want.

EDIT: I’ve run your test code and I think pymavlink is correctly installed. Using SITL, this is what I’ve got:
Waiting for APM heartbeat
Heartbeat from APM (system 1 component 1)
HEARTBEAT {type : 1, autopilot : 3, base_mode : 81, custom_mode : 0, system_status : 3, mavlink_version : 3}

Yes, this output shows that pymavlink is working :slight_smile:

Maybe my scheme is not clear enough… I intend to run QGroundControl and also the python program (that calculates the location) in the Odroid XU4.
The main problem here is how to send a spoof GPS location to the QGroundControl, so that the ROV can enter “auto” mode and follow the waypoints defined by the user.

Thanks again for your help :slight_smile:

Sorry, my fault.

EDIT: “Probably the best idea is to use your program (with pymavlink) as a man-in-the-middle”
BlueRov2 <-> your code <-> QGC

QGroundControl is the user interface; it is not responsible for any control/autonomy. See here: https://www.ardusub.com/software/components.html

1 Like

@patrickelectric That is my goal! What i don’t know is how to make QGC assume that my robot current position is the one i calculated in my code…

@jwalser Thanks, I understand that! But as I see it, it is the easiest way to set Waypoints graphically and to start the mission, right?

@gilpinheiro take a look in SET_POSITION_TARGET_GLOBAL_INT and POSITION_TARGET_GLOBAL_INT.
You just need to get the message replace with what you want and send it to QGC or BlueRov2.

1 Like

@patrickelectric @jwalser If I send fake GPS positions to Ardusub with the commands you gave me (e.g. SET_POSITION_TARGET_INT) will this allow me to use position enabled modes?

As you can see in the figure above, it says it will only allow it if I am using a GPS antenna

Yes, but you need to use the GPS_INPUT message. The SET_POSITION_TARGET_INT is for a position target.

1 Like

So, just to set things straight… if I use GPS_INPUT message ardusub will assume I have a GPS module?

Effectively, yes. ArduSub doesn’t assume that the information is coming from a GPS antenna, but it accepts it as an alternative. You will still need a ‘positioning system’, not necessarily a GPS antenna.

1 Like