예제 #1
0
 public SystemTime(MavLinkMessage message) : base(null)
 {
     if (message.messid == this.MessageID)
     {
         MAVLink.mavlink_system_time_t data = (MAVLink.mavlink_system_time_t)message.data_struct;
         this.time_boot_ms  = data.time_boot_ms;
         this.time_unix_sec = data.time_unix_usec;
     }
 }
예제 #2
0
        public void Main()
        {
            stopwatch = new Stopwatch();
            stopwatch.Start();

            drones.Add("bebop2", new DroneData("192.168.42.1", 20000));

            MAVLink.mavlink_system_time_t cmd = new MAVLink.mavlink_system_time_t();
            cmd.time_boot_ms   = 0;
            cmd.time_unix_usec = (ulong)((DateTime.UtcNow - unix_epoch).TotalMilliseconds * 1000);
            byte[] pkt = mavlinkParse.GenerateMAVLinkPacket20(MAVLink.MAVLINK_MSG_ID.SYSTEM_TIME, cmd);
            foreach (KeyValuePair <string, DroneData> drone in drones)
            {
                mavSock.SendTo(pkt, drone.Value.ep);
            }
            send_flag = true;
        }
예제 #3
0
        public void CheckSystemTimeObject()
        {
            MAVLink.mavlink_system_time_t timeStruct = new MAVLink.mavlink_system_time_t();
            timeStruct.time_boot_ms   = 1;
            timeStruct.time_unix_usec = 2;

            MavLinkMessage message = createSampleMessage(MAVLink.MAVLINK_MSG_ID.SYSTEM_TIME, timeStruct);

            SystemTime systemTime = new SystemTime(message);

            Assert.AreEqual(timeStruct.time_boot_ms, systemTime.time_boot_ms);
            Assert.AreEqual(timeStruct.time_unix_usec, systemTime.time_unix_sec);

            SystemTimeDTO dto = DTOFactory.createSystemTimeDTO(systemTime);

            Assert.AreEqual(dto.time_boot_ms, systemTime.time_boot_ms);
            Assert.AreEqual(dto.time_unix_sec, systemTime.time_unix_sec);

            String json = JsonConvert.SerializeObject(dto);
        }
        static void Main()
        {
            stopwatch = new Stopwatch();
            stopwatch.Start();

            drones.Add("micro_uwb", new DroneData("127.0.0.1", 20000, 0));
            drones.Add("micro_uwb2", new DroneData("127.0.0.1", 20000, 1));
            drones.Add("micro_uwb3", new DroneData("127.0.0.1", 20000, 2));

            Console.WriteLine("SampleClientML managed client application starting...\n");
            /*  [NatNet] Initialize client object and connect to the server  */
            connectToServer();                          // Initialize a NatNetClient object and connect to a server.

            Console.WriteLine("============================ SERVER DESCRIPTOR ================================\n");
            /*  [NatNet] Confirming Server Connection. Instantiate the server descriptor object and obtain the server description. */
            bool connectionConfirmed = fetchServerDescriptor();    // To confirm connection, request server description data

            MAVLink.mavlink_system_time_t cmd = new MAVLink.mavlink_system_time_t();
            cmd.time_boot_ms   = 0;
            cmd.time_unix_usec = (ulong)((DateTime.UtcNow - unix_epoch).TotalMilliseconds * 1000);
            byte[] pkt = mavlinkParse.GenerateMAVLinkPacket20(MAVLink.MAVLINK_MSG_ID.SYSTEM_TIME, cmd);
            foreach (KeyValuePair <string, DroneData> drone in drones)
            {
                mavSock.SendTo(pkt, drone.Value.ep);
            }

            if (connectionConfirmed)                         // Once the connection is confirmed.
            {
                Console.WriteLine("============================= DATA DESCRIPTOR =================================\n");
                Console.WriteLine("Now Fetching the Data Descriptor.\n");
                fetchDataDescriptor();                  //Fetch and parse data descriptor

                Console.WriteLine("============================= FRAME OF DATA ===================================\n");
                Console.WriteLine("Now Fetching the Frame Data\n");

                /*  [NatNet] Assigning a event handler function for fetching frame data each time a frame is received   */
                mNatNet.OnFrameReady += new NatNetML.FrameReadyEventHandler(fetchFrameData);

                Console.WriteLine("Success: Data Port Connected \n");

                Console.WriteLine("======================== STREAMING IN (PRESS ESC TO EXIT) =====================\n");
            }


            while (!(Console.KeyAvailable && Console.ReadKey().Key == ConsoleKey.Escape))
            {
                // Continuously listening for Frame data
                // Enter ESC to exit

                // Exception handler for updated assets list.
                if (mAssetChanged == true)
                {
                    Console.WriteLine("\n===============================================================================\n");
                    Console.WriteLine("Change in the list of the assets. Refetching the descriptions");

                    /*  Clear out existing lists */
                    mDataDescriptor.Clear();
                    mHtSkelRBs.Clear();
                    mRigidBodies.Clear();
                    mSkeletons.Clear();
                    mForcePlates.Clear();

                    /* [NatNet] Re-fetch the updated list of descriptors  */
                    fetchDataDescriptor();
                    Console.WriteLine("===============================================================================\n");
                    mAssetChanged = false;
                }
            }
            /*  [NatNet] Disabling data handling function   */
            mNatNet.OnFrameReady -= fetchFrameData;

            mavSock.Close();
            stopwatch.Stop();

            /*  Clearing Saved Descriptions */
            mRigidBodies.Clear();
            mSkeletons.Clear();
            mHtSkelRBs.Clear();
            mForcePlates.Clear();
            mNatNet.Disconnect();
        }