private void Disconnect() { // Properly shut down the local variables in reverse order of precedence so that the ORiN engine is not left hanging TurnOffMotors(); try { Robot.Execute("GiveArm"); // Release the arm } catch (Exception ex) { ShowError("GiveArm", ex); } Robot.Variables.Clear(); // Clear all robot-specific variables from the main robot variable (THIS DOES NOT AFFECT VALUES ON THE PHYSICAL RC8 CONTROLLER) RobotBusyStatus = null; // Set the individual robot-specific variable to null RobotState = null; RobotExternalSpeed = null; RobotCurrentPosition = null; RobotCurrentAngle = null; RC8Controller.Robots.Clear(); // Clear all local robot variables from the controller variable Robot = null; // Set the individual robot variable to null RC8Controller.Variables.Clear(); // Clear all local variables from the controller variable (THIS DOES NOT AFFECT VALUES ON THE PHYSICAL RC8 CONTROLLER) CurrentErrorCode = null; // Set the individual local variables to null CurrentErrorDescription = null; RC8variable_S10 = null; ORiN_Engine.Workspaces.Item(0).Controllers.Remove(RC8Controller.Index); // Remove the controller variable from the ORiN engine RC8Controller = null; // Set the individual controller variable to null ORiN_Engine = null; // Set the ORiN engine variable to null }
public static string GetTString(CaoVariable pVar) { if (pVar.Value is double[]) { double[] pos = (double[])pVar.Value; StringBuilder sb = new StringBuilder(); sb.Append("T("); for (int i = 0; i < pos.Length; i++) { sb.Append(pos[i].ToString("0.00") + ","); } sb.Append(")"); return(sb.ToString()); } else if (pVar.Value is float[]) { float[] pos = (float[])pVar.Value; StringBuilder sb = new StringBuilder(); sb.Append("T("); for (int i = 0; i < pos.Length; i++) { sb.Append(pos[i].ToString("0.00") + ","); } sb.Append(")"); return(sb.ToString()); } return("Error"); }
public void SetObjectAng(CaoVariable pos, int axis = 1, double offsetA = 0) { double[] posData = (double[])pos.Value; posData[axis - 1] += offsetA; ObjectAngVar.Value = posData; }
private void InitVariables() { // Add local variables that are linked to corresponding variables on the physical RC8 controller // Add a variable linked to the robot connected to the RC8 controller Robot = RC8Controller.AddRobot("Arm"); // Add robot variables RobotBusyStatus = Robot.AddVariable("@BUSY_STATUS"); // Add a variable linked to the robot's busy status RobotState = Robot.AddVariable("@State"); // Add a variable which contains the current state of the robot RobotExternalSpeed = Robot.AddVariable("@Extspeed"); // Add a variable linked to the external (teach pendant) speed RobotCurrentPosition = Robot.AddVariable("@CURRENT_POSITION"); // Add a variable which contains the current robot position RobotCurrentAngle = Robot.AddVariable("@CURRENT_ANGLE"); // Add a variable which contains the current robot angle // Add variables that are linked to the current error code and description CurrentErrorCode = RC8Controller.AddVariable("@ERROR_CODE"); CurrentErrorDescription = RC8Controller.AddVariable("@ERROR_DESCRIPTION"); // Register to handle new message events from the controller // Every time the controller has a new message, the ShowMessage function will be called RC8Controller.OnMessage += new _ICaoControllerEvents_OnMessageEventHandler(ShowMessage); // Add a variable linked to string variable S10 RC8variable_S10 = RC8Controller.AddVariable("S10"); timer_InterfaceUpdate.Start(); // Start the GUI timer }
public static string GetJString(CaoVariable pVar) { if (pVar.Value is double[]) { var pos = (double[])pVar.Value; var sb = new StringBuilder(); sb.Append("J("); for (var i = 0; i < pos.Length; i++) { sb.Append(pos[i].ToString("0.00") + ","); } sb.Remove(sb.Length - 1, 1); sb.Append(")"); return(sb.ToString()); } if (pVar.Value is float[]) { var pos = (float[])pVar.Value; var sb = new StringBuilder(); sb.Append("J("); for (var i = 0; i < pos.Length; i++) { sb.Append(pos[i].ToString("0.00") + ","); } sb.Remove(sb.Length - 1, 1); sb.Append(")"); return(sb.ToString()); } return("Error"); }
public static string GetPosData(CaoVariable pVar) { var doubleVals = pVar.Value as double[]; if (doubleVals != null) { var pos = doubleVals; var sb = new StringBuilder(); for (var i = 0; i < 3; i++) { sb.Append(pos[i].ToString("0.00") + ","); } sb.Remove(sb.Length - 1, 1); return(sb.ToString()); } var floatVals = pVar.Value as float[]; if (floatVals != null) { var pos = floatVals; var sb = new StringBuilder(); for (var i = 0; i < 3; i++) { sb.Append(pos[i].ToString("0.00") + ","); } sb.Remove(sb.Length - 1, 1); return(sb.ToString()); } return("Error"); }
public void SetObjectPos(CaoVariable pos, int axis = 1, double offset = 0) { var posData = (double[])pos.Value; posData[axis - 1] += offset; ObjectPosVar.Value = posData; }
public void SetObjectPos(CaoVariable pos, double offsetX = 0, double offsetY = 0, double offsetZ = 0) { double[] posData = (double[])pos.Value; posData[0] += offsetX; posData[1] += offsetY; posData[2] += offsetZ; ObjectPosVar.Value = posData; }
public void Rotate(int mode, float degree) { CaoVariable cur = Robot.CurPosVar; double x = cur.Value[0]; double y = cur.Value[1]; double z = cur.Value[2]; Robot.Rotate(mode, degree, string.Format("V({0},{1},{2})", x, y, z)); }
public void Initialize() { TempPosVar99 = ControllerPointsPVars["P99"]; HomeJointVar = ControllerPointsJVars["J10"]; HomeJointVar.Value = new[] { 0, 0, 90, 0, 0, 0 }; ObjectPosVar = ControllerPointsPVars["P11"]; ObjectPosVar.Value = new[] { 0, 0, 0, 0, 0, 0, -1 }; ObjectAngVar = ControllerPointsJVars["J11"]; ObjectAngVar.Value = new[] { 0, 0, 0, 0, 0, 0 }; }
private void button_Close_Click(object sender, EventArgs e) { // Properly shut down the local variables in reverse order of precedence so that the ORiN engine is not left hanging RC8Controller.Variables.Clear(); // Clear all local variables from the controller variable (THIS DOES NOT AFFECT VALUES ON THE PHYSICAL RC8 CONTROLLER) RC8variable_S10 = null; // Set the individual local variables to null ORiN_Engine.Workspaces.Item(0).Controllers.Remove(RC8Controller.Index); // Remove the controller variable from the ORiN engine RC8Controller = null; // Set the individual controller variable to null ORiN_Engine = null; // Set the ORiN engine variable to null Close(); // Exit this C# program }
private void button_Connect_Click(object sender, EventArgs e) { button_Connect.Enabled = false; // Create a link to the RC8 controller via the engine (CAO.exe) RC8Controller = ORiN_Engine.Workspaces.Item(0).AddController( "", // This is the name of the connection to the RC8 controller; Pass an empty string to have the controller auto-generate a name "CaoProv.DENSO.RC8", // This is the name of the DENSO ORiN provider for RC8; It must be exactly as shown "localhost", // This is the name of the machine executing the DENSO ORiN provider (usually the machine running this program) "Server=192.168.0.1"); // This is the IP address of the physical RC8 controller // Add a local variable that is linked to string variable S10 on the physical RC8 controller RC8variable_S10 = RC8Controller.AddVariable("S10"); button_ReadVariable.Enabled = true; button_WriteVariable.Enabled = true; button_Close.Enabled = true; }
private void button_Connect_Click(object sender, EventArgs e) { button_Connect.Enabled = false; // Create a link to the RC7 controller via the engine (CAO.exe) RC7Controller = ORiN_Engine.Workspaces.Item(0).AddController( "Sample", // This is the name of the connection to the RC7 controller; Pass an empty string to have the controller auto-generate a name "CaoProv.DENSO.NetwoRC", // This is the name of the DENSO ORiN provider for RC7; It must be exactly as shown "", // This is the name of the machine executing the DENSO ORiN provider (usually the machine running this program) "Conn=eth:192.168.0.2"); // This is the IP address of the physical RC7 controller //In order to perform motion commands on the pc side you should start the RobSlave.pac program on the RC7 RC7Task_RobSlave = RC7Controller.AddTask("RobSlave", ""); RC7Task_RobSlave.Start(1, ""); // Add a local variable that is linked to string variable S10 on the physical RC7 controller RC7variable_S10 = RC7Controller.AddVariable("S10"); button_ReadVariable.Enabled = true; button_WriteVariable.Enabled = true; button_Close.Enabled = true; }