Netduino home hardware projects downloads community

Jump to content


The Netduino forums have been replaced by new forums at community.wildernesslabs.co. This site has been preserved for archival purposes only and the ability to make new accounts or posts has been turned off.
Photo

Quad.Net Quadrocopter for .NETMF


  • Please log in to reply
119 replies to this topic

#1 Brandon G

Brandon G

    Advanced Member

  • Members
  • PipPipPip
  • 92 posts
  • LocationVancouver BC, Canada

Posted 16 January 2011 - 11:49 PM

As posted on another forum page http://forums.netdui...o-quadrocopter/ I've started a new quadrocopter project. Its just a start and I'm sure will not be easy but I look forward to working with this community to get it moving. As well I am trying to make this hardware and implementation of framework agnostic. So potentially it could run on Netduino or other .netmf boards, but of course we'll be working towards the netduino application first and foremost, it will also be run with a plug and play config so we can add in support for different types of hardware / gyros / escs / acceleometer, magnetometer, altimeter etc. PM if interested and look at the source which as it stands right now is just structure of the project that i have set up in my head.

#2 Luke Cummings

Luke Cummings

    Advanced Member

  • Members
  • PipPipPip
  • 38 posts
  • LocationCalgary, AB

Posted 19 January 2011 - 06:46 PM

I just recently started porting my quad based on Aeroquad to GHI's FEZpanda board. I currently solve my realtime problem by offloading to a arduino ported teensy. I got so excited when I started reading about the possiblility of running native code to handle everything on the one board that I bought a netduino from Sparkfun. Unfortunately its gonna be 3 weeks till it gets here (on backorder). I would be very interested in collaborating on a project such a yours.
Cheap, Fast, Good... Pick two

#3 JonnyBoats

JonnyBoats

    Advanced Member

  • Members
  • PipPipPip
  • 155 posts
  • LocationPhillips, ME

Posted 19 January 2011 - 10:46 PM

Now if it can do this: ;-)

#4 Chris Seto

Chris Seto

    Advanced Member

  • Members
  • PipPipPip
  • 405 posts

Posted 19 January 2011 - 10:58 PM

All the GRASP lab videos involve some complex processing done on computers that are receiving info pertaining to the quad's location in space using infrared cameras. The computer(s?) really only manipulate what they think is an object in space which is then translated down to code that actually controls the quad. I would be willing to be the majority of the flight critical autostab is handled onboard the aircraft, but it's not like the onboard computer is calculating all those fancy maneuvers. :) Still, it is very impressive what some code and quadcopters can do. :)

#5 Brandon G

Brandon G

    Advanced Member

  • Members
  • PipPipPip
  • 92 posts
  • LocationVancouver BC, Canada

Posted 19 January 2011 - 11:40 PM

that video when posted on engadget is what got me really interested. there's some guys at MIT doing some cool stuff too. The one i found a lil crazy was the one that had the kinect hardware attached for object detection, which i think can be done alot simpler with less weight but still a neat concept

#6 Brandon G

Brandon G

    Advanced Member

  • Members
  • PipPipPip
  • 92 posts
  • LocationVancouver BC, Canada

Posted 19 January 2011 - 11:42 PM

http://www.engadget....nType=wl-gadget

#7 Brandon G

Brandon G

    Advanced Member

  • Members
  • PipPipPip
  • 92 posts
  • LocationVancouver BC, Canada

Posted 22 January 2011 - 09:14 PM

Magoocas, Fellow Canuck. The aeroquad software is pretty good. I've looked through a few of their classes and they've done agreat job with some of the avionics and physics concepts. A big part of what i am trying to accomplish in this project is a nice domain of those concepts, they seem to have mashed them together quite a bit, I come from DDD and want to apply that technique here. A port would be great and we can just try and organize it better. I have been inundated with my day job and my own $ making projects the last 2 weeks, but I'm about to order all my parts and start with the three gyro concept which will be just the stab part, not the full 9 degrees of freedom concepts. I will PM you for SVN repository

#8 Luke Cummings

Luke Cummings

    Advanced Member

  • Members
  • PipPipPip
  • 38 posts
  • LocationCalgary, AB

Posted 23 January 2011 - 03:58 AM

Brandon, hows the weather over in Van? lol always great to work with the best... I'm working with mecurial right now so I had to get subversion, installing as I type. I was reading the thread you started before on the same topic and I wanted to put the question to bed. Can you fly a quad with NETMF? Hell yes! check this out: As I alluded to previously its not totally .Net as the receiver stuff just isn't possible. But there you go. I agree basing off aeroquad is going to be the way to go, in fact that is what I have base FEZiquad off of. (Don't laugh I needed to call it something) The mecurial repository is available on google code: http://code.google.com/p/feziquad/ Well thats all for now, time to start checking out what you've got so far... Edit: Actually there is one other thing, what is DDD?: this http://www.gnu.org/software/ddd/?

Edited by magoocas, 23 January 2011 - 04:09 AM.

Cheap, Fast, Good... Pick two

#9 Brandon G

Brandon G

    Advanced Member

  • Members
  • PipPipPip
  • 92 posts
  • LocationVancouver BC, Canada

Posted 23 January 2011 - 05:18 PM

I am not a DDD expert but i try to use their methodologies

#10 Brandon G

Brandon G

    Advanced Member

  • Members
  • PipPipPip
  • 92 posts
  • LocationVancouver BC, Canada

Posted 23 January 2011 - 05:44 PM

just looked at the source there for feziquad, is that the one that you have flying in that video????? the code is very simple and I like how its organized, I like alot of things in there. If thats the one thats flying i am impressed

#11 Chris Walker

Chris Walker

    Secret Labs Staff

  • Moderators
  • 7767 posts
  • LocationNew York, NY

Posted 23 January 2011 - 06:25 PM

I did some deep native code research into this last night. The following info is intended for advanced audiences. Here's a glimpse into how .NET MF works at a low level. 1. .NET MF uses lots of hardware interrupts. System, USART, SPI, timers, etc. This is how bytes go from the serial port into buffers, etc. These usually last just a few microseconds, but there's a lot more going on under the hood than just GC if you get down to the nanosecond level. 2. ARM interrupts have priority levels. .NET MF has a generic IRQ handler (IRQ_Handler) which dispatches native interrupt handling code based on trigger source and priority. 3. In theory, it's possible to create a highest-priority IRQ based on the edge of a timer clock which executes every # ns/us. It's also possible to create a "fast forced" IRQ based on one of the timer clocks which uses its own code path and would basically run as a super-high-priority "fast IRQ (FIQ)" independent of the core .NET MF. I built a sample IRQ handler to be executed every ~2us last night. I designated it as "priority 7/7" and downranked all other priorities to <=6 (scale of 0-7). I used the existing .NET MF IRQ_Handler. Sometimes my 2us handler was called in time and sometimes there was a delay of up to 50us. If a quadcopter native code routine needs to run say 10,000 a second, and the code is efficient enough to fit inside a native code handler...then it's looking very possible to run "behind the scenes". It might also be possible to tweak the .NET MF interrupt handling code to make this call more precise. It should be possible to build a FIQ-priority handler based on a timer. One could create a parallel interrupt handling/execution path inside the .NET MF firmware which would run the native code handler on a more exact schedule. Okay, maybe a little more technical than some of you were looking for...but hopefully this helps. If we have a few advanced ARM/THUMB hackers (Corey? ;)) maybe we could make this a community project. Chris

#12 Luke Cummings

Luke Cummings

    Advanced Member

  • Members
  • PipPipPip
  • 38 posts
  • LocationCalgary, AB

Posted 23 January 2011 - 07:45 PM

Brandon, that is indeed the code running in that video
Cheap, Fast, Good... Pick two

#13 Brandon G

Brandon G

    Advanced Member

  • Members
  • PipPipPip
  • 92 posts
  • LocationVancouver BC, Canada

Posted 23 January 2011 - 08:14 PM

Chris, that is exactly what we are looking for, if it were possible to get a faster line to the handlers send in delegates of our own to those handlers and was wrapped in a nice library i think we'd be laughing with a fast enough hz to do anything that can be done in arduino, therein lies the bottleneck, like i said there are ways around GC. I did some more research on F# the other day and saw how people have fooled the compiler to use VB and have found a way to do it in F# but for purposes of simplicity within this project i've decided to use C# and when i get to optimizing (if need be) might switch out some of the loops for F3 for speed.
Magoocas,
I am impressed, i think we found our starting point and might want to involve Luke in what we are trying to do. if you've looked at source control you can see the implementational way in which im approaching.
We have
the Quad.Net solution with:
Framework (contains interfaces like IPWM)
Framwork.Implementations.SecretLabs (implementations like SecretLabs.NETMF.Hardware.PWM)
This allows for us to swap out framework specific implementations, ie using fez's custom framework
Hardware (contains generic interfaces for things like motors, gyros and escs)
Hardware.Implementations (implemntations of hardware like HobbyKings ss2530 ESC)
Hardware.Implementations.Secretlabs (implementations for things specific to netduino board, things like Pins)
Quad.Net.FlightController (main entry point but in the form of interfaces, requires an implemntation, like fez or netduino)
Quad.Net.FlightController.Netduino (specific implementation of netduino board and its settings)

Example of Netduino Implemntation with a speedcontroller
using System.Threading;
using Quad.Net.ElectricSpeedController;
using Quad.Net.Framework.Implementations.SecretLabs.PulseWidthModulation;
using Quad.Net.Framework.PulseWidthModulation;
using Quad.Net.Hardware.ElectricSpeedController;
using Quad.Net.Hardware.Implementations.ElectricSpeedController.Implementations;
using Quad.Net.Hardware.Implementations.SecretLabs.Pin;
using Quad.Net.Hardware.Pin;
using SecretLabs.NETMF.Hardware.Netduino;

namespace Quad.Net.FlightController.Implementations.Netduino
{
    public class Program
    {
        public static void Main()
        {
            ICpuPin pin = new CpuPin(Pins.GPIO_PIN_D9);
            ISpeedControllerSettings electricSpeedControllerSettings = new HobbyKingSs2530Settings(pin);
            IPWM pwm = new SecretLabsPWM(pin);
            Controller controller = new Controller(electricSpeedControllerSettings,pwm);

            for (int i = 0; i <= 100; i++)
            {
                controller.ElectricSpeedController.SetThrottle(i);
                Thread.Sleep(50);
            }
        }

    }
}
What i have tried to accomplish with this is a framework where any contributor can swap out hardware, gyros or microcontroller that supports netmf and specific implementations of framework, fez vs secretlabs

What i'm hoping will happen is a user can throw a new esc in, implement an ESC interface specific to that esc, and fly 5 minutes later, or a board or a gyro or eventually other sensors, if we keep this generic enough we could add features and hardware very quickly and segregate the project in a more agile framework than what is being done in other projects as well as allow for various combinations of hardware software with little or no effort. Everyone else code that i have veiwed ha been scary dependent on hardware or assumptions and thus why the project falls down

#14 Chris Walker

Chris Walker

    Secret Labs Staff

  • Moderators
  • 7767 posts
  • LocationNew York, NY

Posted 23 January 2011 - 11:13 PM

Hi Brandon, I built a native code handler test for .NET MF. This event is triggered on a line input (but should be triggerable by a timer). I built the event so that it would keep retriggering itself...to see how fast the FIQ operates. In this test, the FIQ fires infinitely, about once per microsecond. Of course, doing so takes up 100% of MCU time and stops the .NET MF from running...so I'd recommend calling the FIQ interrupt handler (native code) every ## us/ms. P.S. I had the FIQ raise and lower a pin every time it got called. That's the "wave". The interval between pulses is the latency to call the FIQ; the pulse is the FIQ executing about 5 instructions. Chris

Attached Files

  • Attached File  fiq.png   63.06KB   183 downloads


#15 Brandon G

Brandon G

    Advanced Member

  • Members
  • PipPipPip
  • 92 posts
  • LocationVancouver BC, Canada

Posted 24 January 2011 - 12:41 AM

well after checking out the feziQuad i took all their code and implemented it in my framework, main control loop, PID, obviously not testing with hardware and have no test coverage yet but its fairly slick if i do say so myself, it has his implementation of PID minus the windup, want to understand its implications first, i have not implemented his gyro, esc, or radio yet either. If we got in touch with Cummings, we could test this

If i get hardware and some skills with soddering i could be up and running right now, I cleaned up alot of his code as well

Magoocas, its in source control

Here's an entry point to give u an idea

using Quad.Net.Commons.Configuration;
using Quad.Net.ElectricSpeedController;
using Quad.Net.Framework.Implementations.SecretLabs.PulseWidthModulation;
using Quad.Net.Framework.PulseWidthModulation;
using Quad.Net.Hardware.ElectricSpeedController;
using Quad.Net.Hardware.Gyro;
using Quad.Net.Hardware.Implementations.ElectricSpeedController.Implementations;
using Quad.Net.Hardware.Implementations.Gyro;
using Quad.Net.Hardware.Implementations.Radio;
using Quad.Net.Hardware.Implementations.SecretLabs.Pin;
using Quad.Net.Hardware.Pin;
using Quad.Net.Hardware.Radio;
using SecretLabs.NETMF.Hardware.Netduino;

namespace Quad.Net.FlightController.Implementations.Netduino
{
    public class Program
    {
        public static void Main()
        {
            IConfiguration settings = GetStaticSettings();

            //Assumes one type of speed controller on quad
            ISpeedControllerSettings speedControllerSettings = new HobbyKingSs2530Settings();
            
            ICpuPin pinFrontESC = new CpuPin(Pins.GPIO_PIN_D9);
            IPWM pwmFront = new SecretLabsPWM(pinFrontESC);
            SpeedController electricSpeedControllerFront = new SpeedController(speedControllerSettings, pwmFront);

            ICpuPin pinRearESC = new CpuPin(Pins.GPIO_PIN_D8);
            IPWM pwmRear = new SecretLabsPWM(pinRearESC);
            SpeedController electricSpeedControllerRear = new SpeedController(speedControllerSettings, pwmRear);

            ICpuPin pinRightESC = new CpuPin(Pins.GPIO_PIN_D7);
            IPWM pwmRight = new SecretLabsPWM(pinRightESC);
            SpeedController electricSpeedControllerRight = new SpeedController(speedControllerSettings, pwmRight);

            ICpuPin pinLeftESC = new CpuPin(Pins.GPIO_PIN_D6);
            IPWM pwmLeft = new SecretLabsPWM(pinLeftESC);
            SpeedController electricSpeedControllerLeft = new SpeedController(speedControllerSettings, pwmLeft);


            Motors motors= new Motors(electricSpeedControllerFront,electricSpeedControllerRear,electricSpeedControllerRight,electricSpeedControllerLeft);
           

            AxesController axesController = new AxesController(settings);
            IGyro gyro = new DefaultGyro();
            IRadio radio = new DefaultRadio();
            ControllerLoopSettings loopSettings = new ControllerLoopSettings(settings);
            Controller controller = new Controller(motors, axesController, gyro, radio, loopSettings);
                      

        }

        private static IConfiguration GetStaticSettings()
        {
            InMemoryConfiguration config = new InMemoryConfiguration();
            config["PitchDerivativeGain"] = "-.5";
            config["PitchItegralGain"] = "0";
            config["PitchProportionalGain"] = "1.2";

            config["RollDerivativeGain"] = "-.5";
            config["RollItegralGain"] = "0";
            config["RollProportionalGain"] = "1.2";

            config["YawDerivativeGain"] = "0";
            config["YawItegralGain"] = "0";
            config["YawProportionalGain"] = "3";

            config["RadioLoopFrequency"] = "25";
            config["SensorLoopFrequency"] = "300";
            config["MotorLoopFrequency"] = "300";
            config["LoopUnit"] = "2";

            return config;

        }
    }
}



#16 Brandon G

Brandon G

    Advanced Member

  • Members
  • PipPipPip
  • 92 posts
  • LocationVancouver BC, Canada

Posted 24 January 2011 - 01:01 AM

Magoocas, I didnt realize that video was you!!!! With a little bit of work you could fly with the code i've updated and a little bit of messing around with the source. I would love to see it run!

#17 Chris Walker

Chris Walker

    Secret Labs Staff

  • Moderators
  • 7767 posts
  • LocationNew York, NY

Posted 24 January 2011 - 01:08 AM

Hey Brandon, Chris Seto: About how many instructions would you need to run, and at what interval, for a stable quadcopter controller routine? Chris

#18 Luke Cummings

Luke Cummings

    Advanced Member

  • Members
  • PipPipPip
  • 38 posts
  • LocationCalgary, AB

Posted 24 January 2011 - 02:05 AM

Brandon I was just out fishing on my way home, were you able to figure out the issues with your repository I wasn't able to access it last night. It asks me for user name password. I will get to work implementing your methodology, commit when I'm done and maybe put up a video if she flies. Edit: Nevermind i got your PM, smartphones are useful but mostly tedious...
Cheap, Fast, Good... Pick two

#19 Brandon G

Brandon G

    Advanced Member

  • Members
  • PipPipPip
  • 92 posts
  • LocationVancouver BC, Canada

Posted 24 January 2011 - 02:14 AM

Yes i pm'ed you the credentials, let me give you your own Harness for your implementation will call it Quad.Net.FeziQuad.Implementation, dont think it'll fly right off bat there's a few things that might still need to be done, you've used some fairly specific esc implemntations and mine use some assumptions that i dont know yet, but not much will PM once i've committed with changes. Chris at this point i'm not sure the hz range i've seen has varied between 250 and 1000 level i've seen is, once i get some hardware in i can be more specific, I'll defer to Chris and Luke on this one

#20 Brandon G

Brandon G

    Advanced Member

  • Members
  • PipPipPip
  • 92 posts
  • LocationVancouver BC, Canada

Posted 24 January 2011 - 03:04 AM

I have updated and made a very quick implementation of the hardware you have, there may be a few bugs in there but not bad for 10 mins work, your startup project is Quad.Net.FlightController.Implementations.FeziQuad




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users

home    hardware    projects    downloads    community    where to buy    contact Copyright © 2016 Wilderness Labs Inc.  |  Legal   |   CC BY-SA
This webpage is licensed under a Creative Commons Attribution-ShareAlike License.