/*static public int ArmCommandCallback(Comnet.Header header, Comnet.ABSPacket packet, Comnet.CommNode node)
         * {
         *  NGCP.ArmCommand ac = Comnet.ABSPacket.GetValue<NGCP.ArmCommand>(packet);
         *  //do some kind of switch case
         *  //@TODO ARM
         *  int servoPosition = ac.id;
         *  int servoValue = ac.position;
         *  //id_servo_GUI = ac.id;
         *  //val_servo_GUI = ac.position;
         *
         *
         *
         *  return (Int32)(Comnet.CallBackCodes.CALLBACK_SUCCESS | Comnet.CallBackCodes.CALLBACK_DESTROY_PACKET);
         *
         *
         * }*/


        static public int VehicleSystemStatusCallback(Comnet.Header header, Comnet.ABSPacket packet, Comnet.CommNode node)
        {
            NGCP.VehicleSystemStatus vss = Comnet.ABSPacket.GetValue <NGCP.VehicleSystemStatus>(packet);
            //State = (UGV.DriveState)vss.vehicle_state;
            //make sure you return this way to declare succes and destory the pointer(c++)
            return((Int32)(Comnet.CallBackCodes.CALLBACK_SUCCESS | Comnet.CallBackCodes.CALLBACK_DESTROY_PACKET));
        }
        public int SpeedSteeringCommandCallback(Comnet.Header header, Comnet.ABSPacket packet, Comnet.CommNode node)
        {
            NGCP.SpeedSteeringCommand ssc = Comnet.ABSPacket.GetValue <NGCP.SpeedSteeringCommand>(packet);

            Speed_Box.Text   = ((short)ssc.speed).ToString();
            Turning_Box.Text = ((short)ssc.steering * 27 / 1000).ToString();

            return((Int32)(Comnet.CallBackCodes.CALLBACK_SUCCESS | Comnet.CallBackCodes.CALLBACK_DESTROY_PACKET));
        }
Exemple #3
0
        static public int VehicleModeCommandCallback(Comnet.Header header, Comnet.ABSPacket packet, Comnet.CommNode node)
        {
            //validate who the packet is from 1 is gcs
            if (header.GetSourceID() == 1)
            {
                NGCP.VehicleModeCommand twc = Comnet.ABSPacket.GetValue <NGCP.VehicleModeCommand>(packet);
                //Settings.DriveMode = (DriveMode)twc.vehicle_mode;
            }

            //make sure you return this way to declare succes and destory the pointer(c++)
            return((Int32)(Comnet.CallBackCodes.CALLBACK_SUCCESS | Comnet.CallBackCodes.CALLBACK_DESTROY_PACKET));
        }
        public int VehicleGlobalPositionCallback(Comnet.Header header, Comnet.ABSPacket packet, Comnet.CommNode node)
        {
            //validate who the packet is from 1 is gcs
            if (header.GetSourceID() == 7)
            {
                NGCP.VehicleGlobalPosition vgp = Comnet.ABSPacket.GetValue <NGCP.VehicleGlobalPosition>(packet);
                GPS_X_Box.Text = vgp.latitude.ToString();
                GPS_Y_Box.Text = vgp.longitude.ToString();
            }

            //make sure you return this way to declare succes and destory the pointer(c++)
            return((Int32)(Comnet.CallBackCodes.CALLBACK_SUCCESS | Comnet.CallBackCodes.CALLBACK_DESTROY_PACKET));
        }
        ///<sumary>
        ///Commprotocol callbacks
        ///</sumary>
        static public int VehicleWaypointCommandCallback(Comnet.Header header, Comnet.ABSPacket packet, Comnet.CommNode node)
        {
            //validate who the packet is from 1 is gcs
            if (header.GetSourceID() == 1)
            {
                NGCP.VehicleWaypointCommand twc = Comnet.ABSPacket.GetValue <NGCP.VehicleWaypointCommand>(packet);
                //WayPoint commandWayPoint = new WayPoint(twc.latitude, twc.longitude, 1);

                //using a queue but want command waypoint in front :(
                //maybe want to switch this data type
                //Waypoints.Enqueue(commandWayPoint);
            }

            //make sure you return this way to declare succes and destory the pointer(c++)
            return((Int32)(Comnet.CallBackCodes.CALLBACK_SUCCESS | Comnet.CallBackCodes.CALLBACK_DESTROY_PACKET));
        }
Exemple #6
0
        static public int ArmCommandCallback(Comnet.Header header, Comnet.ABSPacket packet, Comnet.CommNode node)
        {
            NGCP.ArmCommand ac = Comnet.ABSPacket.GetValue <NGCP.ArmCommand>(packet);
            //do some kind of switch case
            //@TODO ARM
            int servoPosition = ac.id;
            int servoValue    = ac.position;

            Console.WriteLine("test armCommand");
            //id_servo_GUI = ac.id;
            //val_servo_GUI = ac.position;



            return((Int32)(Comnet.CallBackCodes.CALLBACK_SUCCESS | Comnet.CallBackCodes.CALLBACK_DESTROY_PACKET));
        }
        public int ArmCommandCallback(Comnet.Header header, Comnet.ABSPacket packet, Comnet.CommNode node)
        {
            NGCP.ArmCommand ac = Comnet.ABSPacket.GetValue <NGCP.ArmCommand>(packet);

            //do some kind of switch case
            //@TODO ARM
            int armServo   = ac.id;
            int servoValue = ac.position;

            //// this method
            switch (armServo)
            {
            case armY_id:     //Arm Stepper Y
                Arm_Y_Servo_Box.Text = (servoValue).ToString();
                break;

            case armX_id:     //Arm Stepper X
                Arm_X_Servo_Box.Text = (servoValue).ToString();
                break;

            case turretServo_id:     //Turret Servo
                Base_Servo_Box.Text = (servoValue).ToString();
                break;

            case gripper_id:     //Gripper
                if (servoValue == 1)
                {
                    Gripper_Servo_Box.Text = "Closed";
                }
                else
                {
                    Gripper_Servo_Box.Text = "Retracted";
                }
                break;

            default:
                // write to none of the servos, the id written was not recognized
                break;
            }
            return((Int32)(Comnet.CallBackCodes.CALLBACK_SUCCESS | Comnet.CallBackCodes.CALLBACK_DESTROY_PACKET));
        }
        public int VehicleModeCommandCallback(Comnet.Header header, Comnet.ABSPacket packet, Comnet.CommNode node)
        {
            //validate who the packet is from 1 is gcs
            if (header.GetSourceID() == 1)
            {
                NGCP.VehicleModeCommand twc = Comnet.ABSPacket.GetValue <NGCP.VehicleModeCommand>(packet);
                if ((DriveMode)twc.vehicle_mode == DriveMode.LocalControl)
                {
                    Drive_Type_Box.Text = "Local Mode";
                }
                else if ((DriveMode)twc.vehicle_mode == DriveMode.SemiAutonomous)
                {
                    Drive_Type_Box.Text = "Semi-Auto Mode";
                }
                else if ((DriveMode)twc.vehicle_mode == DriveMode.Autonomous)
                {
                    Drive_Type_Box.Text = "Auto Mode";
                }

                //Settings.DriveMode = (DriveMode)twc.vehicle_mode;
            }
            else if (header.GetSourceID() == 7)
            {
                NGCP.VehicleModeCommand vmc = Comnet.ABSPacket.GetValue <NGCP.VehicleModeCommand>(packet);
                if ((DriveMode)vmc.vehicle_mode == DriveMode.LocalControl)
                {
                    Drive_Type_Box.Text = "Local Mode";
                }
                else if ((DriveMode)vmc.vehicle_mode == DriveMode.SemiAutonomous)
                {
                    Drive_Type_Box.Text = "Semi-Auto Mode";
                }
                else if ((DriveMode)vmc.vehicle_mode == DriveMode.Autonomous)
                {
                    Drive_Type_Box.Text = "Auto Mode";
                }
            }

            //make sure you return this way to declare succes and destory the pointer(c++)
            return((Int32)(Comnet.CallBackCodes.CALLBACK_SUCCESS | Comnet.CallBackCodes.CALLBACK_DESTROY_PACKET));
        }