I’m simulating a blimp in offboard mode using PX4, Gazebo Harmonic and ROS2 Humble. I need to have reversible motors to be able to stop the blimp.
I’m currently using the ActuatorMotors uORB topic to send offboard commands directly to the actuators in PX4 and it works properly, unless I set them to reversible.
When setting them to reversible, I’m able to send negative actuator commands but the -1.0 is capped at the minimum rotational speed and the 1.0 is capped at maximum rotaional speed, it never reverses direction. The min/max ESC parameter values can only be set between 0-1000 (SIM_GZ_EC_MIN1 and SIM_GZ_EC_MAX1) and when setting the disarmed value to 500 ( SIM_GZ_EC_DIS1), to have the mid point/neutral be at 500 and negative thrust <500, the motors spin when disarmed.
Here is my parameter file for my custom airframe:
#!/bin/sh
#
# @name Cavernaute
# @type Airship
# @class Airship
#
# @output Motor1 starboard thruster
# @output Motor2 port thruster
# @output Motor3 tail thruster
# @output Servo1 thrust tilt
. ${R}etc/init.d/rc.airship_defaults
PX4_SIMULATOR=${PX4_SIMULATOR:=gz}
PX4_GZ_WORLD=${PX4_GZ_WORLD:=default}
PX4_SIM_MODEL=${PX4_SIM_MODEL:=cavernaute}
param set-default SIM_GZ_EN 1
param set-default CA_AIRFRAME 9
param set-default COM_ARM_CHK_ESCS 0
param set-default COM_PREARM_MODE 2
param set-default RWTO_MAX_THR 0.0
param set-default COM_MODE_ARM_CHK 1
param set-default COM_RCL_EXCEPT 6
param set-default COM_RC_IN_MODE 1
param set-default CA_R_REV 15
param set_default PWM_MAIN_REV 15
param set-default CA_ROTOR_COUNT 4
param set-default CA_ROTOR0_AX 1
param set-default CA_ROTOR0_PY 0.435
param set-default CA_ROTOR1_AX 1
param set-default CA_ROTOR1_PY -0.3919
param set-default CA_ROTOR1_PX -0.1887
param set-default CA_ROTOR2_AY 1
param set-default CA_ROTOR2_PX -0.3893
param set-default CA_ROTOR2_PY -0.0888
param set-default CA_ROTOR2_PZ -0.61325
param set-default CA_ROTOR3_AZ 1
param set-default CA_ROTOR3_PZ 1.3325
param set-default SIM_GZ_EC_FUNC1 101
param set-default SIM_GZ_EC_FUNC2 102
param set-default SIM_GZ_EC_FUNC3 103
param set-default SIM_GZ_EC_FUNC4 104
param set-default SIM_GZ_EC_MIN1 1
param set-default SIM_GZ_EC_MIN2 1
param set-default SIM_GZ_EC_MIN3 1
param set-default SIM_GZ_EC_MIN4 1
param set-default SIM_GZ_EC_MAX1 1000
param set-default SIM_GZ_EC_MAX2 1000
param set-default SIM_GZ_EC_MAX3 1000
param set-default SIM_GZ_EC_MAX4 1000
param set-default EKF2_HGT_REF 2
param set-default EKF2_RNG_CTRL 2
param set-default EKF2_BARO_CTRL 0
param set-default MPC_ALT_MODE 2
param set-default EKF2_RNG_POS_Y 0.3
param set-default SYS_HAS_BARO 0
param set-default SYS_HAS_GPS 0
param set-default COM_ARM_WO_GPS 2
and the code from my control loop generating the velocity commands. I have 4 motors and all four are reversible:
# Publish motor velocity commands vel_msg = ActuatorMotors() vel_msg.timestamp = int(Clock().now().nanoseconds / 1000) vel_msg.timestamp = int(Clock().now().nanoseconds / 1000) vel_msg.reversible_flags = 15 vel_msg.control = [1.0, 1.0, 0.0, self.pd_controller()] + [0.0] * 8 self.publisher_actuator_motors.publish(vel_msg)