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?
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
id=0) for IMU 0
SCALED_IMU2for IMU 1 (for the sensors that exist)
SCALED_IMU3for IMU2 (if there are any relevant sensors)
For our most common flight controller boards:
Acc / Gyr: ICM-20602
Acc / Mag: LSM303D
||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_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.
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:0.0.0.0:14550") def get_imu_data(): while True: msg = master.recv_match() if not msg: continue if msg.get_type() == 'RAW_IMU': data = str(msg) try: data = data.split(":") xacc = data.split(",") yacc = data.split(",") zacc = data.split(",") xgyro = data.split(",") ygyro = data.split(",") zgyro = data.split(",") xmag = data.split(",") ymag = data.split(",") zmag = data.split(",")[0:-1] except: print(data) #print(msg) print(msg) break get_imu_data()
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:0.0.0.0:14550') # Wait a heartbeat before sending commands master.wait_heartbeat() # 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('Yaw:',YAW) #print(TIME) except: print('no YAW message received') try: # acquisizione roll ROLL = master.messages['ATTITUDE'].roll print('ROLL:',ROLL) except: print('no ROLL message received') try: # acquisizione pitch PITCH = master.messages['ATTITUDE'].pitch print('pitch:',PITCH) except: print('no ROLL message received') try: # acquisizione yawspeed YAWSP = master.messages['ATTITUDE'].yawspeed print('Yawspeed:',YAWSP) except: print('no rollspeed message received') try: # acquisizione rollspeed ROLLSP = master.messages['ATTITUDE'].rollspeed print('rollspeed:',ROLLSP) except: print('no rollspeed message received') try: # acquisizione pitchspeed PITCHSP = master.messages['ATTITUDE'].pitchspeed print('pitchspeed:',PITCHSP) except: 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.