public void fctPlay(NLX.Robot.Kuka.Controller.RobotController rob) { if (listPos.Count() != 0) { // play the list, then empty it rob.PlayTrajectory(listPos); listPos.Clear(); } }
static void Main(string[] args) { started = false; Program prog = new Program(); Console.WriteLine("Start of programm...."); coeffTrans = 1.0; coeffRot = 0.4; Thread myThreadKeyboard; myThreadKeyboard = new Thread(new ThreadStart(KeyboardThreadLoop)); myThreadKeyboard.Start(); device = new TDx.TDxInput.Device(); //keyboard = new TDx.TDxInput.Keyboard(); var keyboard = device.Keyboard; Console.WriteLine(device.Sensor); Console.WriteLine(device.Sensor.Translation); //System.Threading.Thread.Sleep(2500); //translation = device.Sensor.Translation; //rotation = device.Sensor.Rotation; Console.WriteLine(device.IsConnected); device.Connect(); Console.WriteLine(device.IsConnected); //System.Threading.Thread.Sleep(2500); // la souris est connecte /*Console.WriteLine("nombre de touches : "); Console.WriteLine(keyboard.Keys); Console.WriteLine("nombre de touches programmable : "); Console.WriteLine(keyboard.ProgrammableKeys);*/ //keyboard.KeyDown += new System.EventHandler(prog.onKeyDown); //double xMax = 0, yMax = 0, zMax = 0; theRobot = new NLX.Robot.Kuka.Controller.RobotController(); theRobot.Connect("192.168.1.1"); Console.WriteLine("Connection avec le robot OK !"); sh = new ScenarioHandler(); //sh.readAndInterpretFile(@"C:\Users\IMERIR14\Desktop\Novalinxproject\trunk\darkproject\scenario.sck", theRobot); Console.WriteLine("File interpretation finished"); Console.WriteLine("On entre dans le while sleep"); while (true) { System.Threading.Thread.Sleep(100); } }
static void Main(string[] args) { /* Declaration des variables */ double x_Min = 0; double y_Min = 0; double z_Min = 0; double x_Max = 0; double y_Max = 0; double z_Max = 0; double valeurX; double valeurY; double valeurZ; Console.WriteLine("Start..."); device = new TDx.TDxInput.Device(); device.Connect(); robotController = new NLX.Robot.Kuka.Controller.RobotController(); //robotController.Connect("192.168.1.1"); ConsoleKeyInfo info; String bouton = device.Keyboard.GetKeyName(1); Console.WriteLine(bouton); bouton = device.Keyboard.GetKeyName(2); Console.WriteLine(bouton); bouton = device.Keyboard.GetKeyName(3); Console.WriteLine(bouton); bouton = device.Keyboard.GetKeyName(4); Console.WriteLine(bouton); bouton = device.Keyboard.GetKeyName(5); Console.WriteLine(bouton); bouton = device.Keyboard.GetKeyName(6); Console.WriteLine(bouton); bouton = device.Keyboard.GetKeyName(7); Console.WriteLine(bouton); bouton = device.Keyboard.GetKeyName(8); Console.WriteLine(bouton); bouton = device.Keyboard.GetKeyName(9); Console.WriteLine(bouton); bouton = device.Keyboard.GetKeyName(10); Console.WriteLine(bouton); bouton = device.Keyboard.GetKeyName(11); Console.WriteLine(bouton); bouton = device.Keyboard.GetKeyName(12); Console.WriteLine(bouton); bouton = device.Keyboard.GetKeyName(13); Console.WriteLine(bouton); bouton = device.Keyboard.GetKeyName(14); Console.WriteLine(bouton); bouton = device.Keyboard.GetKeyName(15); Console.WriteLine(bouton); while (true) { var translation = device.Sensor.Translation; var rotation = device.Sensor.Rotation; /* Affichage des translations et des rotations */ //Console.WriteLine("Translation: " + translation.X + " : " + translation.Y + " : " + translation.Z); //Console.WriteLine("Rotation: " + rotation.X + " : " + rotation.Y + " : " + rotation.Z + "\n"); valeurX = translation.X / 2353; valeurY = translation.Y / 2702; valeurZ = translation.Z / 2648; System.Threading.Thread.Sleep(200); } }
static void Main(string[] args) { started = false; Program prog = new Program(); Console.WriteLine("Start of programm...."); coeffTrans = 1.0; coeffRot = 0.4; Thread myThreadKeyboard; myThreadKeyboard = new Thread(new ThreadStart(KeyboardThreadLoop)); myThreadKeyboard.Start(); device = new TDx.TDxInput.Device(); //keyboard = new TDx.TDxInput.Keyboard(); var keyboard = device.Keyboard; Console.WriteLine(device.Sensor); Console.WriteLine(device.Sensor.Translation); //System.Threading.Thread.Sleep(2500); //translation = device.Sensor.Translation; //rotation = device.Sensor.Rotation; Console.WriteLine(device.IsConnected); device.Connect(); Console.WriteLine(device.IsConnected); //System.Threading.Thread.Sleep(2500); // la souris est connecte /*Console.WriteLine("nombre de touches : "); * Console.WriteLine(keyboard.Keys); * * Console.WriteLine("nombre de touches programmable : "); * Console.WriteLine(keyboard.ProgrammableKeys);*/ //keyboard.KeyDown += new System.EventHandler(prog.onKeyDown); //double xMax = 0, yMax = 0, zMax = 0; theRobot = new NLX.Robot.Kuka.Controller.RobotController(); theRobot.Connect("192.168.1.1"); Console.WriteLine("Connection avec le robot OK !"); sh = new ScenarioHandler(); //sh.readAndInterpretFile(@"C:\Users\IMERIR14\Desktop\Novalinxproject\trunk\darkproject\scenario.sck", theRobot); Console.WriteLine("File interpretation finished"); Console.WriteLine("On entre dans le while sleep"); while (true) { System.Threading.Thread.Sleep(100); } }
static void Main(string[] args) { /* Declaration des variables */ double x_Min = 0; double y_Min = 0; double z_Min = 0; double x_Max = 0; double y_Max = 0; double z_Max = 0; double valeurX; double valeurY; double valeurZ; Console.WriteLine("Start..."); device = new TDx.TDxInput.Device(); device.Connect(); robotController = new NLX.Robot.Kuka.Controller.RobotController(); //robotController.Connect("192.168.1.1"); ConsoleKeyInfo info; String bouton = device.Keyboard.GetKeyName(1); Console.WriteLine(bouton); bouton = device.Keyboard.GetKeyName(2); Console.WriteLine(bouton); bouton = device.Keyboard.GetKeyName(3); Console.WriteLine(bouton); bouton = device.Keyboard.GetKeyName(4); Console.WriteLine(bouton); bouton = device.Keyboard.GetKeyName(5); Console.WriteLine(bouton); bouton = device.Keyboard.GetKeyName(6); Console.WriteLine(bouton); bouton = device.Keyboard.GetKeyName(7); Console.WriteLine(bouton); bouton = device.Keyboard.GetKeyName(8); Console.WriteLine(bouton); bouton = device.Keyboard.GetKeyName(9); Console.WriteLine(bouton); bouton = device.Keyboard.GetKeyName(10); Console.WriteLine(bouton); bouton = device.Keyboard.GetKeyName(11); Console.WriteLine(bouton); bouton = device.Keyboard.GetKeyName(12); Console.WriteLine(bouton); bouton = device.Keyboard.GetKeyName(13); Console.WriteLine(bouton); bouton = device.Keyboard.GetKeyName(14); Console.WriteLine(bouton); bouton = device.Keyboard.GetKeyName(15); Console.WriteLine(bouton); while (true) { var translation = device.Sensor.Translation; var rotation = device.Sensor.Rotation; /* Affichage des translations et des rotations */ //Console.WriteLine("Translation: " + translation.X + " : " + translation.Y + " : " + translation.Z); //Console.WriteLine("Rotation: " + rotation.X + " : " + rotation.Y + " : " + rotation.Z + "\n"); valeurX = translation.X / 2353; valeurY = translation.Y / 2702; valeurZ = translation.Z / 2648; System.Threading.Thread.Sleep(200); } }
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()); } }