---
# System prepended metadata

title: GBU Project work note
tags: [PX4, NCKU UAV, GBU_Proj]

---

# GBU Project work note
###### tags: `PX4` `NCKU UAV` `GBU_Proj`

## Px4 servo release test 
### work note 0507
* First run mavros
`$ roslaunch gbu_project px4.launch`

* In order to control the aux servo from mavors, 'OFFBOARD' flight mode must be activated

    We disable almost all the pre-arm check critria from QG, includes GPS check, magnetometer consistence check and usb check ... etc.

    Then ARM the flight controller.

    Another criteria for entering the 'OFFBOARD' mode is that the setpoints are published continuously from the companion computer (Odroid). Thus we have to make a fake set point signal from rostopic pub in 10 Hz:
    `$ rostopic pub /mavros/setpoint_position/local geometry_msgs/PoseStamped '{header: {stamp: now, frame_id: bask_link}, pose: {position: [0,0,0], orientation: [0,0,0,1]}}' -r 10`

* Then we can set flight mode to 'OFFBOARD' from rosservice
    `rosservice call /mavros/set_mode 0 'OFFBOARD'`
    
* After the 'OFFBOARD' mode is set, publish the actuator control command
    `rostopic pub /mavros/actuator_control mavros_msgs/ActuatorControl '{stamp: now, frame_id: base_link}' 3 '[0, 0, 0, 0, 0, 0.5, 0, 0]' -r 1`
    * The servo for tested is at port AUX1, which is at no.6 signal of control group 3
    * The number of the control signal is from -1 to +1.
    
:::warning
We found that actually the actuator control function overrides the RC control commands, which results a jittering servo when there is RC data input at the same time.
The servo stop jittering once we turn off the RC transmitter.
It is discovered that the AUX1 port is assigned or mapped to some rc inputs by the actuator mixer. The possible solution will be a custom mixer to assign other control groups, i.e. group 2 & 6 for gimbal & payload (from px4 dev page), to a aux output pin.
:::

reference:
[rostopic](http://wiki.ros.org/ROS/Tutorials/UnderstandingTopics)
[mavros_msgs/ActuatorControl](http://docs.ros.org/api/mavros_msgs/html/msg/ActuatorControl.html)
[mavros_msgs](http://wiki.ros.org/mavros_msgs)
[mavros](http://wiki.ros.org/mavros)

-------------------------
## Arduino Nano33 Ble test

* [mbedOS](https://maker.pro/arduino/tutorial/how-to-use-mbed-rtos-features-on-the-arduino-nano-33-ble)
* [MadgwickAHRS](https://github.com/arduino-libraries/MadgwickAHRS)
    *  [error] include <CurieIMU.h> no such file. need "corelibs-arduino101"l, but i don't know where to put the foler