ROS2 interface for controlling thrust and attitude

Hi guys,

I am controlling a copter with ROS2 humble and I would like to ask how to send thrust + attitude cmd in guided and guided_noGPS modes.

I followed guides on Ardupilot webstite and SITM can run with ROS2 humble. However, ROS 2 Interfaces shows only ap/joy, ap/cmd_vel and ap/cmd_gps_pose are provided.

Unfortunately, it seems like none of them can enable me to send thrust + attitude commands. But I believe it should be possible, as there is already a function void AC_AttitudeControl::input_thrust_vector_heading(const Vector3f& thrust_vector, float heading_angle_cd, float heading_rate_cds), which is defined in ardupilot/libraries/AC_AttitudeControl /AC_AttitudeControl_Multi.cpp.

HI @robin_drone,

I think RyanF is probably best place to help here.

One thing I can add is we have the GUID_OPTIONS parameter that affects how mavlink SET_ATTITUDE_TARGET messages are interpreted (it changes whether the “thrust” field is interpreted as thrust or climb-rate. This may be unrelated though.

Thanks for the input. This isn’t yet supported. Please create an issue on Github, tag me me with the request (ryanf55) on Github, and we can work out a message definition suitable for the application. Once we have a suitable message chosen, it would be much appreciated if you wanted to contribute a feature for it.

Cheers!

1 Like

Thanks for your reply. Yes, that should be considered in ROS2 interface.

@rfriedman , thanks so much for your reply.

Yes, I am willing to help on this. Now, I am on holiday, let me create the request when I am back to work :).

1 Like

Here’s some related work from @snktshrma

@rfriedman , I am still working on this. Do you know if there is someone else interested in or working on that?

Just work it out with @snktshrma - it doens’t matter to me who finishes the feature. Whoever has time is ok.

Hi @robin_drone ! So individual Motor Control works fine and is complete. Here’s the PR:

For attitude and thrust control, I started it out but yet to complete. I’ll try to complete it this week. In any case, if you want to use direct motor control, feel free to use my PR.

Hi @snktshrma , sorry to reply so late. How is it going? Are you still working on thrust and attitude control?

Hi @robin_drone ! So the thrust and attitude code is done but there are changes to be done to XRCE c codegen. I did not get time to work on the codegen part. I’ll complete that over this weekend.

For the AP related changes, here it is: Commits · snktshrma/ardupilot · GitHub

1 Like

@snktshrma Hey, I had some doubts regarding how your code works. Is your code specifically for external controllers other than the autopilot board running ArduCopter?

Also, how does one control the thruster PWM of the ArduCopter board, say a Pixhawk 4, within a ROS 2 network?