public static void Main(string[] args) { if (args != null && args.Length > 0) { SERVER_IP = args[0]; Console.WriteLine("Using argument Specified IP of: " + SERVER_IP); } else { Console.WriteLine("Using default IP of: " + SERVER_IP); } Quit = false; InitBeagleBone(); SetupClient(); MotorControl.Initialize(); //MotorBoards.Initialize(CANBBB.CANBus0); int count = 0; Console.WriteLine("Finished the initalize"); do { Console.WriteLine("Looping"); SendSensorData(count); ProcessInstructions(); Thread.Sleep(50); count++; if (count == 101) { count = 0; } } while (!Quit); }
public static void Main(string[] args) { if (args.Length > 0) { if (args[0].Equals("turn")) { turnMode = true; } else if (args[0].Equals("line")) { lineMode = true; } } double SetTurn = 0; double PTurn = 1; double ITurn = 0; double DTurn = 0; double SetDis = 1; double PDis = 1; double IDis = 0; double DDis = 0; UdpClient udpServer = new UdpClient(9000); IPEndPoint remoteEP = new IPEndPoint(IPAddress.Any, 9000); /* * try * { // Open the text file using a stream reader. * using (StreamReader sr = new StreamReader("PIDValues.txt")) * { * // Read the stream to a string, and write the string to the console. * sr.ReadLine(); * sr.ReadLine(); // Ignore first two lines * SetTurn = Convert.ToDouble(sr.ReadLine()); * PTurn = Convert.ToDouble(sr.ReadLine()); * ITurn = Convert.ToDouble(sr.ReadLine()); * DTurn = Convert.ToDouble(sr.ReadLine()); * sr.ReadLine(); * SetDis = Convert.ToDouble(sr.ReadLine()); * PDis = Convert.ToDouble(sr.ReadLine()); * IDis = Convert.ToDouble(sr.ReadLine()); * DDis = Convert.ToDouble(sr.ReadLine()); * } * } * catch (Exception e) * { * Console.WriteLine("PIDValues.txt is either missing or in improper format:"); * Console.WriteLine(e.Message); * } */ PID directionPID = new PID(PTurn, ITurn, DTurn); directionPID.SetTarget(SetTurn); PID distancePID = new PID(PDis, IDis, DDis); directionPID.SetTarget(SetDis); Quit = false; InitBeagleBone(); //SetupClient(); MotorControl.Initialize(); MotorBoards.Initialize(CANBBB.CANBus0); int count = 0; do { //SendSensorData(count); //ProcessInstructions(); followTennisBall(udpServer, remoteEP, directionPID, distancePID); Thread.Sleep(50); count++; if (count == 101) { count = 0; } } while (!Quit); }