Example #1
0
        /// <summary>
        /// Ajoute une action du gripper
        /// </summary>
        /// <param name="processName">Nom du processus</param>
        /// <param name="action">Action de gripper</param>
        /// <param name="robot">Controller du robot</param>
        /// <returns>Indicateur de succès</returns>
        public static bool AddGripperAction(string processName, GripperAction.Action action, RobotController robot)
        {
            var process = new RobotProcess(processName);

            process.Commands.Add(new GripperAction()
            {
                Name    = action == GripperAction.Action.Open ? "Open gripper" : "Close gripper",
                Command = action
            });
            process.SaveProcess();
            try
            {
                robot.StopRelativeMovement();
                if (action == GripperAction.Action.Open)
                {
                    robot.OpenGripper();
                }
                else
                {
                    robot.CloseGripper();
                }
                robot.StartRelativeMovement();
                return(true);
            }
            catch (Exception ex)
            {
                return(false);
            }
        }
 public void Open_Gripper()
 {
     if (debug)
     {
         robot.OpenGripper();
     }
     else
     {
         Console.WriteLine("J'ouvre la pince");
     }
 }
Example #3
0
        /// <summary>
        /// Permet de démarrer l'éxécution d'un processus sur un robot
        /// </summary>
        /// <param name="robot">Robot éxécutant le processus</param>
        /// <param name="process">Processus à éxécuter</param>
        /// <returns>Indicateur de succès d'éxécution</returns>
        public static bool ExecuteProcess(RobotController robot, List <IRobotCommand> commands, Tray tray = null, LogManager log = null)
        {
            try
            {
                //Arrêt des mouvements relatifs du robot
                robot.StopRelativeMovement();
                // Parcours et éxécution des commandes
                foreach (var command in commands)
                {
                    if (command is Movement)
                    {
                        // Commande de mouvement
                        var mvt = command as Movement;
                        //Envoie de la liste de positions au robot
                        if (log != null)
                        {
                            log.AddLog("Info", string.Format("Movement start : {0} waypoints", mvt.Positions.Count()));
                        }
                        robot.PlayTrajectory(mvt.GetCartesianPositions());
                        if (log != null)
                        {
                            log.AddLog("Info", "Movement end");
                        }
                    }
                    else if (command is GripperAction)
                    {
                        // Commande d'action du gripper
                        var action = command as GripperAction;
                        if (action.Command == GripperAction.Action.Open)
                        {
                            //Ouverture pince
                            robot.OpenGripper();
                            if (log != null)
                            {
                                log.AddLog("Info", "Open gripper");
                            }
                        }
                        else if (action.Command == GripperAction.Action.Close)
                        {
                            //Fermeture pince
                            robot.CloseGripper();
                            if (log != null)
                            {
                                log.AddLog("Info", "Close gripper");
                            }
                        }
                    }
                    else if (command is TrayAction)
                    {
                        var action = command as TrayAction;

                        if (log != null)
                        {
                            log.AddLog("Info", action.Command == TrayAction.Action.Depose ? "Deposing item on Tray ..." : "Withdrawing item on Tray ...");
                        }

                        if (tray != null)
                        {
                            // Execution des commandes plateau
                            var commandsTray = tray.GetRobotCommand(action.Command == TrayAction.Action.Withdraw);
                            ExecuteProcess(robot, commandsTray, tray, log);
                        }
                        else
                        {
                            if (log != null)
                            {
                                log.AddLog("Error", "Tray not calibrated...");
                            }
                        }
                    }
                    else
                    {
                        //Commande inconnue
                        if (log != null)
                        {
                            log.AddLog("Error", "In ExecuteProcess(): Unknow command");
                        }
                        return(false);
                    }
                }
            }
            catch (Exception e)
            {
                if (log != null)
                {
                    log.AddLog("Error", "Exception throw in ExecuteProcess(): " + e.Data);
                }
                return(false);
            }
            return(true);
        }
        static void Main(string[] args)
        {
            RobotController Robot = new RobotController();
            Robot.Connect("192.168.1.1");
            Console.WriteLine("Robot connecté ... ");
            //        Console.WriteLine("Robot position : x:" + Robot.GetCurrentPosition().X + "; y:" + Robot.GetCurrentPosition().Y + "; z: " + Robot.GetCurrentPosition().Z);
            /*
            List<CartesianPosition> Trajectoire = new List<CartesianPosition>();
            for (int i = 1; i <= 100; i++)
            {
                Trajectoire.Add(new CartesianPosition
                {
                    X = i + Robot.GetCurrentPosition().X,
                    Y = i + Robot.GetCurrentPosition().Y,
                    Z = i + Robot.GetCurrentPosition().Z,
                    A = 0 + Robot.GetCurrentPosition().A,
                    B = 0 + Robot.GetCurrentPosition().B,
                    C = 0 + Robot.GetCurrentPosition().C
                });
            }
            //Robot.PlayTrajectory(Trajectoire);
            Robot.StartRelativeMovement();
            CartesianPosition Test = new CartesianPosition
            {
                X = -1,
                Y = 0,
                Z = 0,
                A = 0,
                B = 0,
                C = 0
            };
            Robot.SetRelativeMovement(Test);
            System.Threading.Thread.Sleep(2000);
            Robot.StopRelativeMovement();
             */
            Device Mouse = new Device();

            //-------------------------------------------------
            bool loop = true;
            while (loop)
            {
                Console.WriteLine("Type number and press Return");
                Console.WriteLine("press 2 pour ouvrir la pince");
                Console.WriteLine("press 3 pour fermer la pince");
                try
                {
                    int i = int.Parse(Console.ReadLine());
                    switch (i)
                    {
                        case 0:
                            {
                                for (int ii = 1; ii <= 20; ii++)
                                {
                                    bool pinceOuverte = Robot.IsGripperOpen();
                                    //bool pinceOuverte = true;
                                    Console.WriteLine("Pince ouverte : ");
                                    Console.WriteLine(pinceOuverte);
                                }
                                break;
                            }
                        case 1:
                            {
                                for (int ii = 1; ii <= 20; ii++)
                                {
                                    var valeurCapteur = Robot.ReadSensor();
                                    //int valeurCapteur = 12345;
                                    Console.WriteLine("Valeur du capteur : ");
                                    Console.WriteLine(valeurCapteur);
                                }
                                break;
                            }
                        case 2:
                            {
                                Console.WriteLine("Ouvrir la pince");
                                Robot.OpenGripper();
                                break;
                            }
                        case 3:
                            {
                                Console.WriteLine("Fermer la pince");
                                Robot.CloseGripper();
                                break;
                            }
                        default:
                            {
                                System.Console.WriteLine("Other number");
                                break;
                            }
                    }
                }
                catch
                {
                }
                System.Threading.Thread.Sleep(50);
            }
            //-------------------------------------------------
        }
        static void Main(string[] args)
        {
            RobotController Robot = new RobotController();

            Robot.Connect("192.168.1.1");
            Console.WriteLine("Robot connecté ... ");
            //        Console.WriteLine("Robot position : x:" + Robot.GetCurrentPosition().X + "; y:" + Robot.GetCurrentPosition().Y + "; z: " + Robot.GetCurrentPosition().Z);

            /*
             *      List<CartesianPosition> Trajectoire = new List<CartesianPosition>();
             *      for (int i = 1; i <= 100; i++)
             *      {
             *          Trajectoire.Add(new CartesianPosition
             *          {
             *              X = i + Robot.GetCurrentPosition().X,
             *              Y = i + Robot.GetCurrentPosition().Y,
             *              Z = i + Robot.GetCurrentPosition().Z,
             *              A = 0 + Robot.GetCurrentPosition().A,
             *              B = 0 + Robot.GetCurrentPosition().B,
             *              C = 0 + Robot.GetCurrentPosition().C
             *          });
             *      }
             *      //Robot.PlayTrajectory(Trajectoire);
             *      Robot.StartRelativeMovement();
             *      CartesianPosition Test = new CartesianPosition
             *      {
             *          X = -1,
             *          Y = 0,
             *          Z = 0,
             *          A = 0,
             *          B = 0,
             *          C = 0
             *      };
             *      Robot.SetRelativeMovement(Test);
             *      System.Threading.Thread.Sleep(2000);
             *      Robot.StopRelativeMovement();
             */
            Device Mouse = new Device();

            //-------------------------------------------------
            bool loop = true;

            while (loop)
            {
                Console.WriteLine("Type number and press Return");
                Console.WriteLine("press 2 pour ouvrir la pince");
                Console.WriteLine("press 3 pour fermer la pince");
                try
                {
                    int i = int.Parse(Console.ReadLine());
                    switch (i)
                    {
                    case 0:
                    {
                        for (int ii = 1; ii <= 20; ii++)
                        {
                            bool pinceOuverte = Robot.IsGripperOpen();
                            //bool pinceOuverte = true;
                            Console.WriteLine("Pince ouverte : ");
                            Console.WriteLine(pinceOuverte);
                        }
                        break;
                    }

                    case 1:
                    {
                        for (int ii = 1; ii <= 20; ii++)
                        {
                            var valeurCapteur = Robot.ReadSensor();
                            //int valeurCapteur = 12345;
                            Console.WriteLine("Valeur du capteur : ");
                            Console.WriteLine(valeurCapteur);
                        }
                        break;
                    }

                    case 2:
                    {
                        Console.WriteLine("Ouvrir la pince");
                        Robot.OpenGripper();
                        break;
                    }

                    case 3:
                    {
                        Console.WriteLine("Fermer la pince");
                        Robot.CloseGripper();
                        break;
                    }

                    default:
                    {
                        System.Console.WriteLine("Other number");
                        break;
                    }
                    }
                }
                catch
                {
                }
                System.Threading.Thread.Sleep(50);
            }
            //-------------------------------------------------
        }