PX4 / PX4-Autopilot

PX4 Autopilot Software
https://px4.io
BSD 3-Clause "New" or "Revised" License
8.26k stars 13.42k forks source link

Navio2 ESC calibration and PWM Outputs parameters missing #13635

Open ClaudioCimarelli opened 4 years ago

ClaudioCimarelli commented 4 years ago

Describe the bug I am experiencing an incompatibility between Navio2 and PX4 v1.9.2 in controlling the PWM output to the esc.

This issue is related to the closed #11743, that was solved by switching to APM...(I can confirm that it works without problem, but it is not a solution for me).

I am wondering how could I turn the driver under /sys/class/pwm/pwmchip0 into the expected device file and if anyone ever was able to fly using PX4 with a NAVIO2 board.

Drone:

Thank you for your help in avance, hoping this issue will have better luck than #11743 :crossed_fingers: :smile:

dagar commented 4 years ago

Unfortunately support for the Navio2 was never brought to the same level as the pixhawk flight controllers and infrastructure wasn't put in place to keep it working well.

dagar commented 4 years ago

What does your bootup look like in PX4? Is linux_pwm_out starting successfully? What does pwm info show?

ClaudioCimarelli commented 4 years ago

I receive an error in both cases:

pwm_debug

I tried the module for esc calibration directly but of course not a chance: esc_calib

I naively used this driver under sysfs the same way as the expected device file. I am totally new to drivers, so I am trying everything. Anyway somewhere in the code of PX4 there is already the key to dialogue using navio pwm drivers, but I do not know where to look yet.

ClaudioCimarelli commented 4 years ago

In addition, there is a strange issue with the Navio2 rebooting after the disarming. I have not managed to localize the config which causes this because this does not happen always.

SalimTerryLi commented 4 years ago

I created a post on px4discuss just now. Here I' m continuously work on supporting Linux based device running PX4 such as RasPi and Jetson TX2(planning) but not sure whether PX4 team value this.

ClaudioCimarelli commented 4 years ago

Update: I have noticed that the module Linux Pwm Out actually starts fine. It was my error that it was already running and thus not starting again. Pwm module does not start anyway, but I think it is normal for navio.

I think the problem is setting the correct period value for the pwm device and the duty cycle. I have checked that with ardupilot the period is set to 2040816 ns by printing the file /sys/class/pwm/pwmchip0/pwm0/period while PX4 set it to 2500000 ns. This value should probably be read from the PWM_RATE param but it is not present like others in the same group.

EDIT: the parameter is hardcoded inside https://github.com/PX4/Firmware/blob/master/src/drivers/linux_pwm_out/navio_sysfs.h as static const int FREQUENCY_PWM = 400; . I tried setting it to 490.

EDIT2: modifying this value is not enough and the system reboot every time after disarming.

stale[bot] commented 4 years ago

This issue has been automatically marked as stale because it has not had recent activity. Thank you for your contributions.

tgadi001 commented 4 years ago

@ClaudioCimarelli were you able to find any work around for this problem? I have same setup as your with px4 running on a RPi with NAVIO2 shield, but my ESCs are not calibrated so i can not fly my vehicle. I was thinking to install APM on a different SD card, plug it in to the RPi, connect to Mission Planner, perform ESC callibration on Mission Planner, then write down PWM min/max values for each channel and finally plug back in the SD card with px4 to the RPi and manually enter the min/max PWM values as the parameters on px4. Only problem is that i don't think changing PWM_MAIN_MINx and PWM_MAIN_MAXx parameters on px4 flight stack does anything.

Another thing I was wondering was if there is any way to fix the current esc_calib function on px4 flight stack? maybe instead of trying to access the /dev/pwm_output0 there is a way to make it access the right file, i just haven't been able to find any useful information cause i am really new to this.

Anyone's thoughts or comments would be really appreciated. Even if it doesn't give me the right solution at least i would know what not to waste my time on. Thank you in advance!!

SalimTerryLi commented 4 years ago

@ClaudioCimarelli were you able to find any work around for this problem? I have same setup as your with px4 running on a RPi with NAVIO2 shield, but my ESCs are not calibrated so i can not fly my vehicle. I was thinking to install APM on a different SD card, plug it in to the RPi, connect to Mission Planner, perform ESC callibration on Mission Planner, then write down PWM min/max values for each channel and finally plug back in the SD card with px4 to the RPi and manually enter the min/max PWM values as the parameters on px4. Only problem is that i don't think changing PWM_MAIN_MINx and PWM_MAIN_MAXx parameters on px4 flight stack does anything.

Another thing I was wondering was if there is any way to fix the current esc_calib function on px4 flight stack? maybe instead of trying to access the /dev/pwm_output0 there is a way to make it access the right file, i just haven't been able to find any useful information cause i am really new to this.

Anyone's thoughts or comments would be really appreciated. Even if it doesn't give me the right solution at least i would know what not to waste my time on. Thank you in advance!!

We need a new driver to replace this, with new framework and new parameters implemented. That old driver doesn't worth any updating.

stale[bot] commented 3 years ago

This issue has been automatically marked as stale because it has not had recent activity. Thank you for your contributions.