mavlink / MAVSDK-Python

MAVSDK client for Python.
https://mavsdk.mavlink.io
BSD 3-Clause "New" or "Revised" License
320 stars 219 forks source link

Other examples in MAVSDK-Python can run perfectly but not manual_control.py example #393

Closed kois86 closed 2 years ago

kois86 commented 3 years ago

Hi,

I am at loss in troubleshooting the issue for my program. FYI, my program performs precision landing on a moving platform and for that, I use manual_control.py example.

I use HiTL setup whereby my Raspi, containing the program above, is connected to pixhawk FC, and this pixhawk is connected to the PC running Gazebo simulator.

FYI, what weird is, when i run my program, only drone.manual_control.set_manual_control_input() not running. Other instructions within the example, such as takeoff and land, and even drone.manual_control.start_position_control(), having an effect on the gazebo simulator.

Other examples such as offboard_attitude.py, telemetry_flight.py, all run well, only that instruction not working.

Anyone has the same issue or can solve my problem. Thank you in advance and please help as I really have no idea how to move forward on this.

Thank you

julianoes commented 3 years ago

Thanks for the issue. I will have to try to reproduce it sometime.

For precision landing I would suggest to use offboard rather than manual control though.

kois86 commented 3 years ago

Thanks for the issue. I will have to try to reproduce it sometime.

For precision landing I would suggest to use offboard rather than manual control though.

Understood but the precision landing system I have been developed require precision pitch yaw roll and throttle control.

In offboard example, it defines the UAV's movement by its rotation angle and throttle value as well as duration which I find quite hard to use in my main program in order to position the UAV at the coordinate that I wanted to.

Meanwhile, I try to reinstall and test different PX4 FW for troubleshooting.

Thank you.

p/s: In SiTL mode, this example and my main program works well

julianoes commented 3 years ago

require precision pitch yaw roll and throttle control.

You can do that with offboard attitude control: https://mavsdk.mavlink.io/main/en/cpp/api_reference/classmavsdk_1_1_offboard.html#classmavsdk_1_1_offboard_1af6f0d3991bb6b62f39d862c46fcffb34

kois86 commented 3 years ago

require precision pitch yaw roll and throttle control.

You can do that with offboard attitude control: https://mavsdk.mavlink.io/main/en/cpp/api_reference/classmavsdk_1_1_offboard.html#classmavsdk_1_1_offboard_1af6f0d3991bb6b62f39d862c46fcffb34

i try to use offboard attitude command but doesn't work perfectly as my manual_control. the reason being, it requires duration after the command which makes the movement jerky and not smooth, unlike manual_control that can repeat its command without duration, thus making the UAV movement seamless and steady carrying its inertia from previous command.

I not sure how to explain but I hope u understand

julianoes commented 3 years ago

it requires duration after the command

You should be able to set an offboard command as fast as you want.

kois86 commented 2 years ago

Hi Julian,

have u tested the manual control? when i go through the documentation i found this

async set_manual_control_input(x, y, z, r) Set manual control input

The manual control input needs to be sent at a rate high enough to prevent triggering of RC loss, a good minimum rate is 10 Hz.

Which I think is the cause of the API not running. is there a way to override or to adjust the 10hz fast rate input requirement?

JonasVautherin commented 2 years ago

Well you have to call the function, if you want to call it at 20Hz that's on your end, right?

kois86 commented 2 years ago

Programming wise, i have run the examples given in the github repository, refer to https://github.com/mavlink/MAVSDK-Python/blob/main/examples/manual_control.py.

when running the program in simulation together with QGroundControl as monitoring, the drone will enter position mode and then it will do nothing. but will move accordingly when I run it without.

Thus, when I want to test onto the actual drone, it will not move similar to the simulation - it just only enter position mode

kois86 commented 2 years ago

anyhow, have u tried the example with QGC?

thank you very much

JonasVautherin commented 2 years ago

but will move accordingly when I run it without.

You mean the mavsdk example works if QGC is not connected, but it fails if QGC is connected?

kois86 commented 2 years ago

but will move accordingly when I run it without.

You mean the mavsdk example works if QGC is not connected, but it fails if QGC is connected?

Yes, exactly. with QGC connected, the drone doesnt move accordingly and just descend until it lands

JonasVautherin commented 2 years ago

Do you have the virtual joysticks enabled in QGC? Could it be interfering somehow?

kois86 commented 2 years ago

Do you have the virtual joysticks enabled in QGC? Could it be interfering somehow?

I have disabled the virtual joystick, but unfortunately to a same result.

Any idea why i cant use the example with QGC connected?

JonasVautherin commented 2 years ago

Feels like some kind of interference at the mavlink level :thinking:. Would be nice to understand why, if you can have a closer look :+1:

kois86 commented 2 years ago

I did try to troubleshoot and have a closer look but can only think this requirement (The manual control input needs to be sent at a rate high enough to prevent triggering of RC loss, a good minimum rate is 10 Hz) that prevent the example to run.

the reason I prefer the manual control over offboard attitude is that it gives natural smooth movement of the drone without the need to put in await asyncio.sleep after the instruction to make it move, which lead to two problems that I encountered when using offboard attitude:

  1. jerking movement as there are pauses between each set of offboard movement instructions
  2. latency of the real-time input(in my case camera feed) that reduce the accuracy of the program.

However, currently I'm still using offboard attitude for my actual drone, while still looking for a way to use manual control. do feedback if you have any idea, or example of manual control being used in the actual drone which requires QGC in the loop.

thank you

julianoes commented 2 years ago

@kois86 which PX4 version are you using? And what is your param https://docs.px4.io/master/en/advanced_config/parameter_reference.html#COM_RC_IN_MODE?

julianoes commented 2 years ago

Closing, as there was no more follow up.

kennethakiti1 commented 2 years ago

is there any update on the manual_control to work?

julianoes commented 2 years ago

@kennethakiti1 please create a new issue with whatever does not work as it should for you please.