示例#1
0
        static void Main(string[] args)
        {
            uint zano;
            Library.Initialise("Example-GetAltitude.1.0.0");
            zano = Library.Obtain("192.168.0.1", 10001);

            bool isConnected = false;
            Frame frame = new Frame();

            Library.Connect(zano);

            while (true)
            {
                if (isConnected)
                {
                    Frames.FlightAltitudeGet(zano);
                }

                Library.Tick();

                while (Library.Receive(ref frame) == 1)
                {
                    switch (frame.Reference)
                    {
                        case Symbols.kFlightAltitudeGet:
                        {
                            int altitude = frame.Get(Symbols.kAltitude);
                            Console.WriteLine(String.Format("Altitude is {0} mm", altitude));
                        }
                        break;
                    }
                }

                Library.Status status;

                while ((status = Library.GetStatus()) != Library.Status.None)
                {
                    switch (status)
                    {
                        case Library.Status.DeviceDisconnectionDisconnected:
                        case Library.Status.DeviceConnectionNotConnected:
                        case Library.Status.DeviceConnectionHeldStill:
                        {
                            isConnected = false;
                            Library.Connect(zano);
                        }
                        break;
                        case Library.Status.DeviceConnectionConnected:
                        {
                            isConnected = true;
                        }
                        break;
                    }
                }

                Thread.Sleep(10);
            }
        }
示例#2
0
        static void Main(string[] args)
        {
            uint zano;
            Library.Initialise("Example-ConnectAndIdle.1.0.0");
            zano = Library.Obtain("192.168.0.1", 10001);

            bool isConnected = false;
            Frame frame = new Frame();

            Library.Connect(zano);

            while (true)
            {
                Library.Tick();

                while (Library.Receive(ref frame) == 1)
                {
                    // ...
                }

                Library.Status status;

                while ((status = Library.GetStatus()) != Library.Status.None)
                {
                    switch (status)
                    {
                        case Library.Status.DeviceDisconnectionDisconnected:
                        case Library.Status.DeviceConnectionNotConnected:
                        case Library.Status.DeviceConnectionHeldStill:
                        {
                            isConnected = false;
                            Library.Connect(zano);
                        }
                        break;
                        case Library.Status.DeviceConnectionConnected:
                        {
                            isConnected = true;
                        }
                        break;
                    }
                }

                Thread.Sleep(10);
            }
        }
示例#3
0
        private Accelerometer()
        {
            OnTrigger("NULL.started", args =>
            {
                U.LoadRecordings();
                V.Navigate("$Start");
                /*
                if (Z.IsConnected)
                {
                    Move("connect");
                    Move("start");
                }
                else
                {
                    Trigger("connect");
                }*/
            });

            OnTrigger("NULL.start_new", args =>
            {
                for (int i = 0; i < 6; i++)
                {
                    G.FilteredReadings[i] = 0;
                    G.FilteredComplete[i] = false;
                    G.FilteredValue[i] = 0;
                }
            });

            OnTrigger("NULL.apply_new", args =>
            {
                G.SaveRecording = true;
                Trigger("connect");
            });

            OnTrigger("NULL.apply_recording", args =>
            {
                if (args.Length != 0 && args[0] is AccelerometerRecording)
                {
                    var recording = (AccelerometerRecording) args[0];
                    G.FilteredReadings[0] = K.MinReadings;
                    G.FilteredValue[0] = recording.Filtered0;
                    G.FilteredComplete[0] = true;

                    G.FilteredReadings[1] = K.MinReadings;
                    G.FilteredValue[1] = recording.Filtered1;
                    G.FilteredComplete[1] = true;

                    G.FilteredReadings[2] = K.MinReadings;
                    G.FilteredValue[2] = recording.Filtered2;
                    G.FilteredComplete[2] = true;

                    G.FilteredReadings[3] = K.MinReadings;
                    G.FilteredValue[3] = recording.Filtered3;
                    G.FilteredComplete[3] = true;

                    G.FilteredReadings[4] = K.MinReadings;
                    G.FilteredValue[4] = recording.Filtered4;
                    G.FilteredComplete[4] = true;

                    G.FilteredReadings[5] = K.MinReadings;
                    G.FilteredValue[5] = recording.Filtered5;
                    G.FilteredComplete[5] = true;

                    G.SaveRecording = false;
                    Trigger("connect", recording.SerialNumber);
                }
            });

            OnTrigger("NULL.connect", args =>
            {
                if (Z.IsConnected == false)
                {
                    A.Trigger("connect", args);
                    Move("connect");
                }
                else
                {
                    Move("connect");
                    Trigger("connected");
                }
            });

            OnTrigger("connect.connected", args =>
            {
                bool completeSet = true;

                for (int i = 0; i < 6; i++)
                {
                    if (G.FilteredComplete[i] == false)
                    {
                        completeSet = false;
                    }
                }

                if (completeSet)
                {
                    Move("axis");
                    Trigger("save");
                }
                else
                {
                    Move("wait_start");
                }

            });

            OnMove("connect>wait_start", args =>
            {
                // Clear
                G.DidSave = false;
                for (int i = 0; i < 6; i++)
                {
                    G.FilteredReadings[i] = 0;
                    G.FilteredComplete[i] = false;
                    G.FilteredValue[i] = 0;
                }

                V.Navigate("$Accelerometer");
            });

            OnTrigger("wait_start.start", args =>
            {
                Move("start");
            });

            OnMove("wait_start>start", args =>
            {
                // Get ZanoHandler to send gyros and raw acceleration frames this way.
                Z.Listen(Symbols.kSensorsGyroGet, "receive_gyro");
                Z.Listen(Symbols.kSensorsRawAccelerationGet, "receive_accelerometer");

                Views.Accelerometer.Instance.Begin();
                Move("axis");
            });

            OnTrigger("axis.retry", args =>
            {
                G.DidSave = false;
                for (int i = 0; i < 6; i++)
                {
                    G.FilteredReadings[i] = 0;
                    G.FilteredComplete[i] = false;
                    G.FilteredValue[i] = 0;
                }
            });

            OnTrigger("axis.save, save.not_sent, connect.save", args =>
            {
                // Compile the readings into maximum and minimum readings
                G.ResultsXMin = U.MinToShort(G.FilteredValue[U.AxisToIndex(1, 0, 0)], G.FilteredValue[U.AxisToIndex(-1, 0, 0)]);
                G.ResultsXMax = U.MaxToShort(G.FilteredValue[U.AxisToIndex(1, 0, 0)], G.FilteredValue[U.AxisToIndex(-1, 0, 0)]);
                G.ResultsYMin = U.MinToShort(G.FilteredValue[U.AxisToIndex(0, 1, 0)], G.FilteredValue[U.AxisToIndex(0, -1, 0)]);
                G.ResultsYMax = U.MaxToShort(G.FilteredValue[U.AxisToIndex(0, 1, 0)], G.FilteredValue[U.AxisToIndex(0, -1, 0)]);
                G.ResultsZMin = U.MinToShort(G.FilteredValue[U.AxisToIndex(0, 0, 1)], G.FilteredValue[U.AxisToIndex(0, 0, -1)]);
                G.ResultsZMax = U.MaxToShort(G.FilteredValue[U.AxisToIndex(0, 0, 1)], G.FilteredValue[U.AxisToIndex(0, 0, -1)]);

                G.ResultsXAvg = (short)(-1 * ((G.ResultsXMin + G.ResultsXMax) / 2));
                G.ResultsYAvg = (short)(-1 * ((G.ResultsYMin + G.ResultsYMax) / 2));
                G.ResultsZAvg = (short)(-1 * ((G.ResultsZMin + G.ResultsZMax) / 2));

                // Copied from ConfigAccelOffsetSet
                Frame sendFrame = new Frame(Z.Handle);
                sendFrame.Reference = Symbols.kConfigAccelOffsetSet;
                sendFrame.Type = Frame.kSendFrame;
                unchecked
                {
                    sendFrame.Names[0] = Symbols.kX;
                    sendFrame.Values[0] = (int)G.ResultsXAvg;
                    sendFrame.Names[1] = Symbols.kY;
                    sendFrame.Values[1] = (int)G.ResultsYAvg;
                    sendFrame.Names[2] = Symbols.kZ;
                    sendFrame.Values[2] = (int)G.ResultsZAvg;
                    sendFrame.Names[3] = Symbols.kXmin;
                    sendFrame.Values[3] = (int)G.ResultsXMin;
                    sendFrame.Names[4] = Symbols.kYmin;
                    sendFrame.Values[4] = (int)G.ResultsYMin;
                    sendFrame.Names[5] = Symbols.kZmin;
                    sendFrame.Values[5] = (int)G.ResultsZMin;
                    sendFrame.Names[6] = Symbols.kXmax;
                    sendFrame.Values[6] = (int)G.ResultsXMax;
                    sendFrame.Names[7] = Symbols.kYmax;
                    sendFrame.Values[7] = (int)G.ResultsYMax;
                    sendFrame.Names[8] = Symbols.kZmax;
                    sendFrame.Values[8] = (int)G.ResultsZMax;
                }

                LibZano.Calibration.Set(ref Z.SerialNumber, ref sendFrame);
                Library.Send(ref sendFrame);

                Frames.ConfigSave(Z.Handle);

                StringBuilder sn = new StringBuilder(16);

                Library.SerialNumber serialNb = new Library.SerialNumber();

                Library.GetSerialNumber(Z.Handle, ref serialNb);
                for (int i = 0; i < 8; i++)
                {
                    sn.AppendFormat("{0:x2}", serialNb.Part[i]);
                }

                G.ResultsSerial = sn.ToString();

                StringBuilder sb = new StringBuilder();
                sb.Append(G.ResultsSerial);
                sb.AppendFormat(" {0:X8} 09", Symbols.kConfigAccelOffsetSet);
                sb.AppendFormat(" {0:X8} {1}", Symbols.kX, U.FormatShort(G.ResultsXAvg));
                sb.AppendFormat(" {0:X8} {1}", Symbols.kY, U.FormatShort(G.ResultsYAvg));
                sb.AppendFormat(" {0:X8} {1}", Symbols.kZ, U.FormatShort(G.ResultsZAvg));

                sb.AppendFormat(" {0:X8} {1}", Symbols.kXmin, U.FormatShort(G.ResultsXMin));
                sb.AppendFormat(" {0:X8} {1}", Symbols.kYmin, U.FormatShort(G.ResultsYMin));
                sb.AppendFormat(" {0:X8} {1}", Symbols.kZmin, U.FormatShort(G.ResultsZMin));

                sb.AppendFormat(" {0:X8} {1}", Symbols.kXmax, U.FormatShort(G.ResultsXMax));
                sb.AppendFormat(" {0:X8} {1}", Symbols.kYmax, U.FormatShort(G.ResultsYMax));
                sb.AppendFormat(" {0:X8} {1}", Symbols.kZmax, U.FormatShort(G.ResultsZMax));

                Console.WriteLine(sb.ToString());

                File.WriteAllText(Core.U.GetApplicationDataPath() + "last_accel_results.txt", sb.ToString());

                if (G.SaveRecording)
                {
                    AccelerometerRecording reading = new AccelerometerRecording();
                    reading.SerialNumber = Z.CopySerialNumber(serialNb);
                    G.HighestRecordingId++;
                    reading.Id = G.HighestRecordingId;
                    reading.Filtered0 = (int) G.FilteredValue[0];
                    reading.Filtered1 = (int) G.FilteredValue[1];
                    reading.Filtered2 = (int) G.FilteredValue[2];
                    reading.Filtered3 = (int) G.FilteredValue[3];
                    reading.Filtered4 = (int) G.FilteredValue[4];
                    reading.Filtered5 = (int) G.FilteredValue[5];

                    G.Recordings.Add(reading);
                    U.SaveRecordings();
                }

                G.ResultsValues = sb.ToString();

                //StringBuilder fc = new StringBuilder();
                //var now = DateTime.Now;
                //fc.AppendFormat("{0} {1}{2}", now.ToLongDateString(), now.ToLongTimeString(), Environment.NewLine);
                // fc.AppendFormat("{0}", sb.)

                //fc.AppendLine(DateTime.Now.)

                // The Zano will automatically reboot, so we should switch state and wait for the connected event which
                // is handled by libZano.
                Move("save_to_zano");
                V.Navigate("$SaveToZano");

            });

            OnTrigger("save_to_zano.disconnected", args =>
            {
                Console.WriteLine("Probably Saved");
                Move("save_to_server");
                V.Navigate("$SaveToServer");
                LibZano.ServerConnectivity.ForceRefresh();
            });

            OnTrigger("save_to_server.no_internet", args =>
            {
                Console.WriteLine("Checking for Internet");
                LibZano.ServerConnectivity.ForceRefresh();
            });

            OnTrigger("save_to_server.configuration_downloaded", args =>
            {
                Console.WriteLine("Got for Internet");
                if (G.DidSave == false)
                {
                    G.DidSave = true;
                    Console.WriteLine("Saving to server...");
                    LibZano.Calibration.ApplyToServer(ref Z.SerialNumber, Symbols.kConfigAccelOffsetSet);
                }
            });

            OnTrigger("save_to_server.config_server_save_complete", args =>
            {
                Console.WriteLine("Saved Config");
                V.Navigate("$Complete");
            });

            OnTrigger("save_to_server.config_server_save_failed", args =>
            {
                Console.WriteLine("Not Saved Config");
            });

            OnTrigger("axis.tick", args =>
            {
                Frames.SensorsGyroGet(Z.Handle);

                if (G.Recording)
                {
                    Frames.SensorsRawAccelerationGet(Z.Handle);
                }
            });

            OnTrigger("axis.receive_gyro", args =>
            {

                Frame frame = (Frame)args[0];

                // Get the gyro vector and calculate the magnitude
                double x = frame.Get(Symbols.kX);
                double y = frame.Get(Symbols.kY);
                double z = frame.Get(Symbols.kZ);
                double mag = Math.Sqrt(x * x + y * y + z * z);

                G.GyroMagnitude = mag;

                Console.WriteLine("Gyro Mag = {0}", mag);
                if (mag >= K.GyroMaxThreshold)
                {
                    // If the magnitude is over the threshold stop asking for accelerometer
                    G.Recording = false;
                    G.RecordingTime = 0;

                    int lastAxis = U.AxisToIndex(G.LastAxisX, G.LastAxisY, G.LastAxisZ);

                    if (G.FilteredReadings[lastAxis] < K.MinReadings)
                    {
                        // Was the number of readings not finished? Then reset them
                        G.FilteredComplete[lastAxis] = false;
                        G.FilteredReadings[lastAxis] = 0;
                        G.FilteredValue[lastAxis] = 0;
                    }
                }
                else
                {
                    // Underneath the current threshold

                    if (G.Recording == false)
                    {
                        // Not recording?
                        // Turn it on!
                        G.Recording = true;
                        G.RecordingTime = Library.Time();
                        G.RecordingStarted = true;
                    }
                }

                // Refresh the view
                if (Views.Accelerometer.Instance != null)
                {
                    Views.Accelerometer.Instance.Refresh();
                }
            });

            OnTrigger("axis.receive_accelerometer", args =>
            {

                Frame frame = (Frame)args[0];

                // Get raw accelerometer values
                double x = frame.Get(Symbols.kX);
                double y = frame.Get(Symbols.kY);
                double z = frame.Get(Symbols.kZ);

                int xDir = 0;
                int yDir = 0;
                int zDir = 0;

                U.GetAxisGravityVector(x, y, z, ref xDir, ref yDir, ref zDir);

                /*

                    // Console.WriteLine("{0} {1} {2}", x, y, z);

                    U.Normalise(ref x, ref y, ref z);

                    // Calculate the best axis that the Zano is pointing up as using
                    // three dot products against each of the unit vectors, from that
                    // you have a ~unit vector that is the best direction.

                    int xDir = U.DotToInt(x, y, z, 1, 0, 0);
                    int yDir = U.DotToInt(x, y, z, 0, 1, 0);
                    int zDir = U.DotToInt(x, y, z, 0, 0, 1);

                */

                // Store old axis and copy new one over.

                G.LastAxisX = G.AxisX;
                G.LastAxisY = G.AxisY;
                G.LastAxisZ = G.AxisZ;

                G.AxisX = xDir;
                G.AxisY = yDir;
                G.AxisZ = zDir;

                // Now on a different axis?

                if (G.AxisX != G.LastAxisX || G.AxisY != G.LastAxisY || G.AxisZ != G.LastAxisZ)
                {
                    int lastAxis = U.AxisToIndex(G.LastAxisX, G.LastAxisY, G.LastAxisZ);
                    if (G.FilteredReadings[lastAxis] >= K.MinReadings)
                    {
                        // Did all readings?
                        // Mark old axis as complete
                        G.FilteredComplete[lastAxis] = true;
                    }
                    else
                    {
                        // Didn't complete.?
                        // Reset readings and value, so they can be done again.
                        G.FilteredReadings[lastAxis] = 0;
                        G.FilteredComplete[lastAxis] = false;
                        G.FilteredValue[lastAxis] = 0;
                    }

                    // Say something
                    Console.WriteLine("Changed Axis from {0} to {1}", U.AxisToString(G.LastAxisX, G.LastAxisY, G.LastAxisZ), U.AxisToString(G.AxisX, G.AxisY, G.AxisZ));
                }

                int axisIndex = U.AxisToIndex(G.AxisX, G.AxisY, G.AxisZ);

                // Read and perform a low pass if the number of readings of the current axis
                // has not been met yet.
                if (G.FilteredReadings[axisIndex] < K.MinReadings)
                {

                    // Set Initial Value, which is +-4096 (based on axis) where 4096 is 1G.
                    // Ideally the accelerometer would be +-4096 but due to manufacturing this
                    // can vary, hence the need for calibration!
                    if (G.RecordingStarted)
                    {
                        G.RecordingStarted = false;
                        G.FilteredValue[axisIndex] = K.LowPassDefaultFilter * U.AxisSign(G.AxisX, G.AxisY, G.AxisZ);
                    }

                    // Perform a low pass filter on the value and store.
                    double filtered = G.FilteredValue[axisIndex];
                    double now = frame.Get(U.AxisToSymbol(G.AxisX, G.AxisY, G.AxisZ));

                    G.FilteredValue[axisIndex] = U.LowPass(filtered, now, K.LowPassD);

                    G.FilteredReadings[axisIndex]++;
                }

                // Exceeded reading count? Then it's complete
                if (G.FilteredReadings[axisIndex] >= K.MinReadings)
                {
                    G.FilteredComplete[axisIndex] = true;
                }

                // Update the view
                // V.RefreshAccelerometerDisplay();
                if (Views.Accelerometer.Instance != null)
                {
                    Views.Accelerometer.Instance.Refresh();
                }

            });

            OnTrigger("save_to_server.menu", args =>
            {
                Move("NULL");
                T.Set("NULL");
            });
        }
示例#4
0
 ///<command>
 ///	<name>camera.resolution.set</name>
 ///	<symbol>kCameraResolutionSet</symbol>
 ///	<scope>camera.resolution</scope>
 ///	<arguments>
 ///		<arg type="uint">Drone Handle</arg>
 ///		<arg type="byte" symbol="kResolution">Resolution</arg>
 ///	</arguments>
 ///	<responses>
 ///		<response type="byte" symbol="kResult">Result</response>
 ///	</responses>
 ///	<see>camera.resolution.get</see>
 ///</command>
 public static void CameraResolutionSet(uint handle, byte resolution)
 {
     Frame sendFrame = new Frame(handle);
     sendFrame.Reference = Symbols.kCameraResolutionSet;
     sendFrame.Type = Frame.kSendFrame;
     unchecked
     {
         sendFrame.Names[0] = Symbols.kResolution;
         sendFrame.Values[0] = (int) resolution;
     }
     Library.Send(ref sendFrame);
 }
示例#5
0
 ///<command>
 ///	<name>camera.imageprocessing.sharpness.get</name>
 ///	<symbol>kCameraImageprocessingSharpnessGet</symbol>
 ///	<scope>camera.imageprocessing.sharpness</scope>
 ///	<arguments>
 ///		<arg type="uint">Drone Handle</arg>
 ///	</arguments>
 ///	<responses>
 ///		<response type="byte" symbol="kValue">Value</response>
 ///	</responses>
 ///	<see>camera.imageprocessing.sharpness.set</see>
 ///</command>
 public static void CameraImageprocessingSharpnessGet(uint handle)
 {
     Frame sendFrame = new Frame(handle);
     sendFrame.Reference = Symbols.kCameraImageprocessingSharpnessGet;
     sendFrame.Type = Frame.kSendFrame;
     Library.Send(ref sendFrame);
 }
示例#6
0
 ///<command>
 ///	<name>camera.contrast.set</name>
 ///	<symbol>kCameraContrastSet</symbol>
 ///	<scope>camera.contrast</scope>
 ///	<arguments>
 ///		<arg type="uint">Drone Handle</arg>
 ///		<arg type="byte" symbol="kContrast">Contrast</arg>
 ///	</arguments>
 ///	<responses>
 ///		<response type="byte" symbol="kResult">Result</response>
 ///	</responses>
 ///	<see>camera.contrast.get</see>
 ///</command>
 public static void CameraContrastSet(uint handle, byte contrast)
 {
     Frame sendFrame = new Frame(handle);
     sendFrame.Reference = Symbols.kCameraContrastSet;
     sendFrame.Type = Frame.kSendFrame;
     unchecked
     {
         sendFrame.Names[0] = Symbols.kContrast;
         sendFrame.Values[0] = (int) contrast;
     }
     Library.Send(ref sendFrame);
 }
示例#7
0
 public static extern int TrackedSendFrame2(ref Frame frame1, ref Frame frame2, byte userData, uint maxCount, uint resendTime);
示例#8
0
 public static extern int Receive(ref Frame frame);
示例#9
0
 ///<command>
 ///	<name>system.expansion.byte.set</name>
 ///	<symbol>kSystemExpansionByteSet</symbol>
 ///	<scope>system.expansion.byte</scope>
 ///	<arguments>
 ///		<arg type="uint">Drone Handle</arg>
 ///		<arg type="byte" symbol="kLength">Length</arg>
 ///	</arguments>
 ///	<see>system.expansion.byte.get</see>
 ///</command>
 public static void SystemExpansionByteSet(uint handle, byte length)
 {
     Frame sendFrame = new Frame(handle);
     sendFrame.Reference = Symbols.kSystemExpansionByteSet;
     sendFrame.Type = Frame.kSendFrame;
     unchecked
     {
         sendFrame.Names[0] = Symbols.kLength;
         sendFrame.Values[0] = (int) length;
     }
     Library.Send(ref sendFrame);
 }
示例#10
0
 ///<command>
 ///	<name>system.calibratecompass.set</name>
 ///	<symbol>kSystemCalibratecompassSet</symbol>
 ///	<scope>system.calibratecompass</scope>
 ///	<arguments>
 ///		<arg type="uint">Drone Handle</arg>
 ///	</arguments>
 ///</command>
 public static void SystemCalibratecompassSet(uint handle)
 {
     Frame sendFrame = new Frame(handle);
     sendFrame.Reference = Symbols.kSystemCalibratecompassSet;
     sendFrame.Type = Frame.kSendFrame;
     Library.Send(ref sendFrame);
 }
示例#11
0
 ///<command>
 ///	<name>system.bandwidth.set</name>
 ///	<symbol>kSystemBandwidthSet</symbol>
 ///	<scope>system.bandwidth</scope>
 ///	<arguments>
 ///		<arg type="uint">Drone Handle</arg>
 ///		<arg type="ushort" symbol="kValue">Value</arg>
 ///	</arguments>
 ///	<see>system.bandwidth.get</see>
 ///</command>
 public static void SystemBandwidthSet(uint handle, ushort value)
 {
     Frame sendFrame = new Frame(handle);
     sendFrame.Reference = Symbols.kSystemBandwidthSet;
     sendFrame.Type = Frame.kSendFrame;
     unchecked
     {
         sendFrame.Names[0] = Symbols.kValue;
         sendFrame.Values[0] = (int) value;
     }
     Library.Send(ref sendFrame);
 }
示例#12
0
 ///<command>
 ///	<name>sensors.temperature.get</name>
 ///	<symbol>kSensorsTemperatureGet</symbol>
 ///	<scope>sensors.temperature</scope>
 ///	<arguments>
 ///		<arg type="uint">Drone Handle</arg>
 ///	</arguments>
 ///	<responses>
 ///		<response type="short" symbol="kTemperature">Temperature</response>
 ///	</responses>
 ///</command>
 public static void SensorsTemperatureGet(uint handle)
 {
     Frame sendFrame = new Frame(handle);
     sendFrame.Reference = Symbols.kSensorsTemperatureGet;
     sendFrame.Type = Frame.kSendFrame;
     Library.Send(ref sendFrame);
 }
示例#13
0
 ///<command>
 ///	<name>messages.get</name>
 ///	<symbol>kMessagesGet</symbol>
 ///	<scope>messages</scope>
 ///	<arguments>
 ///		<arg type="uint">Drone Handle</arg>
 ///		<arg type="byte" symbol="kIndex">Index</arg>
 ///	</arguments>
 ///	<responses>
 ///		<response type="byte" symbol="kIndex">Index</response>
 ///		<response type="byte" symbol="kCount">Count</response>
 ///		<response type="ushort" symbol="kLength">Length</response>
 ///	</responses>
 ///</command>
 public static void MessagesGet(uint handle, byte index)
 {
     Frame sendFrame = new Frame(handle);
     sendFrame.Reference = Symbols.kMessagesGet;
     sendFrame.Type = Frame.kSendFrame;
     unchecked
     {
         sendFrame.Names[0] = Symbols.kIndex;
         sendFrame.Values[0] = (int) index;
     }
     Library.Send(ref sendFrame);
 }
示例#14
0
 ///<command>
 ///	<name>media.recv</name>
 ///	<symbol>kMediaRecv</symbol>
 ///	<scope>media</scope>
 ///	<arguments>
 ///		<arg type="uint">Drone Handle</arg>
 ///	</arguments>
 ///	<responses>
 ///		<response type="ushort" symbol="kType">Type</response>
 ///		<response type="uint" symbol="kTime">Time</response>
 ///		<response type="uint" symbol="kFrame">Frame</response>
 ///		<response type="uint" symbol="kLength">Length</response>
 ///		<response type="uint" symbol="kOffset">Offset</response>
 ///		<response type="ushort" symbol="kFragmentSize">FragmentSize</response>
 ///	</responses>
 ///	<see>media.get</see>
 ///</command>
 public static void MediaRecv(uint handle)
 {
     Frame sendFrame = new Frame(handle);
     sendFrame.Reference = Symbols.kMediaRecv;
     sendFrame.Type = Frame.kSendFrame;
     Library.Send(ref sendFrame);
 }
示例#15
0
 ///<command>
 ///	<name>media.get</name>
 ///	<symbol>kMediaGet</symbol>
 ///	<scope>media</scope>
 ///	<arguments>
 ///		<arg type="uint">Drone Handle</arg>
 ///		<arg type="ushort" symbol="kType">Type</arg>
 ///		<arg type="uint" symbol="kFrame">Frame</arg>
 ///	</arguments>
 ///	<see>media.recv</see>
 ///</command>
 public static void MediaGet(uint handle, ushort type, uint frame)
 {
     Frame sendFrame = new Frame(handle);
     sendFrame.Reference = Symbols.kMediaGet;
     sendFrame.Type = Frame.kSendFrame;
     unchecked
     {
         sendFrame.Names[0] = Symbols.kType;
         sendFrame.Values[0] = (int) type;
         sendFrame.Names[1] = Symbols.kFrame;
         sendFrame.Values[1] = (int) frame;
     }
     Library.Send(ref sendFrame);
 }
示例#16
0
 ///<command>
 ///	<name>waypoint.stop</name>
 ///	<symbol>kWaypointStop</symbol>
 ///	<scope>waypoint</scope>
 ///	<arguments>
 ///		<arg type="uint">Drone Handle</arg>
 ///	</arguments>
 ///	<see>waypoint.add</see>
 ///	<see>waypoint.get</see>
 ///	<see>waypoint.mode</see>
 ///	<see>waypoint.pause</see>
 ///	<see>waypoint.set</see>
 ///	<see>waypoint.start</see>
 ///</command>
 public static void WaypointStop(uint handle)
 {
     Frame sendFrame = new Frame(handle);
     sendFrame.Reference = Symbols.kWaypointStop;
     sendFrame.Type = Frame.kSendFrame;
     Library.Send(ref sendFrame);
 }
示例#17
0
 ///<command>
 ///	<name>camera.bandingfilter.set</name>
 ///	<symbol>kCameraBandingfilterSet</symbol>
 ///	<scope>camera.bandingfilter</scope>
 ///	<arguments>
 ///		<arg type="uint">Drone Handle</arg>
 ///		<arg type="byte" symbol="kFilter">Filter</arg>
 ///	</arguments>
 ///	<responses>
 ///		<response type="byte" symbol="kResult">Result</response>
 ///	</responses>
 ///	<see>camera.bandingfilter.get</see>
 ///</command>
 public static void CameraBandingfilterSet(uint handle, byte filter)
 {
     Frame sendFrame = new Frame(handle);
     sendFrame.Reference = Symbols.kCameraBandingfilterSet;
     sendFrame.Type = Frame.kSendFrame;
     unchecked
     {
         sendFrame.Names[0] = Symbols.kFilter;
         sendFrame.Values[0] = (int) filter;
     }
     Library.Send(ref sendFrame);
 }
示例#18
0
 ///<command>
 ///	<name>camera.agc.exposure.weight.get</name>
 ///	<symbol>kCameraAgcExposureWeightGet</symbol>
 ///	<scope>camera.agc.exposure.weight</scope>
 ///	<arguments>
 ///		<arg type="uint">Drone Handle</arg>
 ///	</arguments>
 ///	<responses>
 ///		<response type="byte" symbol="kValue">Value</response>
 ///	</responses>
 ///	<see>camera.agc.exposure.weight.set</see>
 ///</command>
 public static void CameraAgcExposureWeightGet(uint handle)
 {
     Frame sendFrame = new Frame(handle);
     sendFrame.Reference = Symbols.kCameraAgcExposureWeightGet;
     sendFrame.Type = Frame.kSendFrame;
     Library.Send(ref sendFrame);
 }
示例#19
0
 public static extern int Send(ref Frame frame);
示例#20
0
 ///<command>
 ///	<name>system.expansion.config.set</name>
 ///	<symbol>kSystemExpansionConfigSet</symbol>
 ///	<scope>system.expansion.config</scope>
 ///	<arguments>
 ///		<arg type="uint">Drone Handle</arg>
 ///		<arg type="byte" symbol="kSpeed">Speed</arg>
 ///	</arguments>
 ///</command>
 public static void SystemExpansionConfigSet(uint handle, byte speed)
 {
     Frame sendFrame = new Frame(handle);
     sendFrame.Reference = Symbols.kSystemExpansionConfigSet;
     sendFrame.Type = Frame.kSendFrame;
     unchecked
     {
         sendFrame.Names[0] = Symbols.kSpeed;
         sendFrame.Values[0] = (int) speed;
     }
     Library.Send(ref sendFrame);
 }
示例#21
0
 ///<command>
 ///	<name>camera.brightness.set</name>
 ///	<symbol>kCameraBrightnessSet</symbol>
 ///	<scope>camera.brightness</scope>
 ///	<arguments>
 ///		<arg type="uint">Drone Handle</arg>
 ///		<arg type="byte" symbol="kBrightness">Brightness</arg>
 ///	</arguments>
 ///	<responses>
 ///		<response type="byte" symbol="kResult">Result</response>
 ///	</responses>
 ///	<see>camera.brightness.get</see>
 ///</command>
 public static void CameraBrightnessSet(uint handle, byte brightness)
 {
     Frame sendFrame = new Frame(handle);
     sendFrame.Reference = Symbols.kCameraBrightnessSet;
     sendFrame.Type = Frame.kSendFrame;
     unchecked
     {
         sendFrame.Names[0] = Symbols.kBrightness;
         sendFrame.Values[0] = (int) brightness;
     }
     Library.Send(ref sendFrame);
 }
示例#22
0
 ///<command>
 ///	<name>system.motor.set</name>
 ///	<symbol>kSystemMotorSet</symbol>
 ///	<scope>system.motor</scope>
 ///	<arguments>
 ///		<arg type="uint">Drone Handle</arg>
 ///		<arg type="short" symbol="kMotor1">Motor1</arg>
 ///		<arg type="short" symbol="kMotor2">Motor2</arg>
 ///		<arg type="short" symbol="kMotor3">Motor3</arg>
 ///		<arg type="short" symbol="kMotor4">Motor4</arg>
 ///	</arguments>
 ///</command>
 public static void SystemMotorSet(uint handle, short motor1, short motor2, short motor3, short motor4)
 {
     Frame sendFrame = new Frame(handle);
     sendFrame.Reference = Symbols.kSystemMotorSet;
     sendFrame.Type = Frame.kSendFrame;
     unchecked
     {
         sendFrame.Names[0] = Symbols.kMotor1;
         sendFrame.Values[0] = (int) motor1;
         sendFrame.Names[1] = Symbols.kMotor2;
         sendFrame.Values[1] = (int) motor2;
         sendFrame.Names[2] = Symbols.kMotor3;
         sendFrame.Values[2] = (int) motor3;
         sendFrame.Names[3] = Symbols.kMotor4;
         sendFrame.Values[3] = (int) motor4;
     }
     Library.Send(ref sendFrame);
 }
示例#23
0
 ///<command>
 ///	<name>camera.imageprocessing.pixelcorrection.set</name>
 ///	<symbol>kCameraImageprocessingPixelcorrectionSet</symbol>
 ///	<scope>camera.imageprocessing.pixelcorrection</scope>
 ///	<arguments>
 ///		<arg type="uint">Drone Handle</arg>
 ///		<arg type="byte" symbol="kValue">Value</arg>
 ///	</arguments>
 ///	<responses>
 ///		<response type="byte" symbol="kResult">Result</response>
 ///	</responses>
 ///	<see>camera.imageprocessing.pixelcorrection.get</see>
 ///</command>
 public static void CameraImageprocessingPixelcorrectionSet(uint handle, byte value)
 {
     Frame sendFrame = new Frame(handle);
     sendFrame.Reference = Symbols.kCameraImageprocessingPixelcorrectionSet;
     sendFrame.Type = Frame.kSendFrame;
     unchecked
     {
         sendFrame.Names[0] = Symbols.kValue;
         sendFrame.Values[0] = (int) value;
     }
     Library.Send(ref sendFrame);
 }
示例#24
0
 ///<command>
 ///	<name>system.obstacle.pid.get</name>
 ///	<symbol>kSystemObstaclePidGet</symbol>
 ///	<scope>system.obstacle.pid</scope>
 ///	<arguments>
 ///		<arg type="uint">Drone Handle</arg>
 ///	</arguments>
 ///	<responses>
 ///		<response type="int" symbol="kPitchProportional">PitchProportional</response>
 ///		<response type="int" symbol="kPitchIntegral">PitchIntegral</response>
 ///		<response type="int" symbol="kPitchDerivative">PitchDerivative</response>
 ///		<response type="int" symbol="kRollProportional">RollProportional</response>
 ///		<response type="int" symbol="kRollIntegral">RollIntegral</response>
 ///		<response type="int" symbol="kRollDerivative">RollDerivative</response>
 ///		<response type="int" symbol="kYawProportional">YawProportional</response>
 ///		<response type="int" symbol="kYawIntegral">YawIntegral</response>
 ///		<response type="int" symbol="kYawDerivative">YawDerivative</response>
 ///	</responses>
 ///</command>
 public static void SystemObstaclePidGet(uint handle)
 {
     Frame sendFrame = new Frame(handle);
     sendFrame.Reference = Symbols.kSystemObstaclePidGet;
     sendFrame.Type = Frame.kSendFrame;
     Library.Send(ref sendFrame);
 }
示例#25
0
 ///<command>
 ///	<name>camera.photo.get</name>
 ///	<symbol>kCameraPhotoGet</symbol>
 ///	<scope>camera.photo</scope>
 ///	<arguments>
 ///		<arg type="uint">Drone Handle</arg>
 ///		<arg type="byte" symbol="kValue">Value</arg>
 ///	</arguments>
 ///</command>
 public static void CameraPhotoGet(uint handle, byte value)
 {
     Frame sendFrame = new Frame(handle);
     sendFrame.Reference = Symbols.kCameraPhotoGet;
     sendFrame.Type = Frame.kSendFrame;
     unchecked
     {
         sendFrame.Names[0] = Symbols.kValue;
         sendFrame.Values[0] = (int) value;
     }
     Library.Send(ref sendFrame);
 }
示例#26
0
 ///<command>
 ///	<name>system.time.set</name>
 ///	<symbol>kSystemTimeSet</symbol>
 ///	<scope>system.time</scope>
 ///	<arguments>
 ///		<arg type="uint">Drone Handle</arg>
 ///		<arg type="uint" symbol="kTime">Time</arg>
 ///	</arguments>
 ///	<see>system.time.get</see>
 ///</command>
 public static void SystemTimeSet(uint handle, uint time)
 {
     Frame sendFrame = new Frame(handle);
     sendFrame.Reference = Symbols.kSystemTimeSet;
     sendFrame.Type = Frame.kSendFrame;
     unchecked
     {
         sendFrame.Names[0] = Symbols.kTime;
         sendFrame.Values[0] = (int) time;
     }
     Library.Send(ref sendFrame);
 }
示例#27
0
 ///<command>
 ///	<name>camera.saturation.get</name>
 ///	<symbol>kCameraSaturationGet</symbol>
 ///	<scope>camera.saturation</scope>
 ///	<arguments>
 ///		<arg type="uint">Drone Handle</arg>
 ///	</arguments>
 ///	<responses>
 ///		<response type="byte" symbol="kSaturation">Saturation</response>
 ///	</responses>
 ///	<see>camera.saturation.set</see>
 ///</command>
 public static void CameraSaturationGet(uint handle)
 {
     Frame sendFrame = new Frame(handle);
     sendFrame.Reference = Symbols.kCameraSaturationGet;
     sendFrame.Type = Frame.kSendFrame;
     Library.Send(ref sendFrame);
 }
示例#28
0
 ///<command>
 ///	<name>waypoint.get</name>
 ///	<symbol>kWaypointGet</symbol>
 ///	<scope>waypoint</scope>
 ///	<arguments>
 ///		<arg type="uint">Drone Handle</arg>
 ///		<arg type="ushort" symbol="kWaypointId">WaypointId</arg>
 ///	</arguments>
 ///	<responses>
 ///		<response type="ushort" symbol="kWaypointId">WaypointId</response>
 ///		<response type="int" symbol="kLatitude">Latitude</response>
 ///		<response type="int" symbol="kLongitude">Longitude</response>
 ///		<response type="int" symbol="kLatitudeDirection">LatitudeDirection</response>
 ///		<response type="int" symbol="kLongitudeDirection">LongitudeDirection</response>
 ///		<response type="int" symbol="kAltitude">Altitude</response>
 ///		<response type="uint" symbol="kType">Type</response>
 ///		<response type="uint" symbol="kFlags">Flags</response>
 ///	</responses>
 ///	<see>waypoint.add</see>
 ///	<see>waypoint.mode</see>
 ///	<see>waypoint.pause</see>
 ///	<see>waypoint.set</see>
 ///	<see>waypoint.start</see>
 ///	<see>waypoint.stop</see>
 ///</command>
 public static void WaypointGet(uint handle, ushort waypointid)
 {
     Frame sendFrame = new Frame(handle);
     sendFrame.Reference = Symbols.kWaypointGet;
     sendFrame.Type = Frame.kSendFrame;
     unchecked
     {
         sendFrame.Names[0] = Symbols.kWaypointId;
         sendFrame.Values[0] = (int) waypointid;
     }
     Library.Send(ref sendFrame);
 }
示例#29
0
        public static void Tick()
        {
            if (Initialised && CanTick)
            {
                A.Trigger("tick");

                LibZano.Library.GetFirmwareVersion(Handle, ref FirmwareVersion);

                if (Library.Time() >= BatteryTimer)
                {
                    BatteryTimer = Library.Time() + 1000;
                    Console.WriteLine("Booted = {0}, Connected = {1}", IsBooted, IsConnected);
                    if (IsBooted && IsConnected)
                    {
                        Frames.SensorsBatteryGet(Handle);
                    }
                }

                Library.Tick();

                Frame frame = new Frame();

                while (Library.Receive(ref frame) == 1)
                {
                    switch (frame.Type)
                    {
                        case Frame.kSendFrame:
                        {
                            String evt;
                            if (listens.TryGetValue(frame.Reference, out evt))
                            {
                                T.Trigger(evt, frame);
                            }

                            if (frame.Reference == Symbols.kSensorsBatteryGet)
                            {
                                Z.LastBattery = frame.Get(Symbols.kCharge);
                                Console.WriteLine("Battery = {0}", Z.LastBattery);
                                A.Trigger("battery", Z.LastBattery);
                            }
                        }
                            break;
                        case Frame.kConnectFrame:
                            {
                                Console.WriteLine("Connect Frame");
                            }
                            break;
                        case Frame.kDisconnectFrame:
                            {
                                Console.WriteLine("Disconnect Frame");
                            }
                            break;
                        case Frame.kFlyStateFrame:
                            {
                                Console.WriteLine("Fly State Frame");
                            }
                            break;
                        case Frame.kFirmware:
                            {
                                Console.WriteLine("Firmware Frame");
                            }
                            break;
                        case Frame.kServerConnectivity:
                            {
                                Console.WriteLine("Server Connectivity Frame");
                            }
                            break;
                    }
                }

                Library.Status status;

                while ((status = Library.GetStatus()) != Library.Status.None)
                {
                    Console.WriteLine("Status = {0}", status);

                    switch (status)
                    {
                        case Library.Status.None:
                            break;
                        case Library.Status.FlashingStarted:
                            Internal.Connect.Trigger("firmware_upgrade_start");
                            A.Trigger("firmware_upgrade_start");
                            break;
                        case Library.Status.FlashingProcessSucessfull:
                            Internal.Connect.Trigger("firmware_upgrade_start_complete");
                            A.Trigger("firmware_upgrade_start_complete");
                            break;
                        case Library.Status.FlashingProcessFailed:
                            Internal.Connect.Trigger("firmware_upgrade_start_failed");
                            A.Trigger("firmware_upgrade_start_failed");
                            break;
                        case Library.Status.FlashingProcessInProgress:
                            Internal.Connect.Trigger("firmware_upgrade_in_progress");
                            A.Trigger("firmware_upgrade_in_progress");
                            break;
                        case Library.Status.ConfigurationStarting:
                            break;
                        case Library.Status.ConfigurationApplied:
                            break;
                        case Library.Status.ConfigurationNotNeeded:
                            break;
                        case Library.Status.ConfigurationDoesNotExist:
                            break;
                        case Library.Status.HelloRequested:
                            break;
                        case Library.Status.HelloSuccess:
                            A.Trigger("has_internet");
                            T.Trigger("has_internet");
                            break;
                        case Library.Status.HelloFailed:
                            A.Trigger("no_internet");
                            T.Trigger("no_internet");
                            break;
                        case Library.Status.HaveServerConnection:
                            A.Trigger("have_server_connection");
                            T.Trigger("have_server_connection");
                            break;
                        case Library.Status.FirmwareDownloadingRequested:
                            break;
                        case Library.Status.FirmwareDownloadedNew:
                            break;
                        case Library.Status.FirmwareDownloadedUpToDate:
                            break;
                        case Library.Status.FirmwareDownloadedNetworkError:
                            break;
                        case Library.Status.ConfigurationRequest:
                            break;
                        case Library.Status.ConfigurationNetworkError:
                            break;
                        case Library.Status.ConfigurationAuthenticationError:
                            break;
                        case Library.Status.ConfigurationNoConfigurationAssociatedWithAccount:
                            break;
                        case Library.Status.ConfigurationDownloaded:
                            A.Trigger("configuration_downloaded");
                            T.Trigger("configuration_downloaded");
                            break;
                        case Library.Status.DeviceConnectionAttempt:
                            break;
                        case Library.Status.DeviceConnectionGotConnection:
                            break;
                        case Library.Status.DeviceConnectionBooted:
                            Internal.Connect.Trigger("booted");
                            A.Trigger("booted");

                            break;
                        case Library.Status.DeviceConnectionInRecovery:
                            break;
                        case Library.Status.DeviceConnectionHeldStill:
                            Internal.Connect.Trigger("not_still");
                            A.Trigger("not_still");
                            break;
                        case Library.Status.DeviceConnectionBootFailure:
                            break;
                        case Library.Status.DeviceConnectionNeedToUpdate:
                            Internal.Connect.Trigger("need_to_update");
                            A.Trigger("need_to_update");
                            break;
                        case Library.Status.DeviceConnectionConnected:
                            Library.GetSerialNumber(Handle, ref SerialNumber);
                            Internal.Connect.Trigger("connected");
                            A.Trigger("connected");
                            BatteryTimer = Library.Time() + 1000;
                            LastBattery = 0;
                            break;
                        case Library.Status.DeviceConnectionNotConnected:
                            LastBattery = 0;
                            Internal.Connect.Trigger("not_connected");
                            A.Trigger("not_connected");
                            break;
                        case Library.Status.DeviceConnectionBadUpdate:
                            Internal.Connect.Trigger("bad_update");
                            A.Trigger("bad_update");
                            break;
                        case Library.Status.DeviceConnectionDroneNotAssociatedWithAccount:
                            Internal.Connect.Trigger("drone_not_associated");
                            A.Trigger("drone_not_associated");
                            break;
                        case Library.Status.DeviceConnectionPeekConnected:
                            A.Trigger("peek_connected");
                            break;
                        case Library.Status.DeviceDisconnectionDisconnected:
                            LastBattery = 0;
                            T.Trigger("disconnected");
                            A.Trigger("disconnected");
                            break;
                        case Library.Status.ServerConnectivityLoginSuccess:
                            A.Trigger("logged_in");
                            T.Trigger("logged_in");
                            break;
                        case Library.Status.ServerConnectivityLoginFailure:
                            A.Trigger("not_logged_in");
                            T.Trigger("not_logged_in");
                            break;
                        case Library.Status.FirmwareConfigurationPersistanceSaveRequested:
                            A.Trigger("config_server_save_started");
                            T.Trigger("config_server_save_started");
                            break;
                        case Library.Status.FirmwareConfigurationPersistanceSaveCompleted:
                            A.Trigger("config_server_save_complete");
                            T.Trigger("config_server_save_complete");
                            break;
                        case Library.Status.FirmwareConfigurationPersistanceSaveFailure:
                            A.Trigger("config_server_save_failed");
                            T.Trigger("config_server_save_failed");
                            break;
                    }
                }
            }
        }
示例#30
0
 ///<command>
 ///	<name>waypoint.set</name>
 ///	<symbol>kWaypointSet</symbol>
 ///	<scope>waypoint</scope>
 ///	<arguments>
 ///		<arg type="uint">Drone Handle</arg>
 ///		<arg type="ushort" symbol="kWaypointId">WaypointId</arg>
 ///		<arg type="int" symbol="kLatitude">Latitude</arg>
 ///		<arg type="int" symbol="kLongitude">Longitude</arg>
 ///		<arg type="int" symbol="kLatitudeDirection">LatitudeDirection</arg>
 ///		<arg type="int" symbol="kLongitudeDirection">LongitudeDirection</arg>
 ///		<arg type="int" symbol="kAltitude">Altitude</arg>
 ///		<arg type="uint" symbol="kType">Type</arg>
 ///		<arg type="uint" symbol="kFlags">Flags</arg>
 ///	</arguments>
 ///	<responses>
 ///		<response type="ushort" symbol="kid">id</response>
 ///	</responses>
 ///	<see>waypoint.add</see>
 ///	<see>waypoint.get</see>
 ///	<see>waypoint.mode</see>
 ///	<see>waypoint.pause</see>
 ///	<see>waypoint.start</see>
 ///	<see>waypoint.stop</see>
 ///</command>
 public static void WaypointSet(uint handle, ushort waypointid, int latitude, int longitude, int latitudedirection, int longitudedirection, int altitude, uint type, uint flags)
 {
     Frame sendFrame = new Frame(handle);
     sendFrame.Reference = Symbols.kWaypointSet;
     sendFrame.Type = Frame.kSendFrame;
     unchecked
     {
         sendFrame.Names[0] = Symbols.kWaypointId;
         sendFrame.Values[0] = (int) waypointid;
         sendFrame.Names[1] = Symbols.kLatitude;
         sendFrame.Values[1] = (int) latitude;
         sendFrame.Names[2] = Symbols.kLongitude;
         sendFrame.Values[2] = (int) longitude;
         sendFrame.Names[3] = Symbols.kLatitudeDirection;
         sendFrame.Values[3] = (int) latitudedirection;
         sendFrame.Names[4] = Symbols.kLongitudeDirection;
         sendFrame.Values[4] = (int) longitudedirection;
         sendFrame.Names[5] = Symbols.kAltitude;
         sendFrame.Values[5] = (int) altitude;
         sendFrame.Names[6] = Symbols.kType;
         sendFrame.Values[6] = (int) type;
         sendFrame.Names[7] = Symbols.kFlags;
         sendFrame.Values[7] = (int) flags;
     }
     Library.Send(ref sendFrame);
 }