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 23-May 23)


By content type

See this member's


Sort by                Order  

#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



#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?



#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



#9590 Automated Build and Deploy

Posted by Brandon G on 15 February 2011 - 06:45 PM in General Discussion

Hey guys, sorry if this has been posted before but I have yet to find it in my searches. I have a windows form app that is used to generate a configuiration file, I would then like to embed the config file as a resource in a netmf project and then do a build and deploy. I have seen similar things before when people try to use VB.NET instead of C# on microframework so i know its possible just wondering if anyone has already done this and wants to share the project. Think it would be a handy little library for everybody, also gets around the weak references issue with config files



#8565 Coding style discussion

Posted by Brandon G on 27 January 2011 - 05:04 PM in General Discussion

•Do not use Hungarian notation •Do not use a prefix for member variables (_, m_, s_, etc.). If you want to distinguish between local and member variables you should use “this.” in C# and “Me.” in VB.NET. •Do use camelCasing for member variables •Do use camelCasing for parameters •Do use camelCasing for local variables •Do use PascalCasing for function, property, event, and class names •Do prefix interfaces names with “I” •Do not prefix enums, classes, or delegates with any letter Me and the rest of the community disagree with this, i understand why its stated as it is, but i disagree. using this. is ugly and redundant (resharper agrees) Its just a style, i've worked with a few of the top guys over the years and we all use this style, at beginning of projects we agree on a naming convention and this is the one we have consistently agreed upon



#8567 Coding style discussion

Posted by Brandon G on 27 January 2011 - 05:22 PM in General Discussion

yea its counterintuitive I is used for Interface and I want to know that straight up at the beginning if i'm dealing with an interface. I think at the end of there are slight variations in coding style, i like to know whether i'm private or public or a const or a Public Member and interface a factory a handler a delegate an event, just by looking at the variable name, i used to be even more explicit than this but the big guys jumped all over me. Its just a readability thing for me and as long as all parties agree at beginning of project you're solid. And Chris / Luke, never do i burn a bridge, but cut me some slack, we're all just trying to do neat stuff and have fun or work, how we post is not a big deal, if i get excited about something sometimes i'll throw a few posts down in a row, its an iterative process and sometimes a stream of thought happens, there's no egos or etiquette, its just code. We are all a community and need each others help at certain points in the process, so I would hope to be able to lean on anyone that has more experience than I especially in this specific project, hopefully one day you can lean on me for parts of your projects.



#8575 Coding style discussion

Posted by Brandon G on 27 January 2011 - 06:54 PM in General Discussion

Resharper is my best practises post processor :)



#8560 Coding style discussion

Posted by Brandon G on 27 January 2011 - 04:21 PM in General Discussion

lol on the underscores, there's alot of things i do that arent in ms' best practises. I'd say 80% of the community uses the same naming practises as above. Going to research the IL to see your other suggestion



#8597 Coding style discussion

Posted by Brandon G on 28 January 2011 - 04:04 AM in General Discussion

Mark, Thank you for your comments, this forum has truly tested my ability to hold my tongue and be professional. I will try to make a point of not posting questions that expose you to my "amateur / ignorant" coding techniques shared by ms mvps and the ms clr team. Great community we have here.



#8181 Coding style discussion

Posted by Brandon G on 23 January 2011 - 05:12 PM in General Discussion

Yes Domain Driven Design, read eric evans and Jimmy Nillson, they changed everything



#7788 Fluent Interop 1.2

Posted by Brandon G on 17 January 2011 - 01:24 AM in Project Showcase

That is fantastic and may help for getting quicker results in my quad project



#9129 Interesting news Pyxis

Posted by Brandon G on 07 February 2011 - 07:32 PM in General Discussion

http://www.engadget....-embedded-chip/



#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



#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



#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.



#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



#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



#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



#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



#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)?



#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



#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



#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()



#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 + ",";
        }
    }
}




#7750 Netduino ESC driver

Posted by Brandon G on 16 January 2011 - 07:25 AM in Netduino 2 (and Netduino 1)

Chris, as i look through how to do this best you are turning out to be a great resource, thanks it really appreciated. the above code, just trying to get my head around the concepts and expose my newbie skill sets here. the SetPulse method of the pwm, what is the 20,000, trying to find docs on it but dont quite get it I will attach my changes/ assumptions afterwards




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.