public void fctPlay(NLX.Robot.Kuka.Controller.RobotController rob)
        {
            if (listPos.Count() != 0)
            {
                // play the list, then empty it
                rob.PlayTrajectory(listPos);

                listPos.Clear();

            }
        }
Пример #2
0
        public void changeLocation(NLX.Robot.Kuka.Controller.CartesianPosition currentMouvement)
        {
            lastMouvement.A = currentMouvement.A;
            lastMouvement.B = currentMouvement.B;
            lastMouvement.C = currentMouvement.C;
            lastMouvement.X = currentMouvement.X;
            lastMouvement.Y = currentMouvement.Y;
            lastMouvement.Z = currentMouvement.Z;

            NLX.Robot.Kuka.Controller.CartesianPosition posRelRobot = new NLX.Robot.Kuka.Controller.CartesianPosition();

            posRelRobot.A = lastMouvement.A * Program.robot.getRotSpeed(); // B
            posRelRobot.B = lastMouvement.C * Program.robot.getRotSpeed(); // C
            posRelRobot.C = lastMouvement.B * Program.robot.getRotSpeed(); // A
            posRelRobot.X = -lastMouvement.Z * Program.robot.getSpeed();
            posRelRobot.Y = -lastMouvement.X * Program.robot.getSpeed();
            posRelRobot.Z = lastMouvement.Y * Program.robot.getSpeed();
            //Console.WriteLine("[" + posRelRobot.A + ":" + posRelRobot.B + ":" + posRelRobot.C + "]   [" + posRelRobot.X + ":" + posRelRobot.Y + ":" + posRelRobot.Z + "]");
            Program.robot.translateRelative(posRelRobot);
        }
 public void setLocation(NLX.Robot.Kuka.Controller.CartesianPosition val)
 {
     this.location = val;
 }
Пример #4
0
 public void setRobotInfo(bool actif, float speed, float rotSpeed, NLX.Robot.Kuka.Controller.CartesianPosition location)
 {
     this.createIHM.setRobotInfo(actif, speed, rotSpeed, location);
 }
        public void readAndInterpretFile2(string path, NLX.Robot.Kuka.Controller.RobotController robot)
        {
            Console.WriteLine("in readAndInterpretFile2");
            Console.WriteLine("path: " + path);

            int nbLignesPalette = 4;
            int nbColonnesPalette = 4;

            parseFile(path);

            double xdecx = point1.X - point2.X;
            double ydecx = point1.Y - point2.Y;

            double xdecy = point1.X - point3.X;
            double ydecy = point1.Y - point3.Y;

            Console.WriteLine("xdecx: " + xdecx);
            Console.WriteLine("ydecx: " + ydecx);
            Console.WriteLine("xdecy: " + xdecy);
            Console.WriteLine("ydecy: " + ydecy);

            try
            {

                //for (int ligne = 0; ligne <= nbLignesPalette; ligne++)
                for (int colonne = 0; colonne <= nbColonnesPalette; colonne++)
                {
                    for (int ligne = 0; ligne <= nbLignesPalette; ligne++)
                    //for (int colonne = 0; colonne <= nbColonnesPalette; colonne++)
                    {
                        Console.WriteLine("ligne: " + ligne + ",colonne: " + colonne);

                        if (File.Exists(path))
                        {
                            using (StreamReader sr = new StreamReader(path))
                            {

                                double d;
                                //new List<NLX.Robot.Kuka.Controller.CartesianPosition>();
                                listPos = new List<NLX.Robot.Kuka.Controller.CartesianPosition>();

                                while (sr.Peek() >= 0)
                                {
                                    string str = sr.ReadLine();

                                    if (Double.TryParse(str, out d))
                                    {
                                        //

                                        NLX.Robot.Kuka.Controller.CartesianPosition cpos = new NLX.Robot.Kuka.Controller.CartesianPosition();

                                        Console.WriteLine("x: " + d);
                                        cpos.X = d;

                                        str = sr.ReadLine();
                                        Double.TryParse(str, out d);
                                        Console.WriteLine("y: " + d);
                                        cpos.Y = d;

                                        str = sr.ReadLine();
                                        Double.TryParse(str, out d);
                                        Console.WriteLine("z: " + d);
                                        cpos.Z = d;

                                        str = sr.ReadLine();
                                        Double.TryParse(str, out d);
                                        Console.WriteLine("a: " + d);
                                        cpos.A = d;

                                        str = sr.ReadLine();
                                        Double.TryParse(str, out d);
                                        Console.WriteLine("b: " + d);
                                        cpos.B = d;

                                        str = sr.ReadLine();
                                        Double.TryParse(str, out d);
                                        Console.WriteLine("c: " + d);
                                        cpos.C = d;

                                        str = sr.ReadLine();
                                        Console.WriteLine(str);

                                        Console.WriteLine("robot: " + robot);
                                        Console.WriteLine("listPos: " + listPos);

                                        listPos.Add(robot.GetCurrentPosition());

                                        // add cpos to the listPos
                                        listPos.Add(cpos);

                                        fctPlay(robot);

                                    }
                                    else
                                    {
                                        // play the list of positions if it's not empty
                                        Console.WriteLine("rob: " + robot);
                                        Console.WriteLine("listpos: " + listPos);

                                        fctPlay(robot);

                                        if (str == "open")
                                        {
                                            // do the open
                                            Console.WriteLine("doing open gripper");
                                            robot.OpenGripper();

                                        }
                                        else if (str == "close")
                                        {
                                            Thread.Sleep(1000);

                                            // do the close
                                            Console.WriteLine("doing close gripper");
                                            robot.CloseGripper();

                                        }
                                        else if (str == "p0")
                                        {
                                            NLX.Robot.Kuka.Controller.CartesianPosition cpos = new NLX.Robot.Kuka.Controller.CartesianPosition();

                                            str = sr.ReadLine();
                                            Console.WriteLine("str: " + str);
                                            Double.TryParse(str, out d);
                                            //cpos.X = d + ligne*xdecy + colonne*xdecy;
                                            Console.WriteLine("ligne: " + ligne);
                                            Console.WriteLine("colonne: " + colonne);
                                            cpos.X = d + (-1)*ligne*xdecx + (-1)*colonne*xdecy;

                                            str = sr.ReadLine();
                                            Double.TryParse(str, out d);
                                            //cpos.Y = d + ligne*ydecx + colonne*ydecy;
                                            cpos.Y = d + (-1)*ligne*ydecx + (-1)*colonne*ydecy;

                                            str = sr.ReadLine();
                                            Double.TryParse(str, out d);
                                            cpos.Z = d;

                                            str = sr.ReadLine();
                                            Double.TryParse(str, out d);
                                            cpos.A = d;

                                            str = sr.ReadLine();
                                            Double.TryParse(str, out d);
                                            cpos.B = d;

                                            str = sr.ReadLine();
                                            Double.TryParse(str, out d);
                                            cpos.C = d;

                                            str = sr.ReadLine();

                                            listPos.Add(robot.GetCurrentPosition());

                                            // add cpos to the listPos
                                            listPos.Add(cpos);

                                            fctPlay(robot);

                                        }
                                        else if (str == "p1")
                                        {
                                            NLX.Robot.Kuka.Controller.CartesianPosition cpos = new NLX.Robot.Kuka.Controller.CartesianPosition();

                                            str = sr.ReadLine();
                                            Double.TryParse(str, out d);
                                            //cpos.X = d + ligne * xdecx + colonne * xdecy;
                                            cpos.X = d + (-1) * ligne * xdecx + (-1) * colonne * xdecy;

                                            str = sr.ReadLine();
                                            Double.TryParse(str, out d);
                                            //cpos.Y = d + ligne * ydecx + colonne * ydecy;
                                            cpos.Y = d + (-1) * ligne * ydecx + (-1) * colonne * ydecy;

                                            str = sr.ReadLine();
                                            Double.TryParse(str, out d);
                                            cpos.Z = d;

                                            str = sr.ReadLine();
                                            Double.TryParse(str, out d);
                                            cpos.A = d;

                                            str = sr.ReadLine();
                                            Double.TryParse(str, out d);
                                            cpos.B = d;

                                            str = sr.ReadLine();
                                            Double.TryParse(str, out d);
                                            cpos.C = d;

                                            str = sr.ReadLine();

                                            listPos.Add(robot.GetCurrentPosition());

                                            // add cpos to the listPos
                                            listPos.Add(cpos);

                                            fctPlay(robot);

                                        }
                                        else if (str == "p2")
                                        {
                                            NLX.Robot.Kuka.Controller.CartesianPosition cpos = new NLX.Robot.Kuka.Controller.CartesianPosition();

                                            str = sr.ReadLine();
                                            Double.TryParse(str, out d);
                                            cpos.X = d;

                                            str = sr.ReadLine();
                                            Double.TryParse(str, out d);
                                            cpos.Y = d;

                                            str = sr.ReadLine();
                                            Double.TryParse(str, out d);
                                            cpos.Z = d;

                                            str = sr.ReadLine();
                                            Double.TryParse(str, out d);
                                            cpos.A = d;

                                            str = sr.ReadLine();
                                            Double.TryParse(str, out d);
                                            cpos.B = d;

                                            str = sr.ReadLine();
                                            Double.TryParse(str, out d);
                                            cpos.C = d;

                                            str = sr.ReadLine();

                                        }
                                        else if (str == "p3")
                                        {
                                            NLX.Robot.Kuka.Controller.CartesianPosition cpos = new NLX.Robot.Kuka.Controller.CartesianPosition();

                                            str = sr.ReadLine();
                                            Double.TryParse(str, out d);
                                            cpos.X = d;

                                            str = sr.ReadLine();
                                            Double.TryParse(str, out d);
                                            cpos.Y = d;

                                            str = sr.ReadLine();
                                            Double.TryParse(str, out d);
                                            cpos.Z = d;

                                            str = sr.ReadLine();
                                            Double.TryParse(str, out d);
                                            cpos.A = d;

                                            str = sr.ReadLine();
                                            Double.TryParse(str, out d);
                                            cpos.B = d;

                                            str = sr.ReadLine();
                                            Double.TryParse(str, out d);
                                            cpos.C = d;

                                            str = sr.ReadLine();

                                        }
                                    }

                                }

                                fctPlay(robot);
                            }

                        }
                        else
                        {
                            Console.WriteLine("it doesn't exist");
                        }
                    }
                }

                Console.WriteLine("in readAndInterpretFile");
                Console.WriteLine("path: " + path);

                listPos = new List<NLX.Robot.Kuka.Controller.CartesianPosition>();

            }
            catch (Exception e)
            {
                Console.WriteLine("The process failed: {0}", e.ToString());
            }
        }
        public void readAndInterpretFile(string path, NLX.Robot.Kuka.Controller.RobotController robot)
        {
            Console.WriteLine("in readAndInterpretFile");
            Console.WriteLine("path: " + path);

            listPos = new List<NLX.Robot.Kuka.Controller.CartesianPosition>();

            try
            {
                if (File.Exists(path))
                {
                    using (StreamReader sr = new StreamReader(path))
                    {

                        double d;
                            new List<NLX.Robot.Kuka.Controller.CartesianPosition>();

                        while (sr.Peek() >= 0)
                        {
                            string str = sr.ReadLine();

                            if (Double.TryParse(str, out d))
                            {
                                //

                                NLX.Robot.Kuka.Controller.CartesianPosition cpos = new NLX.Robot.Kuka.Controller.CartesianPosition();

                                Console.WriteLine("x: " + d);
                                cpos.X = d;

                                str = sr.ReadLine();
                                Double.TryParse(str, out d);
                                Console.WriteLine("y: " + d);
                                cpos.Y = d;

                                str = sr.ReadLine();
                                Double.TryParse(str, out d);
                                Console.WriteLine("z: " + d);
                                cpos.Z = d;

                                str = sr.ReadLine();
                                Double.TryParse(str, out d);
                                Console.WriteLine("a: " + d);
                                cpos.A = d;

                                str = sr.ReadLine();
                                Double.TryParse(str, out d);
                                Console.WriteLine("b: " + d);
                                cpos.B = d;

                                str = sr.ReadLine();
                                Double.TryParse(str, out d);
                                Console.WriteLine("c: " + d);
                                cpos.C = d;

                                str = sr.ReadLine();
                                Console.WriteLine(str);

                                listPos.Add( robot.GetCurrentPosition() );

                                // add cpos to the listPos
                                listPos.Add(cpos);

                                fctPlay(robot);

                            }
                            else
                            {
                                // play the list of positions if it's not empty
                                Console.WriteLine("rob: " + robot);
                                Console.WriteLine("listpos: " + listPos);

                                fctPlay(robot);

                                if (str == "open")
                                {
                                    // do the open
                                    Console.WriteLine("doing open gripper");
                                    robot.OpenGripper();

                                }
                                else if (str == "close")
                                {
                                    Thread.Sleep(1000);

                                    // do the close
                                    Console.WriteLine("doing close gripper");
                                    robot.CloseGripper();

                                }
                            }

                        }

                        fctPlay(robot);
                    }

                }
                else
                {
                    Console.WriteLine("it doesn't exist");
                }
            }
            catch (Exception e)
            {
                Console.WriteLine("The process failed: {0}", e.ToString());
            }
        }
Пример #7
0
 public Dictionary<String, Double> transformCartPointToDict(NLX.Robot.Kuka.Controller.CartesianPosition location)
 {
     Dictionary<String, Double> pDict = new Dictionary<String, Double>();
     pDict.Add("X", location.X);
     pDict.Add("Y", location.Y);
     pDict.Add("Z", location.Z);
     pDict.Add("A", location.A);
     pDict.Add("B", location.B);
     pDict.Add("C", location.C);
     return pDict;
 }