Пример #1
0
            public override String to_script(bRobotBrand type, bool cont)
            {
                string cmd;
                switch (type)
                {
                    case (bRobotBrand.UNKNOWN):
                        return "Unknown robot model";

                    // URSCRIPT
                    case (bRobotBrand.UR):
                        Types.UR.AxisAngle aa = new Types.UR.AxisAngle(Rhino.Geometry.Transform.PlaneToPlane(Plane.WorldXY, this.waypoint));
                        if (this.axis)
                        {
                            cmd = String.Format("movep([{0:0.000}, {1:0.000}, {2:0.000}, {3:0.000}, {4:0.000}, {5:0.000}], a={6:0.000}, v={7:0.000}",
                                    this.q[0], this.q[1], this.q[2],
                                    this.q[3], this.q[4], this.q[5],
                                    this.qdd, this.qd);
                        }
                        else
                        {
                            cmd = String.Format("movep(p[{0:0.000}, {1:0.000}, {2:0.000}, {3:0.000}, {4:0.000}, {5:0.000}], a={6:0.000}, v={7:0.000}",
                                    this.waypoint.Origin.X * 0.001, this.waypoint.Origin.Y * 0.001, this.waypoint.Origin.Z * 0.001,
                                    aa.x * aa.angle, aa.y * aa.angle, aa.z * aa.angle,
                                    this.qdd, this.qd);
                        }

                        if (r > 0.0001)
                            cmd += String.Format(", r={0:0.0000}", r * 0.001);
                        cmd += ")\n";
                        return cmd;

                    // KUKA KRL
                    case (bRobotBrand.KUKA):
                        Types.KUKA.kukaABC k1 = new Types.KUKA.kukaABC(Rhino.Geometry.Transform.PlaneToPlane(Plane.WorldXY, this.waypoint));
                        cmd = "SPL {" + String.Format("X {0:0.0000}, Y {1:0.0000}, Z {2:0.0000}, A {3:0.0000}, B {4:0.0000}, C {5:0.0000},",
                            k1.x, k1.y, k1.z, k1.a, k1.b, k1.c)
                            + "E1 0, E2 0, E3 0, E4 0, E5 0, E6 0}";
                        if (cont)
                            cmd += "\n";
                        //cmd += " C_VEL\n";
                        else
                            cmd += "\n";
                        return cmd;

                    // ABB RAPID
                    case (bRobotBrand.ABB):
                        Quaternion quat;
                        break;

                }
                return "circular move";
            }
Пример #2
0
            public override String to_script(bRobotBrand type, bool cont)
            {
                string cmd;
                switch (type)
                {
                    case (bRobotBrand.UNKNOWN):
                        return "Unknown robot model";
                    case (bRobotBrand.UR):
                        Types.UR.AxisAngle aa = new Types.UR.AxisAngle(Rhino.Geometry.Transform.PlaneToPlane(Plane.WorldXY, this.waypoint));
                        if (this.axis)
                        {
                            cmd = String.Format("movej([{0:0.0000}, {1:0.0000}, {2:0.0000}, {3:0.0000}, {4:0.0000}, {5:0.0000}], a={6:0.0000}, v={7:0.0000}",
                                this.q[0], this.q[1], this.q[2],
                                this.q[3], this.q[4], this.q[5],
                                this.qdd, this.qd);
                        }
                        else
                        {
                            cmd = String.Format("movej(p[{0:0.0000}, {1:0.0000}, {2:0.0000}, {3:0.0000}, {4:0.0000}, {5:0.0000}], a={6:0.0000}, v={7:0.0000}",
                                this.waypoint.Origin.X * 0.001, this.waypoint.Origin.Y * 0.001, this.waypoint.Origin.Z * 0.001,
                                aa.x * aa.angle, aa.y * aa.angle, aa.z * aa.angle,
                                this.qdd, this.qd);

                        }
                        if (r > 0.0001)
                            cmd += String.Format(", r = {0:0.0000}", r * 0.001);
                        cmd += ")\n";
                        return cmd;

                    case (bRobotBrand.KUKA):
                        Types.KUKA.kukaABC k = new Types.KUKA.kukaABC(Rhino.Geometry.Transform.PlaneToPlane(Plane.WorldXY, this.waypoint));
                        //cmd = "PTP {" + String.Format("X {0:0.0000}, Y {1:0.0000}, Z {2:0.0000}, A {3:0.0000}, B {4:0.0000}, C {5:0.0000},",
                        //k.x, k.y, k.z, k.a, k.b, k.c)
                        //+ String.Format("E1 0, E2 0, E3 0, E4 0, E5 0, E6 0, S {0}, T {1}", k.s, k.t) + "}";
                        cmd = "PTP {" + String.Format("X {0:0.0000}, Y {1:0.0000}, Z {2:0.0000}, A {3:0.0000}, B {4:0.0000}, C {5:0.0000},",
                            k.x, k.y, k.z, k.a, k.b, k.c)
                            +
                            "E1 0, E2 0, E3 0, E4 0, E5 0, E6 0 }";
                        if (cont)
                            cmd += "\n";
                        //cmd += " C_PTP\n";
                        else
                            cmd += "\n";
                        return cmd;
                    case (bRobotBrand.ABB):
                        break;

                }
                return "joint move";
            }
Пример #3
0
            public override int Write()
            {
                if (this.Robot.Type() != bRobotBrand.UR)
                {
                    System.ArgumentException argEx = new System.ArgumentException("Invalid robot type for program. Is it a UR robot?");
                    throw argEx;
                }
                this.program = "def " + this.name + "():\n";

                // Write init data
                this.program += "\ttextmsg(\"---\")\n";
                this.program += "\ttextmsg(\"Program generated by Brick v0.1\")\n";
                this.program += "\ttextmsg(\"Brick is written by Tom Svilans\")\n\n";
                this.program += "\ttextmsg(\"tomsvilans.com\")\n\n";
                this.program += "\ttextmsg(\"---\")\n";
                Types.UR.AxisAngle ta = new Types.UR.AxisAngle(robot.Tool.RootToTCP);
                this.program += String.Format("\tset_tcp(p[{0:0.0000}, {1:0.0000}, {2:0.0000}, {3:0.0000}, {4:0.0000}, {5:0.0000}])\n", robot.Tool.RootToTCP.M03 * 0.001, robot.Tool.RootToTCP.M13 * 0.001, robot.Tool.RootToTCP.M23 * 0.001, ta.x * ta.angle, ta.y * ta.angle, ta.z * ta.angle);
                this.program += String.Format("\tset_payload({0:0.0000})\n\n", 1.0);

                //this.program += String.Format("while(True):\n\tif(get_digital_out({0})):\n\t\tbreak\n\telse:\n\t\tsync()\n\n", 5);

                for (int i = 0; i < commands.Count; ++i)
                {
                    switch (commands[i].Type())
                    {
                        case (CommandType.MoveCommand):
                            bMoveBase movcmd = (bMoveBase)commands[i];
                            movcmd.Transform(Transform.PlaneToPlane(robot.Position, Plane.WorldXY));
                            this.program += "    " + movcmd.to_script(bRobotBrand.UR, true);
                            movcmd.Transform(Transform.PlaneToPlane(Plane.WorldXY, robot.Position));
                            break;
                        case (CommandType.IOCommand):
                            bIOBase iocmd = (bIOBase)commands[i];
                            this.program += iocmd.to_script(bRobotBrand.UR);
                            break;
                        default:
                            this.program += "Unsupported command.\n";
                            break;
                    }
                }
                this.program += "end\n";
                this.program += this.name + "()\n"; // run program

                return 1;
            }
Пример #4
0
            public override String to_script(bRobotBrand type, bool cont)
            {
                switch (type)
                {
                    case (bRobotBrand.UNKNOWN):
                        return "Unknown robot model";
                    case (bRobotBrand.UR):
                        Types.UR.AxisAngle q1 = new Types.UR.AxisAngle(Rhino.Geometry.Transform.PlaneToPlane(Plane.WorldXY, this.waypoint));
                        Types.UR.AxisAngle q2 = new Types.UR.AxisAngle(Rhino.Geometry.Transform.PlaneToPlane(Plane.WorldXY, this.waypoint2));

                        return String.Format("movec(p[{0:0.0000}, {1:0.0000}, {2:0.0000}, {3:0.0000}, {4:0.0000}, {5:0.0000}], p[{6:0.0000}, {7:0.0000}, {8:0.0000}, {9:0.0000}, {10:0.0000}, {11:0.0000}], a={12:0.0000}, v={13:0.0000})",
                            this.waypoint.Origin.X * 0.001, this.waypoint.Origin.Y * 0.001, this.waypoint.Origin.Z * 0.001,
                            q1.x, q1.y, q1.z,
                            this.waypoint2.Origin.X * 0.001, this.waypoint2.Origin.Y * 0.001, this.waypoint2.Origin.Z * 0.001,
                            q2.x, q2.y, q2.z,
                            this.qdd, this.qd);

                    case (bRobotBrand.KUKA):
                        Types.KUKA.kukaABC k1 = new Types.KUKA.kukaABC(Rhino.Geometry.Transform.PlaneToPlane(Plane.WorldXY, this.waypoint));
                        Types.KUKA.kukaABC k2 = new Types.KUKA.kukaABC(Rhino.Geometry.Transform.PlaneToPlane(Plane.WorldXY, this.waypoint2));
                        string cmd = String.Format("CIRC {X {0:0.000}, Y {1:0.000}, Z {2:0.000}, A {3:0.000}, B {4:0.000}, C {5:0.000},",
                            k1.x, k1.y, k1.z, k1.a, k1.b, k1.c)
                            + String.Format("X {0:0.000}, Y {1:0.000}, Z {2:0.000}, A {3:0.000}, B {4:0.000}, C {5:0.000},",
                            k2.x, k2.y, k2.z, k2.a, k2.b, k2.c)
                            + "E1 0, E2 0, E3 0, E4 0, E5 0, E6 0}";
                        if (cont)
                            cmd += " C_VEL\n";
                        else
                            cmd += "\n";
                        return cmd;
                    case (bRobotBrand.ABB):
                        break;

                }
                return "circular move";
            }