public static void TaskStartExample() { Console.WriteLine("send_file0: " + HRobot.send_file(device_id, "../../../code0.hrb", "code0.hrb")); Thread.Sleep(500); Console.WriteLine("send_file1: " + HRobot.send_file(device_id, "../../../code1.hrb", "code1.hrb")); Thread.Sleep(500); Console.WriteLine("send_file2: " + HRobot.send_file(device_id, "../../../code2.hrb", "code2.hrb")); Thread.Sleep(500); Console.WriteLine("send_file3: " + HRobot.send_file(device_id, "../../../code3.hrb", "code3.hrb")); Thread.Sleep(500); double[] pos = new double[6]; HRobot.get_current_position(device_id, pos); // run callback. while (true) { if (!is_Run) { switch (x % 4) { case 0: HRobot.task_start(device_id, "code0.hrb"); break; case 1: HRobot.task_start(device_id, "code1.hrb"); break; case 2: HRobot.task_start(device_id, "code2.hrb"); break; case 3: HRobot.task_start(device_id, "code3.hrb"); break; } Console.WriteLine("run code{0}.hrb", x % 4); is_Run = true; } Thread.Sleep(4000); } }
// If you want to get the network information, you does have this function. // The received parameter is set to the value of the counter. public static void run_notify(object device_id) { int id = ( int )device_id; Console.WriteLine("Strat Notify. "); double[] pos = new double[6]; HRobot.get_current_position(id, pos); while (true) { HRobot.network_get_state(id); if (is_received) { for (int i = 1; i <= recv_val.Count; i++) { if (Int32.TryParse(recv_val[i - 1], out int tmp)) { HRobot.set_counter(id, i, tmp); } } is_received = false; } Thread.Sleep(200); } }
public static void SoftLimitExample(int device_id) { double[] joint_low_limit = { -20, -20, -35, -20, 0, 0 }; double[] joint_high_limit = { 20, 20, 0, 0, 0, 0 }; double[] cart_low_limit = { -100, 300, -100, 0, 0, 0 }; double[] cart_high_limit = { 100, 450, -25, 0, 0, 0 }; double[] cart_home = { 0, 400, 0, 0, -90, 0 }; double[] joint_home = { 0, 0, 0, 0, -90, 0 }; double[] now_pos = { 0, 0, 0, 0, 0, 0 }; bool re_bool = false; HRobot.get_current_position(device_id, now_pos); // run joint softlimit HRobot.set_override_ratio(device_id, 100); HRobot.set_joint_soft_limit(device_id, joint_low_limit, joint_high_limit); HRobot.enable_joint_soft_limit(device_id, true); HRobot.enable_cart_soft_limit(device_id, false); HRobot.get_joint_soft_limit_config(device_id, ref re_bool, joint_low_limit, joint_high_limit); Console.WriteLine("Enable Joint SoftLimit: " + re_bool); HRobot.jog_home(device_id); wait_for_stop(device_id); Thread.Sleep(1000); for (int i = 0; i < 4; i++) { HRobot.jog(device_id, 1, i, -1); wait_for_stop(device_id); Console.WriteLine("On the limits of SoftLimit"); } for (int i = 0; i < 4; i++) { HRobot.jog(device_id, 1, i, 1); wait_for_stop(device_id); Console.WriteLine("On the limits of SoftLimit"); } HRobot.enable_joint_soft_limit(device_id, false); // run cartesian softlimit HRobot.ptp_axis(device_id, 0, joint_home); wait_for_stop(device_id); HRobot.set_cart_soft_limit(device_id, cart_low_limit, cart_high_limit); HRobot.enable_cart_soft_limit(device_id, true); HRobot.get_cart_soft_limit_config(device_id, ref re_bool, cart_low_limit, cart_high_limit); Console.WriteLine("Enable Cart SoftLimit: " + re_bool); HRobot.lin_pos(device_id, 0, 0, cart_home); wait_for_stop(device_id); for (int i = 0; i < 3; i++) { HRobot.jog(device_id, 0, i, -1); wait_for_stop(device_id); Console.WriteLine("On the limits of SoftLimit"); Console.WriteLine(""); HRobot.clear_alarm(device_id); Thread.Sleep(2000); } for (int i = 0; i < 3; i++) { HRobot.jog(device_id, 0, i, 1); wait_for_stop(device_id); Console.WriteLine("On the limits of SoftLimit"); Console.WriteLine(""); HRobot.clear_alarm(device_id); Thread.Sleep(2000); } Console.WriteLine("End of motion"); HRobot.enable_joint_soft_limit(device_id, false); HRobot.enable_cart_soft_limit(device_id, false); }