# Position mode works, but offboard mode don't

Source: https://forum.modalai.com/topic/3042/position-mode-works-but-offboard-mode-don-t
Category: General Questions (https://forum.modalai.com/category/2/general-questions)
Posted: 2024-01-23 08:42:54 UTC by Dawid Mościcki
Replies: 32 · Views: 10484

## Dawid Mościcki · 2024-01-23 08:42:54 UTC

Hi, 
We're using seeker dev kit. We calibrated it for visual odometry without using GPS (indoor mode)
Drone works great when stearing it from aparature in Position mode (there is no visible drift).
After sending command via mavros (offboard mode) even simple as vel_cmd (x:0, y:0, z:2) drone is unable to take off vertically and we must use kill switch, because he's trying to move horizontally for no reason.
What should we do if we cant make it to navigate it in offboard mode ?
Best regards,
Dawid

## Reply by Zachary Lowell 0 · 2024-01-25 16:45:54 UTC

@Dawid-Mościcki how are you connecting to the system instance - over udp on port 14550? I would recommend swapping to mavSDK instead of mavros as ros1 is depracated. Please check out the documentation here:

https://docs.modalai.com/mavsdk/

## Reply by Dawid Mościcki · 2024-01-25 20:44:21 UTC (in reply to Zachary Lowell 0)

@Zachary-Lowell-0 i'm not sending commands in offboard mode via voxl2. voxl2 is connected over wifi to our PC, PC is running ros noetic with mavros instance and sending commands over wifi-telemetry

## Reply by Zachary Lowell 0 · 2024-01-29 16:24:05 UTC

Got it - what on the voxl2 side is ingesting these commands and pushing them into the PX4 instance? As for the horizontal drift, I would recommend seeing if you were to do a simple takeoff and land in offboard mode via MAVSDK if the same issue persists (which can be programmed onboard the voxl2). Can you show your initial code that swaps it into offboard mode? Are you sending initial 0's for the setpoint then starting offboard mode, then consistently sending in setpoints post start?

## Reply by Zachary Lowell 0 · 2024-01-29 17:28:17 UTC

Also can you try your code in HITL to see if you get the same reactions?

## Reply by Dawid Mościcki · 2024-02-04 20:57:07 UTC

"Got it - what on the voxl2 side is ingesting these commands and pushing them into the PX4 instance? "
Sorry, but i assumed that i could just send it via wifi telemetry directly to px4 via mavros and it should work. I will try again with using voxl2 instead. Could You link me any tutorial how to do it ? it's my first time using this product ... This will be good ? https://docs.modalai.com/mavros/ 
Thanks and best regards :)

## Reply by Zachary Lowell 0 · 2024-02-05 17:23:27 UTC

Sorry I think I misunderstood your architecture. You should be able to probe PX4 from a traditional mavros packet over the wifi telemetry. I am assuming you are connecting over something like "/dev/ttyUSB0" or something like that? If not, then I am guessing you are connecting over a port like 14550 and not using QGC?

Would you mind posting some of your code so I could see what you are relaying to the PX4 instance - Are you sending in an initial 0's setpoint prior to starting the offboard mode?

## Reply by Zachary Lowell 0 · 2024-02-05 18:21:03 UTC

Are you using QGC - and if so, can you turn it off and then test offboard? There could be conflicting packets or interaction between the px4 instance and qgc. If not, please make sure the initial setup for offboard mode is set points of 0's and if you can run voxl-mavlink-server in debug mode from the command line interface.

Can you takeoff in position mode and swap to offboard mode mid flight and hold position or something of that nature as well?

The thing that is most likely the issue I believe is voxl-vision-hub. There is a program in vision-hub that will automatically do a figure 8 in offboard when it gets kicked off programatically and this is most likely conflicting with your takeoff. The parameters you needs to disable in `/etc/modalai/voxl-vision-hub.conf` are:

`offboard_mode: off`

Hopefully this works - keep us posted!

## Reply by Dawid Mościcki · 2024-02-06 08:56:17 UTC (in reply to Zachary Lowell 0)

@Zachary-Lowell-0 
Thanks for help ! i set offboard_mode: off.
Steps i took : 
1. create simple ros noetic mavros publisher that will set offboard, arm drone, and publish on local_position (0,0,1.5) and orientation (w:1,0,0,0). 
2. Drone armed, spinned motors and after 1s go back to position mode when armed that causes drone to lift off and crash :/ I broke one of landing gear so i hope i can 3D print it and  it will be fine.

We have some problems now with VOXL ESC :/ For some reason when i inspect mavlink via QGC (command voxl_esc status) its returning failure (-1). After restarting it via battery few times sometimes it starts working again and sometimes dont :/ 

What could be reason for that ? Do You have any more tips or stepps for debbuging this ? 

Thanks again :)

I will post code and steps later this day hopefully :)

## Reply by Zachary Lowell 0 · 2024-02-06 16:07:29 UTC

Dang! @Dawid-Mościcki to stay in offboard mode you need to consistently be feeding into the PX4 instance setpoint commands or else it will fall back to position mode. Once you changed the offboard_Mode to off, did you restart voxl-vision-hub and or reboot the voxl2? 

@Alex-Kushleyev looks like they are having some ESC trouble - any recommendations?

## Reply by Alex Kushleyev (ModalAI staff) · 2024-02-06 17:24:14 UTC (in reply to Zachary Lowell 0)

@Dawid-Mościcki ,

Let's do a quick check of ESCs. Please follow this procedure:
```
#stop px4 which will conflict with ESC tools
systemctl stop voxl-px4

#udpate voxl-esc tools to get the latest (if you have internet connection)
apt-get update
apt-get install voxl-esc

#run ESC scan
cd /usr/share/modalai/voxl-esc-tools/
./voxl-esc-scan.py
```
This should detect the modalai ESCs without using PX4. Hopefully there is no issue in doing that, please let us know.

## Reply by Dawid Mościcki · 2024-02-11 18:31:21 UTC (in reply to Alex Kushleyev)

@Alex-Kushleyev 
I tried to update voxl-esc, but its already newest version ...
I 3d printed drone's skid and fly tested. Drone was having trouble with managing constant altitude, and when trying to land (it was on the ground) somehow flew up to 1.5m and made rapid descend to ground and crashed. Could You help me review this issue ? This is link to logs, params, and esc output on gdrive : [link](https://drive.google.com/drive/folders/17GsJ5_WYzPcv-YtNlYX5l_9kFVGN9ChG?usp=sharing)

It was very strange ... I'm almost certain that we got a bug in params at this point. 

Best regards

## Reply by Alex Kushleyev (ModalAI staff) · 2024-02-12 15:17:05 UTC (in reply to Dawid Mościcki)

@Dawid-Mościcki , i took a look at the log, the ESC performance looks good. I do see the jump at the end, which you described, but it is not clear to my why this happened.

@Zachary-Lowell-0 , any suggestions how to diagnose further? Position and offboard mode use VIO, for x-y-z control, right? (sorry if I am off, not entirely familiar). Can we log and look at VIO quality?

## Reply by Dawid Mościcki · 2024-02-19 08:51:13 UTC (in reply to Alex Kushleyev)

@Alex-Kushleyev Any updates on reviewing this issue ? TBH i'm scared to take off this drone from ground again without finding cause of that strange behavior ...

## Reply by Zachary Lowell 0 · 2024-02-19 20:58:36 UTC

@Alex-Kushleyev said in [Position mode works, but offboard mode don't](/post/14703):
> for

@Dawid-Mościcki I would say it is safe for now to just fly via position mode or mannual mode and have a kill switch linked to the rC controller. Then you can try swapping over to positio mode. Then try your offboard code. 

If the esc chimes when booted then it is getting the right data to control the motors.

## Reply by Dawid Mościcki · 2024-02-20 18:34:21 UTC (in reply to Zachary Lowell 0)

@Zachary-Lowell-0 that crash happened in position mode .......

## Reply by Zachary Lowell 0 · 2024-02-23 18:44:21 UTC

Got it - if you are certain this is an issue in the parameters of PX4, you can reconfigure the MPA to match that of the m500 - just run `voxl-configure-mpa` and it will then ask for the drone you are using. Then it will parse through all the config files for the m500 and setup the MPA and px4. Then reboot and everything should be back to factory defaults.

## Reply by Dawid Mościcki · 2024-03-12 17:49:24 UTC (in reply to Zachary Lowell 0)

@Zachary-Lowell-0 
I did it, and configured drone accordingly to https://docs.modalai.com/flying-with-vio/ so that drone could fly without GPS.
Drone can't fly at all, doesnt respond to stick inputs, logs : https://review.px4.io/plot_app?log=f4e0abee-f370-4932-91c4-2e19aa6e66cf
Vibration metrics is too high, what can we do ? 
Please help :/

## Reply by Dawid Mościcki · 2024-03-12 18:02:45 UTC (in reply to Dawid Mościcki)

@Dawid-Mościcki Any 3D files for this drone are available for download ? For example landing skid ?

## Reply by Dawid Mościcki · 2024-03-12 20:43:09 UTC (in reply to Dawid Mościcki)

@Dawid-Mościcki i don't even know how's that possible https://review.px4.io/plot_app?log=973783b8-6262-46e3-8214-602dce495131
look at actuator FFT

## Reply by Zachary Lowell 0 · 2024-03-13 17:55:17 UTC

@Dawid-Mościcki said in [Position mode works, but offboard mode don't](/post/15268):
> Please help 
> 
>  2 Replies Last reply about 24 hours ago Reply

Hi David - can you reflash your voxl with the most recent SDK and reconfigure the SKU - we need to start from baseline. Let me know.

Zach

## Reply by Dawid Mościcki · 2024-03-13 18:25:57 UTC (in reply to Zachary Lowell 0)

@Zachary-Lowell-0 what do You mean by SDK ? Is this guide that i should follow, but without full wipe ? https://docs.modalai.com/sentinel-factory-reset/

## Reply by tom (ModalAI staff) · 2024-03-13 18:28:06 UTC (in reply to Dawid Mościcki)

@Dawid-Mościcki https://docs.modalai.com/flash-system-image/#flashing-a-voxl-sdk-release

## Reply by Dawid Mościcki · 2024-03-15 17:05:50 UTC (in reply to tom)

@tom after flashing, i've got problem with calibrating IMU, btw should 2 imu be present ? because i can see only one : 
voxl-calibrate-imu-temp
voxl-imu-server currently has no calibration file
Server has IMU0 enabled and available for temperature calibration
WARNING, voxl-fan utility missing, can't turn on fan

============================================================================
We're now starting the COLD stage of the calibration.
Please stop all unnecessary services in another terminal, and try your best
to cool the PCB with a fan. Alternatively, start this process on a cold PCB.

We will be measuring the static gyro and accel offset as the board heats up.
VOXL must remain completely still through this entire process!
The IMU temperatures will be printed here continuously.

Press ENTER to start the heating process when you are happy that the IMUs
are cold enough for the lower bound. 25-35C is a reasonable goal for this.
============================================================================
CPU: 36.3C   IMU0: 30.4C   ^M
WARNING, voxl-fan utility missing, can't turn off fan

============================================================================
We're now starting the HOT stage of the calibration. We just turned off
the fan, and started stressing the CPU to heat up the PCB.
This will run automatically for a while collecting data points until enough
data has been collected, something gets too hot, or the timeout is reached.
============================================================================
CPU: 57.1C   IMU0: 34.9C   all imus reached steady state, finishing test
taking sample #2
not enough samples, need at least 3

## Reply by Dawid Mościcki · 2024-03-15 17:14:07 UTC (in reply to tom)

@tom i created backup from /data folder on my pc, but i don't know if this could be helpful

## Reply by Dawid Mościcki · 2024-03-15 17:31:38 UTC (in reply to Dawid Mościcki)

@Dawid-Mościcki after importing parameters for vio-indoor without gps from https://gitlab.com/voxl-public/voxl-sdk/utilities/voxl-px4-params/-/blob/master/params/v1.14/EKF2_helpers/indoor_vio_missing_gps.params

i only armed vehicle to see vibrations : https://review.px4.io/plot_app?log=c70ab712-72c1-4abf-b954-edda6316bf05

What could I do next ?

## Reply by Dawid Mościcki · 2024-03-15 17:37:10 UTC (in reply to tom)

@tom this is my second try https://review.px4.io/plot_app?log=cba05321-9bb5-42f2-a766-ecfa6ee01f80

## Reply by Dawid Mościcki · 2024-03-15 17:42:54 UTC (in reply to tom)

@tom this is my dump from /data folder : https://drive.google.com/drive/folders/1ZJXCvCcAg81zJolngtlS-Y_re2BjY2pz?usp=sharing

## Reply by Alex Kushleyev (ModalAI staff) · 2024-03-16 02:17:57 UTC (in reply to Dawid Mościcki)

@Dawid-Mościcki , the gyro / accel noise in your logs is very high.

This looks like the flight board is loose something is causing it to vibrate during flight (any wires or anything connected to VOXL2 that might be flopping around?).

Actuator controls FFT shows

![38c0d2be-7456-4132-a555-996e918ce8a0-image.png](https://forum.modalai.com/assets/uploads/files/1710555206398-38c0d2be-7456-4132-a555-996e918ce8a0-image.png) 
shows noise at about 80 hz (4800rpm) whch maches the average commanded / actual rpm:

![7ab776c5-9a86-498e-881d-4ffe6b5665be-image.png](https://forum.modalai.com/assets/uploads/files/1710555431465-7ab776c5-9a86-498e-881d-4ffe6b5665be-image.png) 

This confirms that the oscillations are coming from propeller vibrations and not oscillations due to high attitude control gains (which would be much lower frequency in the range of 15-20hz).

## Reply by Dawid Mościcki · 2024-04-04 22:26:51 UTC (in reply to Alex Kushleyev)

@Alex-Kushleyev Thanks for help, after changing propellers everything seems to work normal, but somehow RC apparatus stopped working. When i'm trying to set up bind mode nothing happens. I  was following this guide : 
https://docs.modalai.com/sentinel-user-guide-pre-flight-setup/

Led is blinking always slowly on blue....

What can i do about it ?

## Reply by Dawid Mościcki · 2024-04-08 11:32:20 UTC (in reply to Alex Kushleyev)

@Alex-Kushleyev for some reason CPU load on qvio-server is very high. We also have problem with Alfa wifi modem - every few minutes it's turning off and restarting ... Led isnt blinking for few seconds then network start working again . While this is happening Qgroundcontrol is crashing (as every time when drone is reconnected)

Output from voxl-inspect-services

 Service Name             |  Enabled  |   Running   |  CPU Usage
-------------------------------------------------------------------
 docker-autorun           | Disabled  | Not Running |  
 modallink-relink         | Disabled  | Not Running |  
 voxl-camera-server       |  Enabled  |   Running   |    71.0%
 voxl-cpu-monitor         |  Enabled  |   Running   |     0.6%
 voxl-dfs-server          | Disabled  | Not Running |  
 voxl-feature-tracker     | Disabled  | Not Running |  
 voxl-flow-server         | Disabled  | Not Running |  
 voxl-imu-server          |  Enabled  |   Running   |     5.4%
 voxl-lepton-server       | Disabled  | Not Running |  
 voxl-mavcam-manager      |  Enabled  |   Running   |     0.0%
 voxl-mavlink-server      |  Enabled  |   Running   |     3.5%
 voxl-modem               | Disabled  | Not Running |  
 voxl-neopixel-manager    | Disabled  | Not Running |  
 voxl-open-vins-server    | Disabled  | Not Running |  
 voxl-portal              |  Enabled  |   Running   |     0.2%
 voxl-px4-imu-server      | Disabled  | Not Running |  
 voxl-px4                 |  Enabled  |   Running   |    57.1%
 voxl-qvio-server         |  Enabled  | Not Running |  
 voxl-rangefinder-server  | Disabled  | Not Running |  
 voxl-remote-id           | Disabled  | Not Running |  
 voxl-softap              |  Enabled  |  Completed  |  
 voxl-static-ip           | Disabled  | Not Running |  
 voxl-streamer            |  Enabled  |   Running   |     0.0%
 voxl-tag-detector        | Disabled  | Not Running |  
 voxl-tflite-server       | Disabled  | Not Running |  
 voxl-time-sync           | Disabled  | Not Running |  
 voxl-uvc-server          | Disabled  | Not Running |  
 voxl-vision-hub          |  Enabled  |   Running   |     1.9%
 voxl-wait-for-fs         |  Enabled  |  Completed  |

## Reply by Dawid Mościcki · 2024-04-13 13:25:14 UTC

this is output from journalctl :

Mar 02 13:11:37 m0054 dhcpcd[1694]: wlan0: carrier acquired
Mar 02 13:11:37 m0054 dhcpcd[1694]: wlan0: IAID ca:b5:ab:b9
Mar 02 13:11:37 m0054 dhcpcd[1694]: wlan0: adding address fe80::76d9:b52b:91ff:9629
Mar 02 13:11:37 m0054 dhcpcd[1694]: wlan0: rebinding lease of 192.168.88.243
Mar 02 13:11:38 m0054 dhcpcd[1694]: wlan0: soliciting an IPv6 router
Mar 02 13:11:41 m0054 dhcpcd[1694]: wlan0: probing address 192.168.88.243/24
Mar 02 13:11:46 m0054 dhcpcd[1694]: wlan0: leased 192.168.88.243 for 600 seconds
Mar 02 13:11:46 m0054 dhcpcd[1694]: wlan0: adding route to 192.168.88.0/24
Mar 02 13:11:46 m0054 dhcpcd[1694]: wlan0: adding default route via 192.168.88.1
Mar 02 13:11:51 m0054 dhcpcd[1694]: wlan0: no IPv6 Routers available
Mar 02 13:12:28 m0054 wpa_supplicant[2278]: wlan0: CTRL-EVENT-DISCONNECTED bssid=18:fd:74:f3:01:e1 reason=0 locally_generated=1
Mar 02 13:12:28 m0054 wpa_supplicant[2278]: wlan0: CTRL-EVENT-ASSOC-REJECT status_code=1
Mar 02 13:12:28 m0054 wpa_supplicant[2278]: wlan0: CTRL-EVENT-REGDOM-CHANGE init=CORE type=WORLD
Mar 02 13:12:28 m0054 dhcpcd[1694]: wlan0: carrier lost
Mar 02 13:12:29 m0054 dhcpcd[1694]: wlan0: deleting address fe80::76d9:b52b:91ff:9629
Mar 02 13:12:29 m0054 dhcpcd[1694]: wlan0: deleting default route via 192.168.88.1
Mar 02 13:12:29 m0054 dhcpcd[1694]: wlan0: deleting route to 192.168.88.0/24
Mar 02 13:12:32 m0054 wpa_supplicant[2278]: wlan0: Trying to associate with 18:fd:74:f3:01:e1 (SSID='autonomy_lab' freq=2452 MHz)
Mar 02 13:12:32 m0054 wpa_supplicant[2278]: wlan0: Associated with 18:fd:74:f3:01:e1
Mar 02 13:12:32 m0054 wpa_supplicant[2278]: wlan0: CTRL-EVENT-SUBNET-STATUS-UPDATE status=0
Mar 02 13:12:33 m0054 wpa_supplicant[2278]: wlan0: WPA: Key negotiation completed with 18:fd:74:f3:01:e1 [PTK=CCMP GTK=CCMP]
Mar 02 13:12:33 m0054 wpa_supplicant[2278]: wlan0: CTRL-EVENT-CONNECTED - Connection to 18:fd:74:f3:01:e1 completed [id=0 id_str=]
Mar 02 13:12:33 m0054 dhcpcd[1694]: wlan0: carrier acquired
Mar 02 13:12:33 m0054 dhcpcd[1694]: wlan0: IAID ca:b5:ab:b9
Mar 02 13:12:33 m0054 dhcpcd[1694]: wlan0: adding address fe80::76d9:b52b:91ff:9629
Mar 02 13:12:33 m0054 dhcpcd[1694]: wlan0: soliciting an IPv6 router
Mar 02 13:12:34 m0054 dhcpcd[1694]: wlan0: rebinding lease of 192.168.88.243
Mar 02 13:12:39 m0054 dhcpcd[1694]: wlan0: probing address 192.168.88.243/24
Mar 02 13:12:44 m0054 dhcpcd[1694]: wlan0: leased 192.168.88.243 for 600 seconds
Mar 02 13:12:44 m0054 dhcpcd[1694]: wlan0: adding route to 192.168.88.0/24
Mar 02 13:12:44 m0054 dhcpcd[1694]: wlan0: adding default route via 192.168.88.1
Mar 02 13:12:46 m0054 dhcpcd[1694]: wlan0: no IPv6 Routers available
Mar 02 13:13:34 m0054 dhcpcd[1694]: wlan0: carrier lost
Mar 02 13:13:34 m0054 wpa_supplicant[2278]: wlan0: CTRL-EVENT-DISCONNECTED bssid=18:fd:74:f3:01:e1 reason=0 locally_generated=1
Mar 02 13:13:34 m0054 wpa_supplicant[2278]: wlan0: CTRL-EVENT-ASSOC-REJECT status_code=1
Mar 02 13:13:34 m0054 wpa_supplicant[2278]: wlan0: CTRL-EVENT-REGDOM-CHANGE init=CORE type=WORLD
Mar 02 13:13:34 m0054 dhcpcd[1694]: wlan0: deleting address fe80::76d9:b52b:91ff:9629
Mar 02 13:13:34 m0054 dhcpcd[1694]: wlan0: deleting default route via 192.168.88.1
Mar 02 13:13:34 m0054 dhcpcd[1694]: wlan0: deleting route to 192.168.88.0/24
Mar 02 13:13:38 m0054 wpa_supplicant[2278]: wlan0: Trying to associate with 18:fd:74:f3:01:e1 (SSID='autonomy_lab' freq=2452 MHz)
Mar 02 13:13:38 m0054 wpa_supplicant[2278]: wlan0: Associated with 18:fd:74:f3:01:e1
Mar 02 13:13:38 m0054 wpa_supplicant[2278]: wlan0: CTRL-EVENT-SUBNET-STATUS-UPDATE status=0
Mar 02 13:13:39 m0054 wpa_supplicant[2278]: wlan0: WPA: Key negotiation completed with 18:fd:74:f3:01:e1 [PTK=CCMP GTK=CCMP]
Mar 02 13:13:39 m0054 wpa_supplicant[2278]: wlan0: CTRL-EVENT-CONNECTED - Connection to 18:fd:74:f3:01:e1 completed [id=0 id_str=]
Mar 02 13:13:39 m0054 dhcpcd[1694]: wlan0: carrier acquired
Mar 02 13:13:39 m0054 dhcpcd[1694]: wlan0: IAID ca:b5:ab:b9
Mar 02 13:13:39 m0054 dhcpcd[1694]: wlan0: adding address fe80::76d9:b52b:91ff:9629
Mar 02 13:13:39 m0054 dhcpcd[1694]: wlan0: soliciting an IPv6 router
Mar 02 13:13:40 m0054 dhcpcd[1694]: wlan0: rebinding lease of 192.168.88.243
Mar 02 13:13:43 m0054 dhcpcd[1694]: wlan0: probing address 192.168.88.243/24
Mar 02 13:13:48 m0054 dhcpcd[1694]: wlan0: leased 192.168.88.243 for 600 seconds
Mar 02 13:13:48 m0054 dhcpcd[1694]: wlan0: adding route to 192.168.88.0/24
Mar 02 13:13:48 m0054 dhcpcd[1694]: wlan0: adding default route via 192.168.88.1
Mar 02 13:13:53 m0054 dhcpcd[1694]: wlan0: no IPv6 Routers available

Idk wifi keeps disconnecting. Could You please help me ? And every time when wifi is disconnecting and connecting again, QGC is crashing :/ This behavior could be caused by px4 modules shipped with Your forked version of px4 ...

## Reply by Dawid Mościcki · 2024-04-13 13:35:33 UTC (in reply to Dawid Mościcki)

I will close this ticket and make a new ones. This conversations is too long, sorry for that :/ Thanks for help so far !
