Xacc, yacc, zacc info

i had recently start a project and i was tring to implement a controller by python;
i was thinking to use the xacc, yacc, zacc data that can by export by the ardusub computer, but i have some question:
what are there mesurement units? m/s?
and they need a offset? because i see that when the rov is still i reed values different of 0

Furthermore i notify that when i run the program in pyton the qgc disconnect, but is still possible acquiring data; is normal?

Hi @fusari,

The SCALED_IMU* messages provide their acceleration values in mG, which stands for milli-gravity (1000 x 9.80665 m/s2) - when the vehicle is stationary the zacc should be approximately -1000, due to the downwards force of gravity on Earth.

The MAVLink specification does not include units for the RAW_IMU messages, so they could technically be specific to the implementation or the sensor in use.

From the ArduPilot source code it seems like ArduPilot firmwares present the IMU data with consistent scaling, via the messages

  • RAW_IMU (with id=0) for IMU 0
  • SCALED_IMU2 for IMU 1 (for the sensors that exist)
  • SCALED_IMU3 for IMU2 (if there are any relevant sensors)

For our most common flight controller boards:

MAVLink message Navigator Pixhawk
RAW_IMU Acc / Gyr: ICM-20602
Mag: MMC5983
Gyr: L3GD20H
Acc / Mag: LSM303D
SCALED_IMU2 Mag: AK09915 Acc / Gyr: MPU 6000

I believe the relevant scaling and offsets should already be applied, but you can query the values of the INS_ACCOFS_X/Y/Z and INS_ACCSCAL_X/Y/Z parameters if you want to.

Note that because the z-direction is not expected to have a 0 value, if the flight controller is at all rotated about its pitch and/or roll axes then the x and y accelerometer readings will be non-zero as well, due to gaining some component from the force of gravity.

Two programs generally cannot be connected to the same port on a computer - if you need both Python and QGroundControl to be connected to your vehicle at the same time then you should set up an additional MAVLink Endpoint for Python to connect to.

Note that if a joystick is connected to QGC it will be sending continual joystick messages, so if you also try to send some control messages from Python at the same time then they will be fighting against each other.

thx @EliotBR
so i can´t use the xacc that i read in this code to approximate the positioning and velocity of the rov in a precise istance?

from pymavlink import mavutil
master = mavutil.mavlink_connection("udpin:")

def get_imu_data():
	while True:
	    msg = master.recv_match()
	    if not msg:
	    if msg.get_type() == 'RAW_IMU':
	    	data = str(msg)
		    	data = data.split(":")
		    	xacc = data[2].split(",")[0]
		    	yacc = data[3].split(",")[0]
		    	zacc = data[4].split(",")[0]
		    	xgyro = data[5].split(",")[0]
		    	ygyro = data[6].split(",")[0]
		    	zgyro = data[7].split(",")[0]
		    	xmag = data[8].split(",")[0]
		    	ymag = data[9].split(",")[0]
		    	zmag = data[10].split(",")[0][0:-1]


plus i read the gyro data by a code like this

import time
import sys

# Import mavutil
from pymavlink import mavutil

# Create the connection
master = mavutil.mavlink_connection('udpin:')
# Wait a heartbeat before sending commands

# Request all parameters
master.mav.param_request_list_send(master.target_system, master.target_component)

try:                                            #acquisizione yaw
    YAW = master.messages['ATTITUDE'].yaw 
    #TIME = master.messages['ATTITUDE'].Time

    print('no YAW message received')

try:                                            # acquisizione roll
    ROLL = master.messages['ATTITUDE'].roll  
    print('no ROLL message received')

try:                                            # acquisizione pitch
    PITCH = master.messages['ATTITUDE'].pitch  
    print('no ROLL message received')

try:                                            # acquisizione yawspeed
    YAWSP = master.messages['ATTITUDE'].yawspeed
    print('no rollspeed message received')

try:                                            # acquisizione rollspeed
    ROLLSP = master.messages['ATTITUDE'].rollspeed
    print('no rollspeed message received')

try:                                            # acquisizione pitchspeed
    PITCHSP = master.messages['ATTITUDE'].pitchspeed
    print('no pitchspeed message received')

is possible do the same thing whit x,y,zacc? because i tried but idk how see that parametr

Hi @fusari, apologies for the delay on getting back to this.

Hopefully this comment clears up what is reasonable to expect with just IMU data. Position estimation without an external reference is not expected to work for a meaningful length of time without very high precision and frequency sensors.

I’m not sure what you mean by this. In your previous comment you were extracting the accelerometer values from RAW_IMU messages. If you’re reading messages regularly (e.g. by waiting for vehicle heartbeats, or specific messages) then the master.messages dictionary will be kept updated by pymavlink, in which case you should be able to do XACC = master.messages['RAW_IMU'].xacc, and so forth.