Hi guys, I am trying to figure out how to control the actuators of a fixed-wing offboard. At the moment i am working in Gazebo, with mavros on PX4 1.9. Sadly i don’t really see a good solution yet.
Ideas that i have at the moment:
Preferred option Use the script manual_input.py from the Firmware github to immitate remote control inputs. I found a similar file for cpp on here, but it seems to be old.
Use the QGroundControl code that imitates a joystick and send joystick commands over the UDP port 14570 (see figure on here)
Do you have any better ideas? If you think one of my ideas are suitable, which one? Could you give me some hints or point me towards how i can proceed to get it working?
@vwueest Could you explain why you chose to control actuator setpoints? There are higher level commands that you can use already as you can see in this doc
@Jaeyoung-Lim We are doing a research project, where we need to control on the lowest level possible. We would like to skip all PID controllers, to have full control of the vehicle. So for attitude, we would like to be able to set the angular acceleration (omega_dot) or the set the position of the control surfaces (u) directly.
Since that’s essentially what remote control inputs do, i thought we can achieve that with idea 1. that i mentioned. However, i have the impression the code is deprecated (please correct if I’m wrong).
The other option is to do something similar to “Virtual Joystick” in QGroundControl.
Please let me know if you have any better ideas or tips on how to proceed. Thanks a lot
I did some more research on the topic. It seems that i can achieve just that by using the mavros topic /mavros/rc/overrice. However, i did not really find any documentation on it and did not see any effects when I did the following:
clone firmware, checkout version v1.9.2
run Gazebo with ROS wrapper as described in the px4 documentation (link), but adapt it to run the plane instead of the iris quad
Take off, put it in manual mode and published: rostopic pub -r 10 /mavros/rc/override mavros_msgs/OverrideRCIn '[2000, 2000, 2000, 2000, 2000, 2000, 2000, 2000]'
In the PX4 shell i see the message RC_CHANNELS message detected! come up, but there is no effect visible (propeller off, all control surface to initial position)
How does RC override work? Are there parameters I have to set that i have to set? Does anybody have experience with this?
Thanks for your help!
@vwueest Just as a note, the RC controls do not control the acceleration setpoints as you mentioned, but the actuator inputs.
On fixed wing the relationship with acceleration setpoint and actuator input is nonlinear and this is why using higher level outputs generally result in better control tracking since the flight controller takes care of the input tracking.
@Jaeyoung-Lim yes you are right. Thanks for the note
We would still like to control the actuators eventually, as we are trying to combine low and high level control commands into one as a research project.
It seems that rc/override is not recommended and does not work for me yet. Is there another way I can achieve this, any tips? Maybe with these topics: actuator_control, manual_control/send? I myself did not have any success yet. Please let me know if anyone did or has an idea how
In the meantime I have tried to send higher level commands (I tried setpoint_position/local, setpoint_raw/attitude & mavros/setpoint_velocity/cmd_vel) as you suggested. They work well on the iris quadrotor, but I don’t have any success on the gazebo plane in PX4 v1.9.2. I can switch to offboard mode, but the plane just keeps doing what it was or even sets all actuators to the initial state when sending attitude/thrust comands (sets thrust to 0 for some reason).
Because i once read offboard was not supported in that version, I wanted to try v1.10. There are 2 issues that came up:
When i freshly clone the firmware, check it out at v1.10.0-beta4, and try to build it with make px4_sitl_default gazebo_plane, the build crashes with the output:
(I am running Ubuntu 18.04.3, ROS melodic, Gazebo 9.0.0)
I found this commit from you @Jaeyoung-Lim. I tried to copy these changes into v1.9.2, to allow offboard mode for fixed wings in v1.9.2. Even then, same results as mentioned above.
How can i use command the plane? Am i missing somethings? It feels like this should not be that hard. Any help appreciated
@Jaeyoung-Lim the build also crashes with the same error message when I checkout v1.10.0-beta4 and run
make px4_sitl gazebo_plane
Do you have an example you could point me to about actuator_control? I tried publishing on /mavros/actuator_control and /mavros/target_actuator_control. Neither had an effect on the plane
v1.9.2: SITL compiles and works for plane & quadrotor. Offboard only works for quadrotor
v1.10.0: does not compile (none of the beta or rc) on my system (Ubuntu 18.04.3, ROS melodic, Gazebo 9.0.0). All make commands (make px4_sitl gazebo, gazebo_plane, gazebo_iris) fail with the same error message:
-- Found GStreamer: adding gst_camera_plugin
[ 13%] Building CXX object msg/CMakeFiles/uorb_msgs.dir/topics_sources/commander_state.cpp.o
-- Found GStreamer: adding gst_video_stream_widget
CMake Error: The following variables are used in this project, but they are set to NOTFOUND.
Please set them or make sure they are set and tested correctly in the CMake files:
GSTREAMER_LIBRARIES (ADVANCED)
linked by target "LiftDragPlugin" in directory /home/valentin/temp3/Firmware/Tools/sitl_gazebo
linked by target "gazebo_video_stream_widget" in directory /home/valentin/temp3/Firmware/Tools/sitl_gazebo
linked by target "gazebo_gst_camera_plugin" in directory /home/valentin/temp3/Firmware/Tools/sitl_gazebo
linked by target "gazebo_barometer_plugin" in directory /home/valentin/temp3/Firmware/Tools/sitl_gazebo
linked by target "gazebo_magnetometer_plugin" in directory /home/valentin/temp3/Firmware/Tools/sitl_gazebo
linked by target "gazebo_multirotor_base_plugin" in directory /home/valentin/temp3/Firmware/Tools/sitl_gazebo
linked by target "gazebo_motor_model" in directory /home/valentin/temp3/Firmware/Tools/sitl_gazebo
linked by target "gazebo_mavlink_interface" in directory /home/valentin/temp3/Firmware/Tools/sitl_gazebo
linked by target "gazebo_gimbal_controller_plugin" in directory /home/valentin/temp3/Firmware/Tools/sitl_gazebo
linked by target "physics_msgs" in directory /home/valentin/temp3/Firmware/Tools/sitl_gazebo
linked by target "nav_msgs" in directory /home/valentin/temp3/Firmware/Tools/sitl_gazebo
linked by target "gazebo_wind_plugin" in directory /home/valentin/temp3/Firmware/Tools/sitl_gazebo
linked by target "gazebo_imu_plugin" in directory /home/valentin/temp3/Firmware/Tools/sitl_gazebo
linked by target "std_msgs" in directory /home/valentin/temp3/Firmware/Tools/sitl_gazebo
linked by target "gazebo_opticalflow_plugin" in directory /home/valentin/temp3/Firmware/Tools/sitl_gazebo
linked by target "gazebo_sonar_plugin" in directory /home/valentin/temp3/Firmware/Tools/sitl_gazebo
linked by target "sensor_msgs" in directory /home/valentin/temp3/Firmware/Tools/sitl_gazebo
linked by target "gazebo_gps_plugin" in directory /home/valentin/temp3/Firmware/Tools/sitl_gazebo
linked by target "mav_msgs" in directory /home/valentin/temp3/Firmware/Tools/sitl_gazebo
linked by target "gazebo_irlock_plugin" in directory /home/valentin/temp3/Firmware/Tools/sitl_gazebo
linked by target "gazebo_lidar_plugin" in directory /home/valentin/temp3/Firmware/Tools/sitl_gazebo
linked by target "gazebo_uuv_plugin" in directory /home/valentin/temp3/Firmware/Tools/sitl_gazebo
linked by target "gazebo_vision_plugin" in directory /home/valentin/temp3/Firmware/Tools/sitl_gazebo
linked by target "gazebo_geotagged_images_plugin" in directory /home/valentin/temp3/Firmware/Tools/sitl_gazebo
linked by target "gazebo_controller_interface" in directory /home/valentin/temp3/Firmware/Tools/sitl_gazebo
-- Configuring incomplete, errors occurred!
See also "/home/valentin/temp3/Firmware/build/px4_sitl_default/build_gazebo/CMakeFiles/CMakeOutput.log".
See also "/home/valentin/temp3/Firmware/build/px4_sitl_default/build_gazebo/CMakeFiles/CMakeError.log".
platforms/posix/CMakeFiles/sitl_gazebo.dir/build.make:105: recipe for target 'external/Stamp/sitl_gazebo/sitl_gazebo-configure' failed
make[4]: *** [external/Stamp/sitl_gazebo/sitl_gazebo-configure] Error 1
CMakeFiles/Makefile2:14156: recipe for target 'platforms/posix/CMakeFiles/sitl_gazebo.dir/all' failed
make[3]: *** [platforms/posix/CMakeFiles/sitl_gazebo.dir/all] Error 2
make[3]: *** Waiting for unfinished jobs....
B) Is there something else I have to do besides publishing on the actuator_control topic? Do I have to switch to OFFBOARD mode? Are there parameters to be set?
When i publish actuator_control and then switch to
MANUAL: no effect, all actuators go to their zero position/throttle
OFFBOARD: the simulation freezes (quadrotor & plane)
I set group_mix to PX4_MIX_FLIGHT_CONTROL and also tried PX4_MIX_MANUAL_PASSTHROUGH - no effect.
I looked at the CPU usage and my computer was not even close to its limits in any of the cores. I think there must be another issue, which seems to be related to disabling the lockstep. Is this a bug in the firmware? How could i solve this issue? Let me know if you have any ideas please
Did you find any solution to the accelerometer and gyroscope error messages?
I am also trying to send actuator_control values (in JMAVSim simulation) in offboard mode by disabling lockstep but I get these error messages. I have also observed that the quad is less stable than with lockstep enabled and it drifts drastically when exiting offboard mode.
Yes, I did kind of find a solution. I left the lockstep enabled, used PX4 V1.10.1 and have tested it also on v1.10.0-rc3. The essential thing is that you have to publish at >=150Hz, otherwise the lockstep locks the simulation.
So what I did is, I sent actuator controls like this:
I am using a cpp node to publish commands at 200 Hz to the topic /mavros/actuator_control. I tried it on both Gazebo and JMAVSim, but PX4 is not accepting the actuator control messages.
Are you using command line to publish the messages and set offboard mode?
I tried again and you’re right in that it didn’t work for me anymore. However, i didn’t see these errors. It could have to do with some parameter setting.
I was able to get it running by starting the sim with this launch file:
Hope this works for you. I am not entirely sure what’s the difference between the roslaunch px4 posix_sitl.launch vehicle:= plane and my launch file, but my file worked for the plane, while the px4 official one did not.