# ESC Calibration issues

Source: https://forum.modalai.com/topic/120/esc-calibration-issues
Category: General Questions (https://forum.modalai.com/category/2/general-questions)
Posted: 2021-02-01 14:45:23 UTC by Riley Dove
Replies: 28 · Views: 7831

## Riley Dove · 2021-02-01 14:45:23 UTC

After following the wiki for ESC calibration, once I type Y for all of the prompts and it should run, I get an immediate error. I'm able to connect via QGC. QGC is closed out and it is able to access the port. Errors are 
line 269 in <module> 
mavcall()
line 246 in mavcal 
if not mavshell.connect()
line 74, in connect 
ret = selv.mav.wait_heartbeat(blocking=true, timeout=10) 
TypeError: wait_heartbeat() got an unexpected keyword argument 'timeout'

Any ideas? From what I think I'm seeing is that there was a timeout in the connection maybe?

## Reply by modaltb (ModalAI staff) · 2021-02-01 14:56:02 UTC

Hi @Riley-Dove ,

Do you what FW version you are using?  I’ve seen some inconsistencies on v1.11.  We’ll take a look, they work around we are using isn’t ideal so perhaps there’s some improvements we can make.

## Reply by Riley Dove · 2021-02-01 15:04:07 UTC

I just had a BEC failure, so I cant access the FC,. Will swap and let you know. I believe I updated to 1.11 via QGC.

## Reply by Riley Dove · 2021-02-01 15:40:14 UTC (in reply to modaltb)

@modaltb I have V1.11.3 loaded onto the Flight deck board.

## Reply by modaltb (ModalAI staff) · 2021-02-01 15:48:13 UTC

Hi @Riley-Dove ,

Ok thanks.  Let me get someone to check into this this AM.  

We use the tool a lot with our production release of 1.10, https://docs.modalai.com/flight-core-firmware/#px4-v110

We haven’t moved to 1.11 in production on our side so the tools might need an update.

A work around should be to go back to the release in the link above, but ideally we get the tool working with 1.11.

I’ll keep you posted.

Thanks!
Travis

## Reply by Riley Dove · 2021-02-01 15:49:46 UTC

I just reverted back to the ModalAI version of V1.10 and still having the same issues. It must be somehow related to my system.

## Reply by Riley Dove · 2021-02-01 15:57:56 UTC

In the end goal, When I arm the copter, the motors stay at the ESC armed throttle level, despite seeing throttle input from the RC. Once I get this resolved, should it work, or are they unrelated?

## Reply by modaltb (ModalAI staff) · 2021-02-01 16:06:27 UTC

ESC cal "shouldn't" matter for this (it does set min/max range, but typically bad ESC cal just results in some iffy flights).

I've seen throttling up occurring if the estimator isn't running.  Are you using a magnetometer in the setup?

PX4 expects an external mag by default, our custom FW is basically to handle this use case for indoor flight without a mag, there's work arounds for this so let me know and I can show you if this is the case.

Thanks!

## Reply by Riley Dove · 2021-02-01 16:20:23 UTC (in reply to modaltb)

@modaltb No magnetometer. I installed the No mag params file, as well as a few others, but I'd like to get your instructions. Mavlink inspector shows it not going above 1075.

## Reply by modaltb (ModalAI staff) · 2021-02-01 16:32:23 UTC (in reply to Riley Dove)

@Riley-Dove ,

On VOXL, what happens if you run `systemctl status voxl-vision-px4` ?

In our 1.10, to fly without mag, the system expects VIO data from VOXL.  The FlightDeck should have this setup by default (e.g VOXL is sending VIO data to FlightCore).  This is setup  via  EKF2_AID_MASK  which is seems like you loaded, can you  check this step to make  sure PX4 is getting VIO data?  https://docs.modalai.com/flying-with-vio/#confirm-px4-is-getting-vio-data 

In our 1.11, we've reduced the requirement so simply check if EKF2_AID_MASK is configured (and doesn't care if there's actual vision data...)

## Reply by Riley Dove · 2021-02-01 18:28:00 UTC

This is what I see. I also cannot get to QGC through VOXL. 

~ # systemctl status voxl-vision-px4
● voxl-vision-px4.service - voxl-vision-px4
   Loaded: loaded (/usr/bin/voxl-vision-px4; disabled; vendor preset: enabled)
   Active: failed (Result: signal) since Thu 1970-01-01 00:44:44 UTC; 5min ago
  Process: 3084 ExecStart=/usr/bin/voxl-vision-px4 (code=killed, signal=SEGV)
 Main PID: 3084 (code=killed, signal=SEGV)

Jan 01 00:44:44 apq8096 voxl-vision-px4[3084]: "en_send_voa_to_qgc": false,
Jan 01 00:44:44 apq8096 voxl-vision-px4[3084]: "en_mvl_video_stream": false,
Jan 01 00:44:44 apq8096 voxl-vision-px4[3084]: "en_adsb" false,
Jan 01 00:44:44 apq8096 voxl-vision-px4[3084]: "adsb_uart_bus": 7,
Jan 01 00:44:44 apq8096 voxl-vision-px4[3084]: "adsb_uart_baudrate": 57600,
Jan 01 00:44:44 apq8096 voxl-vision-px4[3084]: "en_offboard_figure_eight": true,
Jan 01 00:44:44 apq8096 voxl-vision-px4[3084]: "vio_to_ned_rotation_matrix":...]
Jan 01 00:44:44 apq8096 systemd[1]: voxl-vision-px4.service: Main process e...GV
Jan 01 00:44:44 apq8096 systemd[1]: voxl-vision-px4.service: Unit entered f...e.
Jan 01 00:44:44 apq8096 systemd[1]: voxl-vision-px4.service: Failed with re...'.
Hint: Some lines were ellipsized, use -l to show in full.
~ #

## Reply by modaltb (ModalAI staff) · 2021-02-01 20:05:41 UTC

OK without that service running, the QGC link through VOXL won't work, and this would also prevent VIO data making it's way to PX4, and then flying without a mag won't work....

How about `systemctl stop voxl-vision-px4` and then running manually with the debug flag: `voxl-vision-px4 -d` 

This service is used when we calibrate the cameras before shipping so I'm wondering what's going on.

## Reply by Riley Dove · 2021-02-01 20:27:08 UTC

This is what I typed and what I get. 

~ # systemctl stop voxl-vision-px4
~ # voxl-vision-px4 -d
loading config file
Error parsing config file before: en_vao": false,
	"en_send_vio_to_qgc": false,
	"en_send_voa_to_qgc": false, 
	"en_mvl_video_stream": false,
	"en_adsb" false,
	"adsb_uart_bus": 7,
	"adsb_uart_baudrate": 57600,
	"en_offboard_figure_eight": true,
	"vio_to_ned_rotation_matrix": [[0, 1, 0], [1, 0, 0], [0, 0, -1]]

Segmentation fault
~ #

## Reply by modaltb (ModalAI staff) · 2021-02-01 21:25:29 UTC

Hi @Riley-Dove , I think the config file got messed up.  Perhaps around the "offboard_mode" setting.

This lives at /etc/modalai/voxl-vision-px4.conf

Here's an example, where the `qgc_ip` is your system with QGC's IP address:

```
{
	"qgc_ip":	"192.168.8.47",
	"en_localhost_mavlink_udp":	true,
	"en_secondary_qgc":	false,
	"secondary_qgc_ip":	"192.168.1.214",
	"offboard_mode":	"none",
	"en_vio":	false,
	"en_voa":	false,
	"en_send_vio_to_qgc":	false,
	"en_send_voa_to_qgc":	false,
	"en_adsb":	false,
	"adsb_uart_bus":	7,
	"adsb_uart_baudrate":	57600,
	"px4_uart_bus":	5,
	"px4_uart_baudrate":	921600,
	"R_imu_to_body":	[[0, 1, 0], [1, 0, 0], [0, 0, -1]],
	"T_imu_wrt_body":	[0.068, -0.015, -0.008],
	"height_body_above_ground_m": 0.05,
	"T_stereo_wrt_body":	[0.10, -0.04, 0.0],
	"land_on_tag_id":	0,
	"follow_tag_id":	0,
	"en_apriltag_fixed_frame":	false,
	"fixed_apriltags":	[{
		"tag_id":	0,
		"R_tag_to_fixed":	[[0, -1, 0], [1, 0, 0], [0, 0, 1]],
		"T_tag_wrt_fixed":	[0, 0, 0]
		}],
	"en_transform_mavlink_pos_setpoints_from_fixed_frame":	true,
	"en_fixed_frame_pipe": false,
	"fixed_frame_filter_len": 5
}
```

## Reply by modaltb (ModalAI staff) · 2021-02-01 21:26:51 UTC

Also, if you didn't modify this file and this is how it shipped let me know so I can look into what happened.  We enable VOA during flight testing and then disable so if there's a typo introduced causing this issue I want to inform the team over here.  Thanks!

## Reply by Riley Dove · 2021-02-01 22:02:39 UTC

Now it says only "error parsing config file before: ? 
Segmentation fault"

## Reply by Riley Dove · 2021-02-01 22:06:02 UTC (in reply to modaltb)

@modaltb I may have modified it, not even sure. I'm still learning the hardcore software side of this. I'm a hardware guy.

## Reply by modaltb (ModalAI staff) · 2021-02-02 04:46:37 UTC

@Riley-Dove ok, we can reset it to factory defaults, maybe that's easiest!  If you can delete that file `/etc/modalai/voxl-vision-px4.conf` and then run the following command: `voxl-configure-vision-px4 -f` it will set the factory settings.

Restart the service:
`systemctl restart voxl-vision-px4`

Check status:
`systemctl status voxl-vision-px4`

If all looks good, you can set your IP back up:

```
vi /etc/modalai/voxl-vision-px4.conf
```

vi isn't easy to use.  But this should get you going:
- hit 'i' to enter edit mode
- move cursor to text using arrows, edit the ip address following the same format that's there
- hit 'esc' to exit edit mode
- to save, enter `:wq`

Restart the service:
`systemctl restart voxl-vision-px4`

Check status:
`systemctl status voxl-vision-px4`

Then you should have a connection to QGC.

## Reply by Riley Dove · 2021-02-02 13:02:58 UTC

I run into the same issue when I check the voxl vision status. Active: Failed. There is nothing on the voxl-vision-px4.conf file. It's not properly configuring that file.

## Reply by modaltb (ModalAI staff) · 2021-02-02 16:10:33 UTC

Hi @Riley-Dove ,

Sorry, something is happening when editing maybe...  This setup is heavily used all over so trying to see what up, we can do a screen share if the following fails.

What if you do the following, without editing the file at all.
- `systemctl stop voxl-vision-px4`
- `voxl-configure-vision-px4 -f`
- `cat /etc/modalai/voxl-vision-px4.conf`

Can you then copy paste the output of the last command here?

Then if the JSON output looks OK above, try to start again... `systemctl start voxl-vision-px4`.

[This](https://gitlab.com/voxl-public/modal-pipe-architecture/voxl-vision-px4/-/blob/v0.6.8/config/voxl-vision-px4.conf) is where I'm getting the file.

## Reply by Riley Dove · 2021-02-02 16:21:50 UTC

Looks like that worked. 

~ # systemctl stop voxl-vision-px4
~ # voxl-configure-vision-px4 -f
loading and updating config file with voxl-vision-px4 -c
Error parsing config file before: 
/usr/bin/voxl-configure-vision-px4: line 120:  3072 Segmentation fault      voxl-vision-px4 -c
^ don't worry about the segfault ^
 
attempting to use camera configuration 3
adding override_cam_id value=1 to /etc/snav/camera.downward.xml
adding override_cam_id value=2 to /etc/snav/camera.stereo.xml
reloading systemd services
disabling all the snav services
starting imu_app
Created symlink from /etc/systemd/system/multi-user.target.wants/imu_app.service to /etc/systemd/system/imu_app.service.
WARNING: Missing stereo calibration file. Follow instructions here to
calibrate if you wish to use stereo visual obstacle avoidance.
https://docs.modalai.com/docs/quickstarts/calibrate-cameras/

DONE configuring ModalAI Vision Lib
enabling voxl-vision-px4 systemd service
Created symlink from /etc/systemd/system/multi-user.target.wants/voxl-vision-px4.service to /etc/systemd/system/voxl-vision-px4.service.
starting voxl-vision-px4 systemd service
DONE configuring voxl-vision-px4
~ # cat /etc/modalai/voxl-vision-px4.conf
{
	"qgc_ip":	"192.168.8.60",
	"en_localhost_mavlink_udp":	true,
	"en_secondary_qgc":	false,
	"secondary_qgc_ip":	"192.168.1.214",
	"offboard_mode":	"figure_eight",
	"en_vio":	true,
	"en_voa":	false,
	"en_send_vio_to_qgc":	false,
	"en_send_voa_to_qgc":	false,
	"en_adsb":	false,
	"adsb_uart_bus":	7,
	"adsb_uart_baudrate":	57600,
	"px4_uart_bus":	5,
	"px4_uart_baudrate":	921600,
	"R_imu_to_body":	[[0, 1, 0], [1, 0, 0], [0, 0, -1]],
	"T_imu_wrt_body":	[0.068, -0.015, -0.008],
	"height_body_above_ground_m": 0.05,
	"T_stereo_wrt_body":	[0.10, -0.04, 0.0],
	"land_on_tag_id":	0,
	"follow_tag_id":	0,
	"en_apriltag_fixed_frame":	false,
	"fixed_apriltags":	[{
		"tag_id":	0,
		"R_tag_to_fixed":	[[0, -1, 0], [1, 0, 0], [0, 0, 1]],
		"T_tag_wrt_fixed":	[0, 0, 0]
		}],
	"en_transform_mavlink_pos_setpoints_from_fixed_frame":	true,
	"en_fixed_frame_pipe": false,
	"fixed_frame_filter_len": 5
}
~ # 

I edited the QGC IP to my laptop's IP and QGC still doesnt see it. I will try from a different computer.

## Reply by Riley Dove · 2021-02-02 16:32:33 UTC

No luck on different computer. I just tried the ESC cal as well and no luck.

## Reply by modaltb (ModalAI staff) · 2021-02-02 16:56:19 UTC

What kind of computer are you using, Linux, Windows?

If Windows, you likely need to configure the firewall (maybe easier to just disable the windows firewall for this test).

You can use the USB connection straight to the blue connector to get a connection to QGC.

But, if you have QGC running, the ESC calibration tool won't work because QGC will have taken ownership of the port.

## Reply by Riley Dove · 2021-02-02 16:57:57 UTC

I've been testing on a Macbook Pro. I can get QGC via the USB port, just not via Wifi. And the motors dont spin above minimum armed PWM.

## Reply by modaltb (ModalAI staff) · 2021-02-02 18:19:22 UTC

I just went through similar yesterday on a new board we're developing.  PX4 is configured to expect a magnetometer, you'll want to set the `sys_has_mag` param to `0`, and `GPS_1_CONFIG` to off/none via the QGC.

I can get on a screen share after a bit if needed so just let me know if you want to wait till then.

## Reply by Riley Dove · 2021-02-02 18:47:22 UTC

I just did another test randomly while eating my lunch and it worked as expected. So I did a maiden and checked stabilize, althold, and position mode and all modes flew well. We have lots of snow here so cant test too much more outdoors.

## Reply by modaltb (ModalAI staff) · 2021-02-02 18:50:17 UTC

OK great!!  Please holler if you hit any other snags.

## Reply by Riley Dove · 2021-02-03 18:26:28 UTC

Another snag... Seems like the voxl-vision-px4 is spotty at starting. I am trying to fly again and no luck. I ran the status command and the same failure as before.

## Reply by modaltb (ModalAI staff) · 2021-02-03 21:32:19 UTC

Hi @Riley-Dove ,

Want to try to do a screen share tomorrow AM?  I'll send an email to what's registered on this account.

Some of the errors looked like config file parsing, but the first one was truncated a bit.

If the device is in the failed currently, and you don't mind, you can throw the output of `systemctl status voxl-vision-px4 -l` here in preps.

Thanks, we'll figure out what's going on!
