The first quick and dirty implementation was done on the companion computer using a ROS2 Node (see [[Direct Actuator Control from ROS2]]). But this will use too much bandwidth on the datalink between the flight controller and the companion computer. # PX4 Implementation We want to be able to open and close the payload bay even if the drone is not armed. Therefore, we need to make use of the pre-arm state that exists in order to check the functionality of non-dangerous [[Actuators |actuators]] (e.g. control surfaces. not motors/propellers). The arm, disarm and pre-arm configuration is explained on the [PX4 user guide](https://docs.px4.io/main/en/advanced_config/prearm_arm_disarm.html). We want the following parameters: | Parameter | Description | Value | | ---- | ---- | ---- | | COM_PREARM_MODE | ALWAYS | 2 | | CBRK_IO_SAFETY | No Safety Switch | 22027 | This puts the drone into the pre-arm state upon boot and allows to move the control surfaces immediately, without engaging the propellers. ## PWM Calibration The payload servos should be calibrated like any other servo motor. We need to configure the following parameters (assuming the servo is MAIN_5): | Parameter | Description | Value | | ---- | ---- | ---- | | PWM\_MAIN\_DIS5 | PWM value in disarm state | e.g. 1500 | | PWM\_MAIN\_FAIL5 | PWM Value in failsafe state | e.g 1500 | | PWM\_MAIN\_MAX5 | Maximum PWM value commanded | e.g. 1958 | | PWM\_MAIN\_MIN5 | Minimum PWM value commanded | e.g. 867 | The values are usually experimentally measured using a simple PWM controller (aka. servo tester). ## Payload Controller Module