Kernel Recipes 2015 - The Dronecode Project – A step in open source drones

40
The DroneCode Project - A Step in Open Source Drones Julien BERAUD October 5, 2015 The DroneCode Project - A Step in Open Source Drones 1 / 21

Transcript of Kernel Recipes 2015 - The Dronecode Project – A step in open source drones

Page 1: Kernel Recipes 2015 - The Dronecode Project – A step in open source drones

The DroneCode Project - A Step in OpenSource Drones

Julien BERAUD

October 5, 2015

The DroneCode Project - A Step in Open Source Drones 1 / 21

Page 2: Kernel Recipes 2015 - The Dronecode Project – A step in open source drones

The DroneCode Project

”An open source, collaborative project thatbrings together existing and future opensource drone projects under a nonprofitstructure governed by The Linux Foundation.The result will be a common, shared opensource platform for Unmanned AerialVehicles (UAVs).”

The DroneCode Project - A Step in Open Source Drones 2 / 21

Page 3: Kernel Recipes 2015 - The Dronecode Project – A step in open source drones

DroneCode Software

The DroneCode Project - A Step in Open Source Drones 3 / 21

Page 4: Kernel Recipes 2015 - The Dronecode Project – A step in open source drones

Parrot Drones 1/3

▶ Parrot AR Drone▶ Parrot 6 SoC - ARM926EJS▶ Linux Kernel▶ Busybox

The DroneCode Project - A Step in Open Source Drones 4 / 21

Page 5: Kernel Recipes 2015 - The Dronecode Project – A step in open source drones

Parrot Drones 2/3

▶ Parrot AR Drone 2.0▶ TI OMAP3630 - ARM Cortex-A8▶ Linux Kernel▶ Busybox

The DroneCode Project - A Step in Open Source Drones 5 / 21

Page 6: Kernel Recipes 2015 - The Dronecode Project – A step in open source drones

Parrot Drones 3/3

▶ Parrot Bebop▶ Parrot 7 SoC - Dual Cortex-A9▶ Linux Kernel▶ Busybox

The DroneCode Project - A Step in Open Source Drones 6 / 21

Page 7: Kernel Recipes 2015 - The Dronecode Project – A step in open source drones

Drone Software

▶ Drone Software▶ Drone OnBoard Software▶ Computer/Smartphone/Tablet Software▶ Cloud Software▶ Protocols to bind them together

▶ Parrot Drones OnBoard Software▶ Custom Proprietary Flight Stack▶ Running entirely on Linux▶ No PREEMPT_RT Patch▶ Quite different from other existing drones

The DroneCode Project - A Step in Open Source Drones 7 / 21

Page 8: Kernel Recipes 2015 - The Dronecode Project – A step in open source drones

Drone Software

▶ Drone Software▶ Drone OnBoard Software▶ Computer/Smartphone/Tablet Software▶ Cloud Software▶ Protocols to bind them together

▶ Parrot Drones OnBoard Software▶ Custom Proprietary Flight Stack▶ Running entirely on Linux▶ No PREEMPT_RT Patch▶ Quite different from other existing drones

The DroneCode Project - A Step in Open Source Drones 7 / 21

Page 9: Kernel Recipes 2015 - The Dronecode Project – A step in open source drones

DroneCode OnBoard Software▶ OnBoard Software

▶ The Flight Stack▶ Specific to Drones▶ 2 Flight Stacks are part of the DroneCode Project

The DroneCode Project - A Step in Open Source Drones 8 / 21

Page 10: Kernel Recipes 2015 - The Dronecode Project – A step in open source drones

DroneCode OnBoard Software▶ OnBoard Software

▶ The Flight Stack▶ Specific to Drones▶ 2 Flight Stacks are part of the DroneCode Project

The DroneCode Project - A Step in Open Source Drones 8 / 21

Page 11: Kernel Recipes 2015 - The Dronecode Project – A step in open source drones

Dronecode Flight Stacks

▶ APM or Ardupilot - http://dev.ardupilot.com/

▶ GPLv3 License▶ First developed to run on an Arduino

▶ PX4 - https://pixhawk.org/dev/start

▶ BSD License▶ First developed to run on an STM32 microcontroller▶ Originally developed to run on top of NuttX RTOS

The DroneCode Project - A Step in Open Source Drones 9 / 21

Page 12: Kernel Recipes 2015 - The Dronecode Project – A step in open source drones

Dronecode Flight Stacks

▶ APM or Ardupilot - http://dev.ardupilot.com/

▶ GPLv3 License▶ First developed to run on an Arduino

▶ PX4 - https://pixhawk.org/dev/start

▶ BSD License▶ First developed to run on an STM32 microcontroller▶ Originally developed to run on top of NuttX RTOS

The DroneCode Project - A Step in Open Source Drones 9 / 21

Page 13: Kernel Recipes 2015 - The Dronecode Project – A step in open source drones

OpenSource Linux drones appearing

▶ January 2015 - Andrew Tridgell at LCA▶ Article on LWN - https://lwn.net/Articles/630018/▶ Drone running Linux with the APM flight stack▶ BeagleBone Black with Pixhawk Fire Cape

▶ Several Linux boards supported natively in APM▶ BeagleBone with Pixhawk Fire Cape▶ Erle Brain▶ NavIO

▶ Qualcomm starting to work on PX4 port on Linux

The DroneCode Project - A Step in Open Source Drones 10 / 21

Page 14: Kernel Recipes 2015 - The Dronecode Project – A step in open source drones

Drone Architecture

▶ QuadCopter▶ Impossible to fly entirely manually - Autopilot▶ Sensors, user commands▶ Motor speeds

▶ Ardupilot▶ Reads from sensors▶ Enhanced Kalmann Filter(EKF)▶ Estimate the state of the Drone

▶ Sensors▶ Inertial Measurement Unit (IMU)▶ Barometer▶ Compass▶ GPS, Optical Flow Sensor, Sonar, ...

▶ External microcontroller for motor control

The DroneCode Project - A Step in Open Source Drones 11 / 21

Page 15: Kernel Recipes 2015 - The Dronecode Project – A step in open source drones

Drone Architecture

▶ QuadCopter▶ Impossible to fly entirely manually - Autopilot▶ Sensors, user commands▶ Motor speeds

▶ Ardupilot▶ Reads from sensors▶ Enhanced Kalmann Filter(EKF)▶ Estimate the state of the Drone

▶ Sensors▶ Inertial Measurement Unit (IMU)▶ Barometer▶ Compass▶ GPS, Optical Flow Sensor, Sonar, ...

▶ External microcontroller for motor control

The DroneCode Project - A Step in Open Source Drones 11 / 21

Page 16: Kernel Recipes 2015 - The Dronecode Project – A step in open source drones

Drone Architecture

▶ QuadCopter▶ Impossible to fly entirely manually - Autopilot▶ Sensors, user commands▶ Motor speeds

▶ Ardupilot▶ Reads from sensors▶ Enhanced Kalmann Filter(EKF)▶ Estimate the state of the Drone

▶ Sensors▶ Inertial Measurement Unit (IMU)▶ Barometer▶ Compass▶ GPS, Optical Flow Sensor, Sonar, ...

▶ External microcontroller for motor control

The DroneCode Project - A Step in Open Source Drones 11 / 21

Page 17: Kernel Recipes 2015 - The Dronecode Project – A step in open source drones

Drone Architecture

▶ QuadCopter▶ Impossible to fly entirely manually - Autopilot▶ Sensors, user commands▶ Motor speeds

▶ Ardupilot▶ Reads from sensors▶ Enhanced Kalmann Filter(EKF)▶ Estimate the state of the Drone

▶ Sensors▶ Inertial Measurement Unit (IMU)▶ Barometer▶ Compass▶ GPS, Optical Flow Sensor, Sonar, ...

▶ External microcontroller for motor control

The DroneCode Project - A Step in Open Source Drones 11 / 21

Page 18: Kernel Recipes 2015 - The Dronecode Project – A step in open source drones

Parrot Bebop Architecture

The DroneCode Project - A Step in Open Source Drones 12 / 21

Page 19: Kernel Recipes 2015 - The Dronecode Project – A step in open source drones

APM - https://github.com/diydrones/ardupilot

AP_HAL class

class AP_HAL::HAL {...

AP_HAL::UARTDriver* uartA;AP_HAL::UARTDriver* uartB;AP_HAL::UARTDriver* uartC;AP_HAL::UARTDriver* uartD;AP_HAL::UARTDriver* uartE;AP_HAL::I2CDriver* i2c;AP_HAL::I2CDriver* i2c1;AP_HAL::I2CDriver* i2c2;AP_HAL::SPIDeviceManager* spi;

...};

Userland drivershal.i2c1->write(BEBOP_BLDC_I2C_ADDR, 1, &data);

The DroneCode Project - A Step in Open Source Drones 13 / 21

Page 20: Kernel Recipes 2015 - The Dronecode Project – A step in open source drones

Drivers modifications▶ Baro - MS5607

▶ Existing driver for MS5611▶ Scaling factor

▶ Compass - AK8963▶ Existing driver for AL8963▶ Only as a slave device for an IMU▶ Implement the use of a direct connection on i2c

▶ IMU▶ MPU6050 in i2c instead of spi▶ No PREEMPT_RT patch▶ Jitter issues▶ Implement the use of the MPU6050 FIFO

▶ Motor Controller▶ New driver to write▶ Added in AP_HAL_Linux▶ Implements the RCOutput class

▶ GPS almost supported▶ Add frames / Fixes

The DroneCode Project - A Step in Open Source Drones 14 / 21

Page 21: Kernel Recipes 2015 - The Dronecode Project – A step in open source drones

Drivers modifications▶ Baro - MS5607

▶ Existing driver for MS5611▶ Scaling factor

▶ Compass - AK8963▶ Existing driver for AL8963▶ Only as a slave device for an IMU▶ Implement the use of a direct connection on i2c

▶ IMU▶ MPU6050 in i2c instead of spi▶ No PREEMPT_RT patch▶ Jitter issues▶ Implement the use of the MPU6050 FIFO

▶ Motor Controller▶ New driver to write▶ Added in AP_HAL_Linux▶ Implements the RCOutput class

▶ GPS almost supported▶ Add frames / Fixes

The DroneCode Project - A Step in Open Source Drones 14 / 21

Page 22: Kernel Recipes 2015 - The Dronecode Project – A step in open source drones

Drivers modifications▶ Baro - MS5607

▶ Existing driver for MS5611▶ Scaling factor

▶ Compass - AK8963▶ Existing driver for AL8963▶ Only as a slave device for an IMU▶ Implement the use of a direct connection on i2c

▶ IMU▶ MPU6050 in i2c instead of spi▶ No PREEMPT_RT patch▶ Jitter issues▶ Implement the use of the MPU6050 FIFO

▶ Motor Controller▶ New driver to write▶ Added in AP_HAL_Linux▶ Implements the RCOutput class

▶ GPS almost supported▶ Add frames / Fixes

The DroneCode Project - A Step in Open Source Drones 14 / 21

Page 23: Kernel Recipes 2015 - The Dronecode Project – A step in open source drones

Drivers modifications▶ Baro - MS5607

▶ Existing driver for MS5611▶ Scaling factor

▶ Compass - AK8963▶ Existing driver for AL8963▶ Only as a slave device for an IMU▶ Implement the use of a direct connection on i2c

▶ IMU▶ MPU6050 in i2c instead of spi▶ No PREEMPT_RT patch▶ Jitter issues▶ Implement the use of the MPU6050 FIFO

▶ Motor Controller▶ New driver to write▶ Added in AP_HAL_Linux▶ Implements the RCOutput class

▶ GPS almost supported▶ Add frames / Fixes

The DroneCode Project - A Step in Open Source Drones 14 / 21

Page 24: Kernel Recipes 2015 - The Dronecode Project – A step in open source drones

Drivers modifications▶ Baro - MS5607

▶ Existing driver for MS5611▶ Scaling factor

▶ Compass - AK8963▶ Existing driver for AL8963▶ Only as a slave device for an IMU▶ Implement the use of a direct connection on i2c

▶ IMU▶ MPU6050 in i2c instead of spi▶ No PREEMPT_RT patch▶ Jitter issues▶ Implement the use of the MPU6050 FIFO

▶ Motor Controller▶ New driver to write▶ Added in AP_HAL_Linux▶ Implements the RCOutput class

▶ GPS almost supported▶ Add frames / Fixes

The DroneCode Project - A Step in Open Source Drones 14 / 21

Page 25: Kernel Recipes 2015 - The Dronecode Project – A step in open source drones

Motor Controller

RCOutput_Bebop

class Linux::LinuxRCOutput_Bebop : public AP_HAL::RCOutput {public:

LinuxRCOutput_Bebop();void init(void* dummy);void set_freq(uint32_t chmask, uint16_t freq_hz);uint16_t get_freq(uint8_t ch);void enable_ch(uint8_t ch);void disable_ch(uint8_t ch);void write(uint8_t ch, uint16_t period_us);void write(uint8_t ch, uint16_t* period_us, uint8_t len);uint16_t read(uint8_t ch);void read(uint16_t* period_us, uint8_t len);void set_esc_scaling(uint16_t min_pwm, uint16_t max_pwm);int read_obs_data(BebopBLDC_ObsData &data);

...

The DroneCode Project - A Step in Open Source Drones 15 / 21

Page 26: Kernel Recipes 2015 - The Dronecode Project – A step in open source drones

Motor Controller 2/2

set_ref_speed

void LinuxRCOutput_Bebop::_set_ref_speed(uint16_t rpm[BEBOP_BLDC_MOTORS_NUM])

{struct bldc_ref_speed_data data;int i;

data.cmd = BEBOP_BLDC_SETREFSPEED;for (i=0; i<BEBOP_BLDC_MOTORS_NUM; i++)

data.rpm[i] = htobe16(rpm[i]);

data.enable_security = 0;data.checksum = _checksum((uint8_t *) &data, sizeof(data) - 1);

if (!_i2c_sem->take(0))return;

hal.i2c1->write(BEBOP_BLDC_I2C_ADDR,sizeof(data),(uint8_t *)&data);

_i2c_sem->give();}

The DroneCode Project - A Step in Open Source Drones 16 / 21

Page 27: Kernel Recipes 2015 - The Dronecode Project – A step in open source drones

RCInput over Wi-Fi

Protocol#define RCINPUT_UDP_NUM_CHANNELS 8#define RCINPUT_UDP_VERSION 2

struct __attribute__((packed)) rc_udp_packet {uint32_t version;uint64_t timestamp_us;uint16_t sequence;uint16_t pwms[RCINPUT_UDP_NUM_CHANNELS];

};

▶ Basic linux utility written▶ joystick_remote

https://github.com/jberaud/joystick_remote▶ Using linux joystick input driver▶ Already ported on Parrot SkyController

The DroneCode Project - A Step in Open Source Drones 17 / 21

Page 28: Kernel Recipes 2015 - The Dronecode Project – A step in open source drones

RCInput over Wi-Fi

Protocol#define RCINPUT_UDP_NUM_CHANNELS 8#define RCINPUT_UDP_VERSION 2

struct __attribute__((packed)) rc_udp_packet {uint32_t version;uint64_t timestamp_us;uint16_t sequence;uint16_t pwms[RCINPUT_UDP_NUM_CHANNELS];

};

▶ Basic linux utility written▶ joystick_remote

https://github.com/jberaud/joystick_remote▶ Using linux joystick input driver▶ Already ported on Parrot SkyController

The DroneCode Project - A Step in Open Source Drones 17 / 21

Page 29: Kernel Recipes 2015 - The Dronecode Project – A step in open source drones

Trying to fly

▶ First flight = crash▶ Logging system used to understand the reason of the crash.▶ Log files sent to one of the maintainers▶ Log Analysis

▶ All sensor datas▶ All interesting values▶ Possibility to find the cause of a problem

▶ Solution found▶ The order of the motors wasn’t right

The DroneCode Project - A Step in Open Source Drones 18 / 21

Page 30: Kernel Recipes 2015 - The Dronecode Project – A step in open source drones

Trying to fly

▶ First flight = crash▶ Logging system used to understand the reason of the crash.▶ Log files sent to one of the maintainers▶ Log Analysis

▶ All sensor datas▶ All interesting values▶ Possibility to find the cause of a problem

▶ Solution found▶ The order of the motors wasn’t right

The DroneCode Project - A Step in Open Source Drones 18 / 21

Page 31: Kernel Recipes 2015 - The Dronecode Project – A step in open source drones

Trying to fly

▶ First flight = crash▶ Logging system used to understand the reason of the crash.▶ Log files sent to one of the maintainers▶ Log Analysis

▶ All sensor datas▶ All interesting values▶ Possibility to find the cause of a problem

▶ Solution found▶ The order of the motors wasn’t right

The DroneCode Project - A Step in Open Source Drones 18 / 21

Page 32: Kernel Recipes 2015 - The Dronecode Project – A step in open source drones

Trying to fly

▶ First flight = crash▶ Logging system used to understand the reason of the crash.▶ Log files sent to one of the maintainers▶ Log Analysis

▶ All sensor datas▶ All interesting values▶ Possibility to find the cause of a problem

▶ Solution found▶ The order of the motors wasn’t right

The DroneCode Project - A Step in Open Source Drones 18 / 21

Page 33: Kernel Recipes 2015 - The Dronecode Project – A step in open source drones

Log Analysis▶ Motors order

▶ Cause of the crash

The DroneCode Project - A Step in Open Source Drones 19 / 21

Page 34: Kernel Recipes 2015 - The Dronecode Project – A step in open source drones

Submitting patches to master

▶ Discussions with Tridge▶ A bit of reworking▶ Patches got accepted▶ 1 month of work▶ 17 patches submitted for the basic support▶ Coming up next

▶ Wiki page for users to hack their bebop▶ Currently missing sensor support▶ Integration as an alternative to our flight stack

▶ Benefits▶ Performance comparison▶ Access to the dronecode ecosystem▶ New piloting modes

The DroneCode Project - A Step in Open Source Drones 20 / 21

Page 35: Kernel Recipes 2015 - The Dronecode Project – A step in open source drones

Submitting patches to master

▶ Discussions with Tridge▶ A bit of reworking▶ Patches got accepted▶ 1 month of work▶ 17 patches submitted for the basic support▶ Coming up next

▶ Wiki page for users to hack their bebop▶ Currently missing sensor support▶ Integration as an alternative to our flight stack

▶ Benefits▶ Performance comparison▶ Access to the dronecode ecosystem▶ New piloting modes

The DroneCode Project - A Step in Open Source Drones 20 / 21

Page 36: Kernel Recipes 2015 - The Dronecode Project – A step in open source drones

Submitting patches to master

▶ Discussions with Tridge▶ A bit of reworking▶ Patches got accepted▶ 1 month of work▶ 17 patches submitted for the basic support▶ Coming up next

▶ Wiki page for users to hack their bebop▶ Currently missing sensor support▶ Integration as an alternative to our flight stack

▶ Benefits▶ Performance comparison▶ Access to the dronecode ecosystem▶ New piloting modes

The DroneCode Project - A Step in Open Source Drones 20 / 21

Page 37: Kernel Recipes 2015 - The Dronecode Project – A step in open source drones

Submitting patches to master

▶ Discussions with Tridge▶ A bit of reworking▶ Patches got accepted▶ 1 month of work▶ 17 patches submitted for the basic support▶ Coming up next

▶ Wiki page for users to hack their bebop▶ Currently missing sensor support▶ Integration as an alternative to our flight stack

▶ Benefits▶ Performance comparison▶ Access to the dronecode ecosystem▶ New piloting modes

The DroneCode Project - A Step in Open Source Drones 20 / 21

Page 38: Kernel Recipes 2015 - The Dronecode Project – A step in open source drones

Conclusion

▶ Useful links▶ http://dev.ardupilot.com/▶ https://github.com/diydrones▶ https://github.com/jberaud▶ https://pixhawk.org

▶ Parrot is recruiting▶ Linux userland and kernel developers▶ Android Java developers▶ iOS developers

▶ Questions ?

The DroneCode Project - A Step in Open Source Drones 21 / 21

Page 39: Kernel Recipes 2015 - The Dronecode Project – A step in open source drones

Conclusion

▶ Useful links▶ http://dev.ardupilot.com/▶ https://github.com/diydrones▶ https://github.com/jberaud▶ https://pixhawk.org

▶ Parrot is recruiting▶ Linux userland and kernel developers▶ Android Java developers▶ iOS developers

▶ Questions ?

The DroneCode Project - A Step in Open Source Drones 21 / 21

Page 40: Kernel Recipes 2015 - The Dronecode Project – A step in open source drones

Conclusion

▶ Useful links▶ http://dev.ardupilot.com/▶ https://github.com/diydrones▶ https://github.com/jberaud▶ https://pixhawk.org

▶ Parrot is recruiting▶ Linux userland and kernel developers▶ Android Java developers▶ iOS developers

▶ Questions ?

The DroneCode Project - A Step in Open Source Drones 21 / 21