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.

Brandon G's Content

There have been 92 items by Brandon G (Search limited from 29-June 23)


By content type

See this member's


Sort by                Order  

#7635 NetDuino Quadrocopter

Posted by Brandon G on 14 January 2011 - 04:34 AM in Netduino 2 (and Netduino 1)

and i always love the moon reference, its bloody amazing they did it at all. its funny but a quad is harder and requires more calcs



#7654 NetDuino Quadrocopter

Posted by Brandon G on 14 January 2011 - 04:38 PM in Netduino 2 (and Netduino 1)

dones, thanks for the PID link. great point starting with just one plane might be easier as a proof of concept, I was thinking of doing some simple tests with the gryos before i considered flying at all. a simple 2 prop setup might be a good way to start. Jan I will look at them more deeply, my understanding was they using one gyro for each roll pitch yaw and that they were being sent back to the controller for pid changes, they had basically taken those things apart and done a straight sodder to their custom board, they were chosen because they were cheap and they had the best success with them. I have read sparkfuns gyro acceleromter guide and man is it thorough, my hope was to go with what was proven out there and follow their same steps. Sparkfun has some great ones with 3 axis in one that would be ideal for this application but are more expensive and a more of an unknown but if your above post is correct then may be the way i need to go



#7535 NetDuino Quadrocopter

Posted by Brandon G on 12 January 2011 - 10:18 PM in Netduino 2 (and Netduino 1)

Maybe i am being a bit naive here then. I was really hoping for an easy board to work with and this might not be the case then. I was hoping to do all this within the managed framework, PID, PWM PPM, RX fired from the events of the components attached to the board, similar to the ISR event of other boards (Once again i am a noob when it comes to the way in which these components interact back with the program) if the events fire fast enough we can make up for any small delays with a different PID calc. So as data comes in from gyros, reciever, escs they will fire events and we can interact with those instantiated objects that provide the stability}, I was planning on instantiating all objects at startup and using a CQRS style of messaging objects from the events with a time sensitive queue LIFO, this way when GC does come through its fast as all hell and is disposing small objects and not interrupting the main objects. the reason for the messaging objects is we can then take that data and lazy write it to an sd card for running simulations and debugging a flight afterwards, makes for a great picture of events and replayablity. 500hz seems a lil high to me and maybe overkill, Ive heard of people flying quite sucessfully with a loop operating in the range of 40 to 50hz and then going up to 500 and even 1000 and seeing no obvious gains, but until i start testing I wont know. I would hope we could achieve 40hz without changing or extending the firmware, btw i like the fluent model by corey seems interesting and would like to see his progress. To be honest i probably wont be using the RX at all within this project, plan on using wifi and tethered testing to start. So just make it fly stable account for wind and hover is part 1.



#7784 NetDuino Quadrocopter

Posted by Brandon G on 16 January 2011 - 11:51 PM in Netduino 2 (and Netduino 1)

http://forums.netdui...pter-for-netmf/



#7634 NetDuino Quadrocopter

Posted by Brandon G on 14 January 2011 - 04:30 AM in Netduino 2 (and Netduino 1)

n regards to the deterministic comments, gc is a mofo and can kill you at the worst times. what i think will compensate is the PID algos and making them smartand aware of the state of system. If there were on thing i wish would be built into .NET would be more ability to talk to GC and get stats and state of it. I have messed with GC a few times with very little success. It would be great to know where it is at in operation, so i could query it and understand that i should in this case, try and level out my quad or purge my queue because i know it to be too late etc



#7633 NetDuino Quadrocopter

Posted by Brandon G on 14 January 2011 - 04:23 AM in Netduino 2 (and Netduino 1)

corey, i will prolly try and start a little heavier than that and optimize as i go and if the quad requires it, not being silly mind you but will try to make it elegant to start and get tighter in high traffic areas.



#7581 NetDuino Quadrocopter

Posted by Brandon G on 13 January 2011 - 05:21 PM in Netduino 2 (and Netduino 1)

I didnt mean to start any kind of war here either but i must object to the radical inefficiencies that you are both speaking of, there's a difference between 20 million operations and processing 20 million operational messages a second on one thread updating a domain with 100 millions objects in memory. Granted GC is an issue, i am not claiming i am going to have 400 passengers on my quad but conversely i will guarantee any code i write will not fly to 90' until it runs out of batteries. Perhaps this is the disconnect between hardware programmers that are hardware first software second. I am going to admit i am a noob when it comes to the hardware side but i cant imagine it this inefficient. no program i have ever made is content with a 20 second lag because of gc, thats drag and drop college kids. These are teeny objects and GC should have no impact if you are cognizant day one (which i always am). I have worked in .NET since the beta, I have run billions of dollars through .NET at millisecond efficiency(i agree on the sleep statement btw, .NET timer classes are awful), i have beat other programs to the punch($) by being more efficient and agile, these include ones written in c and c++, by programmers that are not as aware of speed given their bias of their language. Back to quad, for me this is a fun project to do something neat and cool to get my mind off the constant shite of work, hopefully i can find a community that wants to embark on it as i do with my limited hardware skill or i will try and do so on my own, the former favourable, i would hope this community would want to do more with its framework than what i have seen in the showcases, .NET is a great language and has huge potential in this space if WE can make it better, managed code has a bad rap because of bad programmers the easy barrier to entry, those at the forefront can make it a feasible and quick alternative for practical applications if we work around/with the inherent disadvantages / advantages. In closing i will say that for me this netduino project is an opportunity to step out of just programming and see material physical results of my effort, which is a huge, I have always wanted to bridge the gap between the real world and the virtual and thats what i love most about this project. anyway brandon



#7597 NetDuino Quadrocopter

Posted by Brandon G on 13 January 2011 - 08:43 PM in Netduino 2 (and Netduino 1)

Thanks for your reply Chris, That's the exact architecture i was thinking. A state machine that instantiated all the main objects at startup and then using a messaging pipeline with handlers for interacting with the state machine cqrs style, will make for easily debuggable code as well as rapid development and future feature building, ie gps, accelerometer, sonar, magnetometer, video, wifi, cellular communication, autonomous functions, load carrying etc. The initial setup is as follows motor: emax fc2822 1200kv esc: hobbyking ss 25/30 props: epp 8×4.5 cw/ccw sbec: hk turnigy 5A frame: quadframe.com battery: turnigy 3s3000 20C controller: kkmulticontroller 5.5 once up and running i will start with the netduino board and add: 3 HobbyCity HK401B gyros and try to get those to work with the netduino Will be ordering components soon and will keep you all appraised of my progress.



#7600 NetDuino Quadrocopter

Posted by Brandon G on 13 January 2011 - 08:52 PM in Netduino 2 (and Netduino 1)

also i should mention that i did get this build list from warthox, http://warthox.bplaced.net/?page_id=76 , whom has some of the craziest quad and tri copter videos i have seen yet on the web, which is what started me wanting to do this so badly



#9547 Runtime Native Code Interop

Posted by Brandon G on 14 February 2011 - 09:04 PM in General Discussion

Chris,
Thank you for this. I think this will help a great deal in the cases where near realtime is necessary. I know this requires alot of work to integrate and glad your team are doing it. I would really hope that the NETMF team will take you and GHI's lead as far as providing interops and push it into NETMF. I love managed code and will always write in it when i can, even when knowing i am sacrificing speed for elegance, but given my recent project DotCopter.NET there is no way it can all be done in managed. So in an appeal to the NETMF team, to avoid further fragmentation, they need to pull this into the framework for the cases where its a last resort.

Again, thank you for your efforts Chris.
Brandon



#8951 Anybody interested in a cheap IMU?

Posted by Brandon G on 03 February 2011 - 09:18 PM in General Discussion

I'd take one as well, that was the board i was going to buy but didnt want the old magnetometer, polling via i2c works for my application



#8955 Anybody interested in a cheap IMU?

Posted by Brandon G on 03 February 2011 - 10:48 PM in General Discussion

Chris will be able to answer better, but yes from what i understand there would be no compensation and no mcu. from the razor one here's an implementation by zerov https://code.google..../QuadroLib/Ahrs which might give you an idea of the data coming down



#8966 Anybody interested in a cheap IMU?

Posted by Brandon G on 04 February 2011 - 01:51 AM in General Discussion

I think it really depends on the applications requirements. In my case I am controlling a loop and want to read every 200ms which I think can be acomplished and the overhead is ok. I am no expert though I'm learning as I go. What are you using the imu for?



#8924 Microsoft.SPOT.Reflection.Serialize() / Deserialize() throws System.NotImplem...

Posted by Brandon G on 03 February 2011 - 04:10 AM in General Discussion

like i said, aint great but one thing i have noticed about netmf is a major need for optimization and special cases, elegance is sacrificed for speed



#8886 Microsoft.SPOT.Reflection.Serialize() / Deserialize() throws System.NotImplem...

Posted by Brandon G on 02 February 2011 - 04:15 PM in General Discussion

updated above, as i said this a very very specific and optimistic serialization system for my exact purposes, but the idea is sound and could be used in other places, u merely have to implement ISerializable on your class and insert a type into the serialize message in order to dynamically invoke the constructor, i know i am in this instance only serializing one type with this formatter so i have put that statically in, you could easily put in a header to accomplish this such as stx....type...data...etx once you know your type merely parse and dynamically invoke and assume T : new()



#8861 Microsoft.SPOT.Reflection.Serialize() / Deserialize() throws System.NotImplem...

Posted by Brandon G on 02 February 2011 - 05:20 AM in General Discussion

oh and i havent written tests for it yet, once i have and made this a little more generic i will psot as a zip



#9468 Microsoft.SPOT.Reflection.Serialize() / Deserialize() throws System.NotImplem...

Posted by Brandon G on 14 February 2011 - 12:07 AM in General Discussion

not a problem Fabien, same goes here. I am really not happy with what i've posted so far and starting to think aboutserialization in terms of config and xml and using weak references space lately



#7655 Microsoft.SPOT.Reflection.Serialize() / Deserialize() throws System.NotImplem...

Posted by Brandon G on 14 January 2011 - 04:41 PM in General Discussion

Not a problem, will be a couple weeks before i can start but look forward to it



#7610 Microsoft.SPOT.Reflection.Serialize() / Deserialize() throws System.NotImplem...

Posted by Brandon G on 13 January 2011 - 10:34 PM in General Discussion

Chris are the interfaces there to be implemented? IFormatter etc http://codebetter.co...-serialization/ old but still works



#7609 Microsoft.SPOT.Reflection.Serialize() / Deserialize() throws System.NotImplem...

Posted by Brandon G on 13 January 2011 - 10:28 PM in General Discussion

building a lightweight serializer wouldnt be too hard, I have some old source that could work, its optimistic and only handles simple objects. I will more than likely be re-visiting it soon in my quad project. What are you wanting to serialize (what types of objects)?



#7616 Microsoft.SPOT.Reflection.Serialize() / Deserialize() throws System.NotImplem...

Posted by Brandon G on 13 January 2011 - 11:02 PM in General Discussion

i think if we just did value types and collections of value types with recursion of more complex obecjts as long as they were all inheriting the same interface to start we could open it up from there, i'm new here and wondering if you guys have a svn or git repository going yet? if not I could host something up on mine if need be. Hopefully if i can help on the code side you guys can scratch my back a bit on the hardware side



#7630 Microsoft.SPOT.Reflection.Serialize() / Deserialize() throws System.NotImplem...

Posted by Brandon G on 14 January 2011 - 03:44 AM in General Discussion

greg and i worked together for 5 years that initial implementation was ours, albeit naive it suited our purposes. They are all teeny, almost any well written serialization implementations will be, i'd love to help out.



#8811 Microsoft.SPOT.Reflection.Serialize() / Deserialize() throws System.NotImplem...

Posted by Brandon G on 01 February 2011 - 04:34 PM in General Discussion

i ended up finding that shortly thereafter, thanks Corey. I've stubbed out the whole thing just going for some optimization now. My current application for it is the quadrocopter so has to be heavily optimized and optimistic, a more generic library can be made off it after, will post when done



#8783 Microsoft.SPOT.Reflection.Serialize() / Deserialize() throws System.NotImplem...

Posted by Brandon G on 01 February 2011 - 01:20 AM in General Discussion

So i started to get into it and I have come across some road blocks and cant seem to find a way around it. Reflection being limited i cant even call CreateInstance() or the other method i had up my sleeve FormatterServices.GetUninitializedObject() or Activator.CreateInstance, is there anyway to initialize an object from a string at all in netmf, otherwise i think we're shit out of luck short of some ugly case statements



#8860 Microsoft.SPOT.Reflection.Serialize() / Deserialize() throws System.NotImplem...

Posted by Brandon G on 02 February 2011 - 05:18 AM in General Discussion

Heres a very prelim write of this with some simple implementations as you can see i am putting the responsibility on the ISerializable object for now, not a full object graph, as i extend this i will update, right now its pretty ugly and specific


EDIT: didnt like what i posted earlier, here`s a revamp
using Quad.Net.Commons.Serialization;

namespace Quad.Net.Commons.Logging
{
    public interface ILogger
    {
        void Flush();
        void Write(ISerializable obj);
    }
}

using System.IO;
using Quad.Net.Commons.Serialization;

namespace Quad.Net.Commons.Logging
{
    public class PersistenceWriter : ILogger
    {
        private readonly IBinaryFormatter _formatter;
        private readonly string _fileName;
        private readonly FileStream _fileStream;

        public PersistenceWriter(string fileName, IBinaryFormatter formatter)
        {
            _formatter = formatter;
            _fileName = fileName;
            _fileStream = new FileStream(_fileName, FileMode.OpenOrCreate, FileAccess.Write, FileShare.None, 512);
        }

        public void Flush()
        {
            _fileStream.Flush();
        }

        
        public void Write(ISerializable obj)
        {
            _formatter.Serialize(_fileStream, obj);

        }
    }
}


using System.IO;
using Quad.Net.Commons.Serialization;

namespace Quad.Net.Commons.Logging
{
    public class PersistanceReader
    {
        private readonly IBinaryFormatter _binaryFormatter;

        public PersistanceReader(IBinaryFormatter binaryFormatter)
        {
            _binaryFormatter = binaryFormatter;
            
        }
        public ISerializable[] GetMessages(string readPath)
        {
            FileStream readFile = new FileStream(readPath, FileMode.Open, FileAccess.Read);
            return _binaryFormatter.Deserialize(readFile);
        }
    }
}

using System;
using System.IO;

namespace Quad.Net.Commons.Serialization
{
    public interface IBinaryFormatter
    {
        void Serialize(Stream stream, Object graph);//not implemented
        ISerializable[] Deserialize(Stream stream);
        void Serialize(Stream stream, ISerializable graph);//optimistic
    }
}


namespace Quad.Net.Commons.Serialization
{
    public interface ISerializable //:  where T : new() in classic C# this is what i would do force a parameterless contructor, cant do thisin netmf
    {
        byte[] Serialize();
        object Deserialize(byte[] buffer);
    }
}

using System;
using System.Collections;
using System.IO;

namespace Quad.Net.Commons.Serialization
{
    public class TelemetryFormatter:IBinaryFormatter
    {
        public void Serialize(Stream stream, object graph)
        {
            throw new NotImplementedException();
        }

        public ISerializable[] Deserialize(Stream stream)
        {
            ISerializable[] items = new ISerializable[stream.Length/44];
            int counter = 0;
            while (stream.Position < stream.Length)
            {
                byte[] buffer = new byte[44];
                stream.Read(buffer, 0, 44);
                ISerializable item  = (ISerializable) typeof(TelemetryData).GetConstructor(new Type[0]).Invoke(new object[0]);
                item.Deserialize(buffer);
                items[counter] = item;
                counter++;
            }
            return items;
        }

        public void Serialize(Stream stream, ISerializable graph)
        {
            byte[] buffer = graph.Serialize();
            stream.Write(buffer, 0, buffer.Length);
        }
    }
}


using System;
using Microsoft.SPOT.Hardware;
using Quad.Net.Avionics;
using Quad.Net.Commons.Serialization;
using Quad.Net.Commons.Utilities;

namespace Quad.Net.FlightController
{
    public class TelemetryData : ISerializable
    {
        private readonly AircraftPrincipalAxes  _gyroAxes;
        private readonly AircraftPrincipalAxes _radioAxes;
        private readonly AircraftPrincipalAxes _pidAxes;
        private long _currentTime;
        private readonly byte[] _buffer;
        public TelemetryData()
        {
            _gyroAxes= new AircraftPrincipalAxes(0,0,0);
            _radioAxes = new AircraftPrincipalAxes(0, 0, 0);
            _pidAxes = new AircraftPrincipalAxes(0, 0, 0);
            _currentTime = DateTime.Now.Ticks;
            _buffer = new byte[44];
        }

        public void Update(AircraftPrincipalAxes gyroAxes, AircraftPrincipalAxes radioAxes, AircraftPrincipalAxes pidAxes, long currentTime)
        {
            _gyroAxes.Update(gyroAxes.Pitch,gyroAxes.Roll,gyroAxes.Yaw);
            _radioAxes.Update(radioAxes.Pitch, radioAxes.Roll, radioAxes.Yaw);
            _pidAxes.Update(pidAxes.Pitch, pidAxes.Roll, pidAxes.Yaw);
        }

        public byte[] Serialize()
        {
            Utility.InsertValueIntoArray(_buffer, 0, 4, (uint)(_currentTime >> 32));
            Utility.InsertValueIntoArray(_buffer, 4, 4, (uint)_currentTime);
            Utility.InsertValueIntoArray(_buffer, 8, 4, (uint)_gyroAxes.Pitch);
            Utility.InsertValueIntoArray(_buffer, 12, 4, (uint)_gyroAxes.Roll);
            Utility.InsertValueIntoArray(_buffer, 16, 4, (uint)_gyroAxes.Yaw);

            Utility.InsertValueIntoArray(_buffer, 20, 4, (uint)_radioAxes.Pitch);
            Utility.InsertValueIntoArray(_buffer, 24, 4, (uint)_radioAxes.Roll);
            Utility.InsertValueIntoArray(_buffer, 28, 4, (uint)_radioAxes.Yaw);

            Utility.InsertValueIntoArray(_buffer, 32, 4, (uint)_pidAxes.Pitch);
            Utility.InsertValueIntoArray(_buffer, 36, 4, (uint)_pidAxes.Roll);
            Utility.InsertValueIntoArray(_buffer, 40, 4, (uint)_pidAxes.Yaw);
            return _buffer;
        }

        public object Deserialize(byte[] buffer)
        {
            _currentTime = BitConverter.ToLong(buffer, 0);
            _gyroAxes.Update(
                Utility.ExtractValueFromArray(buffer, 8, 4),
                Utility.ExtractValueFromArray(buffer, 12, 4),
                Utility.ExtractValueFromArray(buffer, 16, 4)
                );
            _radioAxes.Update(
                Utility.ExtractValueFromArray(buffer, 20, 4),
                Utility.ExtractValueFromArray(buffer, 24, 4),
                Utility.ExtractValueFromArray(buffer, 28, 4)
                );
            _pidAxes.Update(
                Utility.ExtractValueFromArray(buffer, 32, 4),
                Utility.ExtractValueFromArray(buffer, 36, 4),
                Utility.ExtractValueFromArray(buffer, 40, 4)
                );
            return this;
        }

        public override string ToString()
        {
            //csv format
            return _currentTime + "," +
                   _gyroAxes.Pitch + "," +
                   _gyroAxes.Roll + "," +
                   _gyroAxes.Yaw + "," +
                   _radioAxes.Pitch + "," +
                   _radioAxes.Roll + "," +
                   _radioAxes.Yaw + "," +
                   _pidAxes.Pitch + "," +
                   _pidAxes.Roll + "," +
                   _pidAxes.Yaw + ",";
        }
    }
}





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.