linux xenomai uav platform. · how can tasks migrate between the linux and xenomai domains? •...

15
Technology for a better society 1 Hard realtime sensor platform for: MSPIL (Mobile Sensor Platform Innovation Lab) AMOS (Autonomous Marine Operations and Systems) AUV (Autonomous Underwater Vehicle) UAV (Unmanned Aerial Vehicle) Linux Xenomai UAV Sensor platform. IDI 20150519 Terje Frøysa Strategic Institute Projects (SIP)

Upload: others

Post on 04-Jul-2020

6 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: Linux Xenomai UAV platform. · How can tasks migrate between the Linux and Xenomai domains? • Derives real‐time threads from regular Linux tasks through standard POSIX API. •

Technology for a better society 1

Hard real‐time sensor platform for:

MSPIL (Mobile Sensor Platform Innovation Lab)AMOS (Autonomous Marine Operations and Systems)

AUV (Autonomous Underwater Vehicle) UAV (Unmanned Aerial Vehicle)

Linux Xenomai UAV Sensor platform.IDI 2015‐05‐19

Terje Frøysa

Strategic Institute Projects (SIP)

Page 2: Linux Xenomai UAV platform. · How can tasks migrate between the Linux and Xenomai domains? • Derives real‐time threads from regular Linux tasks through standard POSIX API. •

Technology for a better society 2

Sensors for UAV/AUV• GPS (Global Positioning System) / GLONASS (GLObal NAvigation Satellite System)

Swarm Radio

• Tactical Grade Ten Degrees of Freedom Inertial Sensor (IMU)• Gyro‐meter/Barometer/Magnetometer• Swarm Radio (intra swarm position/communication)

GPSGyro‐meterBarometerMagnetometer

IDI 2015‐05‐19

GPS

Processor

Sensor system hardware

Page 3: Linux Xenomai UAV platform. · How can tasks migrate between the Linux and Xenomai domains? • Derives real‐time threads from regular Linux tasks through standard POSIX API. •

Technology for a better society 3

Requirements• Hard real‐time• Multi tasking• Sufficient I/O capabilities• Sufficient computing power• Low weight

Embedded prosessor (COTS)• Beaglebone Black 

(Sitara 1GHz Cortex A8)• Open source design.• Hard real‐time?

OS• Linux (preferred over commercial OS'es)

• Versatile, open source, large community.• No hard real‐time (1‐25ms latency)

• Xenomai (Provides hard real‐time to Linux)

Prosessor and OS IDI 2015‐05‐19

Page 4: Linux Xenomai UAV platform. · How can tasks migrate between the Linux and Xenomai domains? • Derives real‐time threads from regular Linux tasks through standard POSIX API. •

Technology for a better society 4

ArchitecturesIDI 2015‐05‐19

User process

SpesificHardwareprocesses

User mode

Kernel process

Device driver OS kernel

Hardware Abstraction Layer (HAL)

CPU + motherboard

Software

Hardware

Linux Real‐time Linux‐Xenomai

devicedriver

Xenomai services

Xenomai tasks Linux threads/processes

Linux servicesReal‐time devicedriver

Xenomai kernel OS kernel

Hardware Abstraction Layer (HAL)

ADEOS (Interrupt pipeline)SpesificHardwareprocesses

CPU + motherboard SpesificHardwareprocesses

Obtaining real‐time by introducing• A micro kernel module.• An interrupt pipeline.• A real‐time device driver standard (RTDM).

Page 5: Linux Xenomai UAV platform. · How can tasks migrate between the Linux and Xenomai domains? • Derives real‐time threads from regular Linux tasks through standard POSIX API. •

Technology for a better society 5

Xenomai evolutionIDI 2015‐05‐19

Xenomai 2 dual‐core

Xenomai 3 Cobalt dual‐core

Xenomai 3 Mercury single‐core

RTAI

Preemptive Linux

2001

Page 6: Linux Xenomai UAV platform. · How can tasks migrate between the Linux and Xenomai domains? • Derives real‐time threads from regular Linux tasks through standard POSIX API. •

Technology for a better society 6

Xenomai system callsIDI 2015‐05‐19

VxWorks applicationlibvxworks glibc

VxWorks skin

VxWorks syscalls Xenomainucleus

Regular LinuxSub‐system(I/O,VM..etc)

Linux syscalls

I‐pipeinterposition

: User space: Kernel space

• Xenomai offers API skins to allow porting applications from other RTOS without rewriting.

• Xenomai libraries are equivalent to glibc but the calls are routed to the proper skin emulator.

• Xenomai intercepts the regular Linux system call dispatcher by means of the I‐pipe.

Page 7: Linux Xenomai UAV platform. · How can tasks migrate between the Linux and Xenomai domains? • Derives real‐time threads from regular Linux tasks through standard POSIX API. •

Technology for a better society 7

Xenomai and ADEOSADEOS (Adaptive Domain Environment for Operating System) / I‐pipe• A Linux kernel patch• A resource virtualization layer.• Allows Xenomai and Linux to run on the same hardware platform.• Introduces the event pipeline, a chain of domains (OS'es) of decreasing priority.

IDI 2015‐05‐19

Interrupts& Traps (kernel events)

Xenomaidomain

Lowest priority

Linux (root)domain

Domain events

Event flow pipeline

InterruptShield

Virtual irq mask

Page 8: Linux Xenomai UAV platform. · How can tasks migrate between the Linux and Xenomai domains? • Derives real‐time threads from regular Linux tasks through standard POSIX API. •

Technology for a better society 8

Software for sensor data delivery• GPS: 1Hz GPIO interrupts relates delivered data (UART) to time‐line.

Sensordvr

dvr

irq SensorTask

ConsumerTask

DynamicsModel(Kalman‐Filter)

Sensordvr

dvr

irq SensorTask

Sensordvr

dvr

irq SensorTask

Buf1

Buf2

Buf3Buffer Adm

inistratorBuf1

Buf2

Buf3Buf1

Buf2

Buf3

dvr

dvr

dvr

Actuators

IDI 2015‐05‐19

• IMU: ≤450Hz GPIO interrupts relates delivered data (SPI) to time‐line.

• Gyro‐meter: ≤ 8Hz GPIO interrupt relates data (I2C) to time‐line.• Magnetometer: ≤ 8Hz • Barometer/Altimeter: ≤ 200Hz GPIO interrupts relates data (I2C) to time‐line.• Swarm Radio:  TBD…10Hz ?

dvr Swarm Radio

Page 9: Linux Xenomai UAV platform. · How can tasks migrate between the Linux and Xenomai domains? • Derives real‐time threads from regular Linux tasks through standard POSIX API. •

Technology for a better society 9

Sensor interfacing at test

• RTDM drivers for sensor GPIO interrupts for precise registration of irq timing.• Standard Linux UART driver• Standard Linux I2C driver• Modified Linux SPI driver (sub‐optimal and requires kernel queues for array transfer)

IDI 2015‐05‐19

Sensor Frq. Interface Speed Payload

GPS 1 Hz UART 115 Kb/s 678 bytes

Gyro Ca. 4 Hz I2C 400 Kb/s 14 bytes

Magnetometer Ca. 4 Hz I2C 400 Kb/s 6 bytes

Barometer Ca. 1 Hz I2C 400 Kb/s 5 bytes

IMU 200 Hz SPI 746 Kb/s 78 bytes

No RTDM drivers found for BeagleBone Black interfaces.Have to use standard Linux drivers (for now). 

Page 10: Linux Xenomai UAV platform. · How can tasks migrate between the Linux and Xenomai domains? • Derives real‐time threads from regular Linux tasks through standard POSIX API. •

Technology for a better society 10

RTDM driver for GPIO interrupts

IDI 2015‐05‐19

info = device.rtdm_dev.device_data;info->gpio_irq_time = rtdm_clock_read_monotonic();sem = rtdm_irq_get_arg(gpio_irq, rtdm_sem_t);if(sem->value == 0)rtdm_sem_up(sem);return RT_INTR_HANDLED;

Receive irq.Read jiffies.Set semaphore.

Block on Semaphore.Time to user_space

Read irq time

ReadRelated datafrom sensor

Linux standarddriver

info = context->device->device_data;err = rtdm_sem_down(&(info->gpio_irq_sem));utime.value = info->gpio_irq_time;err = rtdm_safe_copy_to_user(user_info, buf, utime.bytes, sizeof(utime.bytes));return sizeof(nanosecs_abs_t);

Initialize sensor

ProcessSensor data

Sensor Task

Page 11: Linux Xenomai UAV platform. · How can tasks migrate between the Linux and Xenomai domains? • Derives real‐time threads from regular Linux tasks through standard POSIX API. •

Technology for a better society 11

IDI 2015‐05‐19

Low priority

Linuxscheduler

Softreal‐time

Xenomai user tasks

main

Linuxkernel

Xenomaikernel

Hardreal‐timeXenomai task

rt_task_creatert_task_start

Xenomaisyscall

Kernel spaceUser space

Xenomai task

OnLinuxsyscall

Linuxsyscall

Real‐timescheduler

High priorityMemory space:

Automaticreturn

Linux thread

pthread_create

Page 12: Linux Xenomai UAV platform. · How can tasks migrate between the Linux and Xenomai domains? • Derives real‐time threads from regular Linux tasks through standard POSIX API. •

Technology for a better society 12

Xenomai real‐time shadowIDI 2015‐05‐19

Internal backlinks

Linuxscheduler

Xenomaischeduler

Structxntread

Structtask_struct

• Higher level of integration with Linux env.compared to e.g. RTAI or RTLinux.

How can tasks migrate between the Linux and Xenomai domains?

• Derives real‐time threads from regular Linux tasks through standard POSIX API.

• Inherits Linux tasks’ ability to invoke regular Linux services.

• Each scheduler uses its own data.• Has access to the other scheduler's data 

structure.• Migrates to Linux keeping its priority and 

scheduler policy (SCHED_FIFO).

Page 13: Linux Xenomai UAV platform. · How can tasks migrate between the Linux and Xenomai domains? • Derives real‐time threads from regular Linux tasks through standard POSIX API. •

Technology for a better society 13

/proc/xenomai/stat  and sched informationIDI 2015‐05‐19

CPU PID MSW CSW PF STAT %CPU NAME0 0 0 133030 0 00500080 99.5 ROOT/00 2685 322 645 0 00300182 0.0 baro_task0 2686 1237 2478 0 00300182 0.0 gyro_task0 2687 310 622 0 00300182 0.0 gps_task0 2688 62735 125447 0 00300182 0.3 imu_task0 2689 0 3937 0 00300184 0.0 consume_task0 0 0 83941 0 00000000 0.0 IRQ67: [timer]0 0 0 308 0 00000000 0.0 IRQ135: gps_rtdm0 0 0 62735 0 00000000 0.1 IRQ155: imu_rtdm0 0 0 1236 0 00000000 0.0 IRQ176: gyro_rtdm0 0 0 320 0 00000000 0.0 IRQ188: baro_rtdm

CPU PID CLASS PRI TIMEOUT TIMEBASE STAT NAME0 0 idle -1 - master R ROOT/00 3069 rt 60 - master W baro_task0 3070 rt 50 - master W gyro_task0 3071 rt 50 - master W gps_task0 3072 rt 70 - master W imu_task0 3073 rt 40 20ms368us master D consume_task

MSW = Mode switches: primary‐>secondary/secondary‐>primary CSW = Context switches (operated by Xenomai for real‐time threads, kernel + user‐space).PF = Page Faults

Page 14: Linux Xenomai UAV platform. · How can tasks migrate between the Linux and Xenomai domains? • Derives real‐time threads from regular Linux tasks through standard POSIX API. •

Technology for a better society 14

Timing measurementsAt time: 521 secondsBaro [0]irqs: 527, period 982.907867 ms, min_time 982.830374 ms, max_time 982.992833 ms, Jitter: +0.084966/-0.077493 msGyro [1] irqs: 2047, period 253.673522 ms, min_time 253.568666 ms, max_time 253.776666 ms, Jitter: +0.103144/-0.104856 msGPS [2] irqs: 512, period 1000.050423 ms, min_time 1000.048083 ms, max_time 1000.053417 ms, Jitter: +0.002994/-0.002340 msIMU [3] irqs: 104007, period 5.000128 ms, min_time 4.982875 ms, max_time 5.021792 ms, Jitter: +0.019459/-0.019458 msConsumer cnts: 6497, period 80.000000 ms, min_time 79.925208 ms, max_time 80.084292 ms, Jitter: +0.084292/-0.074792 msAbout irq's:(Missed irq time is from start of measurement)Baro [0] irqs: 527, missed irqs: 0, at:Gyro [1] irqs: 2047, missed irqs: 0, at:GPS [2] irqs: 512, missed irqs: 0, at:IMU [3] irqs: 104007, missed irqs: 1, at: 0.467031542 s,About kernel-to-user space latencies:Baro: mean 0.026833 ms, min_time 0.011833 ms, max_time 0.041833 ms, Jitter: +0.015000/-0.015000 msGyro: mean 0.054666 ms, min_time 0.008333 ms, max_time 0.101000 ms, Jitter: +0.046334/-0.046333 msGPS.: mean 0.027999 ms, min_time 0.010208 ms, max_time 0.045791 ms, Jitter: +0.017792/-0.017791 msIMU.: mean 2.484250 ms, min_time 0.006958 ms, max_time 4.961542 ms, Jitter: +2.477292/-2.477292 msAbout I/O latencies:Baro: mean 3.180541 ms, min_time 1.268958 ms, max_time 5.092125 ms, Jitter: +1.911584/-1.911583 msGyro: mean 8.619375 ms, min_time 5.958042 ms, max_time 11.280708 ms, Jitter: +2.661333/-2.661333 msGPS.: mean 97.763229 ms, min_time 94.614708 ms, max_time 100.911750 ms, Jitter: +3.148521/-3.148521 msIMU.: mean 5.999083 ms, min_time 0.621959 ms, max_time 11.376208 ms, Jitter: +5.377125/-5.377124 ms

IDI 2015‐05‐19

The standard Linux SPI driver does not meet the requirements of the IMU sensor.

Page 15: Linux Xenomai UAV platform. · How can tasks migrate between the Linux and Xenomai domains? • Derives real‐time threads from regular Linux tasks through standard POSIX API. •

Technology for a better society 15

IDI 2015‐05‐19

Thank you!

Does the sensor platform provide hard real‐time?Linux Xenomai will most probably provide sufficient hard real‐time for an UAV sensor platform.With proper RTDM drivers it would perform even better.