MAVSDK-Python icon indicating copy to clipboard operation
MAVSDK-Python copied to clipboard

Can we inject actuator command via MAVSDK for offboard control?

Open JinraeKim opened this issue 4 years ago • 25 comments

I cannot find an example of injecting actuator commands for offboard control.

For example, thrust command or rotor angular rate.

JinraeKim avatar Jan 05 '22 05:01 JinraeKim

What about these?

Actuator control: http://mavsdk-python-docs.s3-website.eu-central-1.amazonaws.com/plugins/offboard.html#mavsdk.offboard.Offboard.set_actuator_control

Attitude rate control: http://mavsdk-python-docs.s3-website.eu-central-1.amazonaws.com/plugins/offboard.html#mavsdk.offboard.Offboard.set_attitude_rate

julianoes avatar Jan 05 '22 06:01 julianoes

Ok, there are appropriate functions :)

But there is no example with direct actuator control, right?

JinraeKim avatar Jan 05 '22 06:01 JinraeKim

There is not but it would be great if you contribute one. :smile:

julianoes avatar Jan 05 '22 06:01 julianoes

As I'm still not familiar with details of offboard control, I would appreciate if MAVSDK-Python provides an example of direct actuator control :)

JinraeKim avatar Jan 05 '22 06:01 JinraeKim

There is not but it would be great if you contribute one. 😄

Of course I will if I find an appropriate working example!

JinraeKim avatar Jan 05 '22 06:01 JinraeKim

I think you can try it in simulation.

So do you actually need attitude rate control, or actuator control? Because that's not the same thing.

julianoes avatar Jan 05 '22 06:01 julianoes

I think you can try it in simulation.

So do you actually need attitude rate control, or actuator control? Because that's not the same thing.

Sorry for the confusion.

What I'm trying to do is actuator control.

JinraeKim avatar Jan 05 '22 06:01 JinraeKim

Ok, and that's with PX4? And what is the use case? If I understand more context, I might be able to help with your actual problem.

julianoes avatar Jan 05 '22 07:01 julianoes

Ok, and that's with PX4? And what is the use case? If I understand more context, I might be able to help with your actual problem.

Yup, with PX4.

I'm trying to inject actuator control input from an external device (e.g., RPi or GCS) to Pixhawk (equipped with PX4) via MAVSDK. This is for testing a custom controller and ease of usage.

JinraeKim avatar Jan 05 '22 07:01 JinraeKim

~~BTW, what does "actuator control" stand for, exactly? (rotor thrust?)~~ According to offboard.py, it seems to be a throttle scaled from -1 to 1. What does "throttle" mean exactly? For example, if I wanna inject a signal as "the first rotor's thrust should be 1N", what should I do?

JinraeKim avatar Jan 05 '22 07:01 JinraeKim

Throttle in this case just means that the motor spins from low to max, 0..1, from what I can read.

julianoes avatar Jan 05 '22 07:01 julianoes

Throttle in this case just means that the motor spins from low to max, 0..1, from what I can read.

Thanks as always :) So it's literally "throttle" like the throttle in RC controller. Is there any systematic or heuristic way to send a thrust command like "the first rotor's thrust should be 1N"?

JinraeKim avatar Jan 05 '22 07:01 JinraeKim

No, it's throttle as in PWM to a motor, I believe.

julianoes avatar Jan 05 '22 09:01 julianoes

Just try it out in SITL (with lockstep disabled).

julianoes avatar Jan 05 '22 09:01 julianoes

Thank you a lot!

JinraeKim avatar Jan 05 '22 10:01 JinraeKim

@JinraeKim did it worked? can you send direct pwm cmds to motors from offboard by mavsdk?

Traveller30 avatar Aug 30 '22 20:08 Traveller30

@JinraeKim did it worked? can you send direct pwm cmds to motors from offboard by mavsdk?

TBH, I don't remember clearly cuz our team is decided not to use MAVSDK for offboard control... I'm sorry. I guess it didn't work well (or was hard to figure out what each variable means).

@hnlee77 Do you remember any things about this?

JinraeKim avatar Aug 30 '22 21:08 JinraeKim

TBH, I don't remember clearly cuz our team is decided not to use MAVSDK for offboard control... I'm sorry. I guess it didn't work well (or was hard to figure out what each variable means).

@hnlee77 Do you remember any things about this?

@Traveller30 Yeah, it didn't work well. we couldn't send direct pwm cmds to motors. so now, we decided send only attitude cmds for offboard by mavsdk.

hnlee77 avatar Aug 31 '22 07:08 hnlee77

ok , thank you

Traveller30 avatar Sep 01 '22 17:09 Traveller30

Kind reminder: contributions are always welcome if a MAVSDK feature doesn't work well :+1:.

JonasVautherin avatar Sep 01 '22 20:09 JonasVautherin

Hello, @JinraeKim , just checking to see if there are any updates on this? I'm trying to send a command directly to each quadcopter motor rather than use higher level functions like "takeoff" or "land", and an example would be very helpful. Have you figured it out?

rakmo97 avatar Jun 12 '23 17:06 rakmo97

Hello, @JinraeKim , just checking to see if there are any updates on this? I'm trying to send a command directly to each quadcopter motor rather than use higher level functions like "takeoff" or "land", and an example would be very helpful. Have you figured it out?

We are no longer working on this topic so there is no update so far :<

JinraeKim avatar Jun 12 '23 21:06 JinraeKim

Offboard control using actuator controls has actually been removed in more recent versions of PX4.

julianoes avatar Jun 12 '23 23:06 julianoes

Thanks! Does that mean the offboard.set_actuator_control function wouldn't work?

I know this might not be the place for this question, but how are people sending actuator commands from a host computer to their quadcopter? I've been trying to figure that out using mavsdk-python.

rakmo97 avatar Jun 12 '23 23:06 rakmo97

It should still work for v1.13: https://github.com/PX4/PX4-Autopilot/blob/release/1.13/src/modules/mavlink/mavlink_receiver.cpp#LL160C3-L160C45

julianoes avatar Jun 13 '23 02:06 julianoes