コード例 #1
0
        public static void setAngle(int roll, int pitch, int yaw, ref ControlCommandStructure cCmd)
        {
            byte[] byteRead             = new byte[100];
            RealtimeDataStructure rData = rtD;

            cCmd.setMode(MODE_ANGLE);
            cCmd.setAnglePitch(pitch);
            cCmd.setAngleRoll(roll);
            cCmd.setAngleYaw(yaw);

            //default 30
            cCmd.setSpeedPitch(30);
            cCmd.setSpeedRoll(30);
            cCmd.setSpeedYaw(30);

            if (sendCommand(CMD_CONTROL, cCmd.getControlStructure()))
            {
                Console.WriteLine("Done!");
                //호출을 한번 더 해줘야 함. 이유: 나중에 각도 읽어올때 쓰레기값 보냄
                if (sendCommand(CMD_REALTIME_DATA))
                {
                    System.Threading.Thread.Sleep(30);

                    port.Read(byteRead, 0, 100);
                    rData = parseRealTimeData(byteRead);

                    float[] angle = rData.getAngle();
                }
            }
            else
            {
                Console.WriteLine("Can't send command a message");
                return;
            }
        }
コード例 #2
0
ファイル: Program.cs プロジェクト: park53kr/SimpleBGC_CSharp
        public static void setAngle(int roll,int pitch,int yaw,ref ControlCommandStructure cCmd)
        {

            byte[] byteRead = new byte[100];
            RealtimeDataStructure rData = rtD;
            cCmd.setMode(MODE_ANGLE);
            cCmd.setAnglePitch(pitch);
            cCmd.setAngleRoll(roll);
            cCmd.setAngleYaw(yaw);

            //default 30 
            cCmd.setSpeedPitch(30);
            cCmd.setSpeedRoll(30);
            cCmd.setSpeedYaw(30);

            if (sendCommand(CMD_CONTROL, cCmd.getControlStructure()))
            {
                Console.WriteLine("Done!");
                //호출을 한번 더 해줘야 함. 이유: 나중에 각도 읽어올때 쓰레기값 보냄
                if (sendCommand(CMD_REALTIME_DATA))
                {
                    System.Threading.Thread.Sleep(30);

                    port.Read(byteRead, 0, 100);
                    rData = parseRealTimeData(byteRead);

                    float[] angle = rData.getAngle();

                }
            }
            else
            {
                Console.WriteLine("Can't send command a message");
                return;
            }
            
        }
コード例 #3
0
        static void Main(string[] args)
        {
            SerialProtocol          p     = new SerialProtocol();
            ControlCommandStructure cCmd  = new ControlCommandStructure();
            RealtimeDataStructure   rData = rtD;
            String select;

            byte[] byteRead = new byte[100];
            int    roll, pitch, yaw;

            while (true)
            {
                Console.WriteLine("Input what you want");
                Console.WriteLine("1. Check the gimbal angle");
                Console.WriteLine("2. Set the gimbal angle");
                Console.WriteLine("3. Exit");
                switch (select = Console.ReadLine())
                {
                case "1":
                    getAngle();
                    break;

                case "2":
                    Console.WriteLine("Give the angle value.");
                    roll  = Convert.ToInt32(Console.ReadLine());
                    pitch = Convert.ToInt32(Console.ReadLine());
                    yaw   = Convert.ToInt32(Console.ReadLine());
                    setAngle(roll, pitch, yaw, ref cCmd);
                    break;

                case "3":
                    return;

                    break;
                }
            }
        }
コード例 #4
0
ファイル: Program.cs プロジェクト: park53kr/SimpleBGC_CSharp
        static void Main(string[] args)
        {
            SerialProtocol p = new SerialProtocol();
            ControlCommandStructure cCmd = new ControlCommandStructure();
            RealtimeDataStructure rData = rtD;
            String select;
            byte[] byteRead = new byte[100];
            int roll, pitch, yaw;
  
            while (true)
            {
                Console.WriteLine("Input what you want");
                Console.WriteLine("1. Check the gimbal angle");
                Console.WriteLine("2. Set the gimbal angle");
                Console.WriteLine("3. Exit");
                switch (select=Console.ReadLine())
                {
                    case "1":
                        getAngle();
                        break;

                    case "2":
                    Console.WriteLine("Give the angle value.");
                    roll = Convert.ToInt32(Console.ReadLine());
                    pitch = Convert.ToInt32(Console.ReadLine());
                    yaw = Convert.ToInt32(Console.ReadLine());
                    setAngle(roll, pitch, yaw, ref cCmd);
                    break;

                    case "3":
                        return;
                        break;

                    


                }
            }
            

        }