I should blog about our new Hardware Abstraction Layer for a long time now and having written an article about the new HW-0.21 just before, I decided not to stop and to describe our new feature just now.
As you all know, Multikopter get built in all different forms and sizes. Trough one problem remains: As soon as you change the motor / propeller geometry, you have to change the closed-loop control to incooperate the new dimensions and positions of your motors and propellers.
This is about to change!
The new NGOS essentially partitions closed-loop control and physical motor / propeller geometry. That means that the output of the controller code in the NGOS no longer contains direct motor actor values but only corrections on pitch, roll and yaw axes. A new API layer called HAL (hardware abstraction layer) encapsulates the physical motor / propeller configuration. The API layer is kept very simple and essentially implements how a correction on a corresponding axis has to be executed by the motors.
The current NGOS implements HAL as abstract modules separate for the controller code. So essentially all controllers can be flown with all HALs.
We currently have implemented the following HALs:
- Quadcopter HAL
Essentially the good old quadcopter you all know and love
- QuadcopterX HAL
The good old quadcopter turned by 45 degrees to fly in X-Mode
- QuadcopterR HAL
The normal quadcopter HAL, just in reverse
- Y6 HAL
The Y6 HAL to fly Tri-Coaxial multicopters
Arbitrary new HALs can be implemented by adding a simple HAL module containg two simple functions to the source code.
On the NGOS side of things this looks like this:
# show hal Current HAL: quadcopter HAL Id: 1 HAL Description: The classical 4 rotor QuadCopter HAL HAL Quality: proven Needed number of actors: 4 Detected number of actors: 4 Motor 1: front Motor 2: back Motor 3: right Motor 4: left Description: This is the classical 4 rotor (non-cross) QuadCopter HAL. It allows to fly a classical QuadCopter with a front, back, left and right motor. Current HAL configuration: HW.HAL quadcopter HW abstraction layer
Switching to a Y6-HAL is as simple as entering the command "set HW.HAL Y6", which I did for this demonstration. This results in the following output on inspection:
# show hal Current HAL: Y6 HAL Id: 4 HAL Description: The Y6 Hexakopter HAL HAL Quality: flying Needed number of actors: 6 Detected number of actors: 4 Motor 1: front-left_up Motor 2: front-right-up Motor 3: back-up Motor 4: front-left-down Motor 5: front-right-down Motor 6: back-down Description: This is the new Y6 HAL in normal mode. It allows to fly a Y6 hexacopter. You need to attach front-left up/down, front-right up/down and back up/down motors. Current HAL configuration: HW.HAL Y6 HW abstraction layer HAL.fact.top 1.00000000 Throttle factor for top layer HAL.fact.bottom 1.10000000 Throttle factor for bottom layer
As you can see, every HAL describes how their actors how to be mounted, what the actor addesses are, how many of them there have to be and how many of them have been detected. The NGOS won't let you start the actors if there have not been detected enough actors for the current HAL. Every HAL can have HAL-dependant parameters. As you can see above the Y6-HAL defines two parameters which allow the user to define the throttle factors for the lower and upper prop-layer.
I think I forgot to mention till now that we can switch between different HALs in-flight? Yes, it's true! Since the HALs are totaly independant from the closed-loop controllers, we are able to change them using behavior rules whenever we like.
You don't belive me? Then check out the following small movies...
In this first movie, I switch between the normal Quadcopter-HAL and the QuacopterX-HAL (x-mode) while flying:
Play on: YouTube
In the next movie I switch between the normal Quadcopter-HAL and the QuadcopterR-HAL (reverse-mode) while flying:
Play on: YouTube
In this last movie Markus, a friend of mine, demonstrates his new Y6-NG flying using the Y6-HAL he implemented (and I have to mention: He's no programmer himself!):
Play on: YouTube
As you can see the new HAL concept performs very well and seems capable of implementing very different HALs. I imagine we could have a Helicopter-HAL or even a Robot-HAL! Current HALs are able to use up to 16 actors.
I will tell you more about other features in my next blog entry...