Ejemplo n.º 1
0
        public void lin(LuaTable table, float velocity)
        {
            doneCommand = false;
            Controller.LinearCommand command = new Controller.LinearCommand();
            command.velocity = Mathf.Min(Mathf.Max(velocity, 0.001f), 2);
            if (table["X"] != null)
            {
                command.target.t[Controller.CartesianAxis.X] = LuaNumber2Float(table["X"]);
            }
            if (table["Y"] != null)
            {
                command.target.t[Controller.CartesianAxis.Y] = LuaNumber2Float(table["Y"]);
            }
            if (table["Z"] != null)
            {
                command.target.t[Controller.CartesianAxis.Z] = LuaNumber2Float(table["Z"]);
            }
            if (table["A"] != null)
            {
                command.target.t[Controller.CartesianAxis.A] = LuaNumber2Float(table["A"]);
            }
            if (table["B"] != null)
            {
                command.target.t[Controller.CartesianAxis.B] = LuaNumber2Float(table["B"]);
            }
            if (table["C"] != null)
            {
                command.target.t[Controller.CartesianAxis.C] = LuaNumber2Float(table["C"]);
            }
            currentCommand = command;

            while (!doneCommand)
            {
                System.Threading.Thread.Sleep(1);
            }
        }
Ejemplo n.º 2
0
 public void SetCurrentCommand(Controller.MotionCommand command)
 {
     currentCommand = command;
 }
Ejemplo n.º 3
0
        public void ptp(LuaTable table, float velocity)
        {
            bool isJnt = false;
            bool isPtp = false;

            doneCommand = false;
            Controller.JointCommand jnt = new Controller.JointCommand();
            jnt.velocity = Mathf.Min(Mathf.Max(velocity, 0.01f), 1.0f);
            if (table["A1"] != null)
            {
                jnt.target.q[Controller.Axis.A1] = LuaNumber2Float(table["A1"]); isJnt = true;
            }
            if (table["A2"] != null)
            {
                jnt.target.q[Controller.Axis.A2] = LuaNumber2Float(table["A2"]); isJnt = true;
            }
            if (table["A3"] != null)
            {
                jnt.target.q[Controller.Axis.A3] = LuaNumber2Float(table["A3"]); isJnt = true;
            }
            if (table["A4"] != null)
            {
                jnt.target.q[Controller.Axis.A4] = LuaNumber2Float(table["A4"]); isJnt = true;
            }
            if (table["A5"] != null)
            {
                jnt.target.q[Controller.Axis.A5] = LuaNumber2Float(table["A5"]); isJnt = true;
            }
            if (table["A6"] != null)
            {
                jnt.target.q[Controller.Axis.A6] = LuaNumber2Float(table["A6"]); isJnt = true;
            }

            Controller.PtpCommand ptp = new Controller.PtpCommand();
            if (table["X"] != null)
            {
                ptp.target.t[Controller.CartesianAxis.X] = LuaNumber2Float(table["X"]); isPtp = true;
            }
            if (table["Y"] != null)
            {
                ptp.target.t[Controller.CartesianAxis.Y] = LuaNumber2Float(table["Y"]); isPtp = true;
            }
            if (table["Z"] != null)
            {
                ptp.target.t[Controller.CartesianAxis.Z] = LuaNumber2Float(table["Z"]); isPtp = true;
            }
            if (table["A"] != null)
            {
                ptp.target.t[Controller.CartesianAxis.A] = LuaNumber2Float(table["A"]); isPtp = true;
            }
            if (table["B"] != null)
            {
                ptp.target.t[Controller.CartesianAxis.B] = LuaNumber2Float(table["B"]); isPtp = true;
            }
            if (table["C"] != null)
            {
                ptp.target.t[Controller.CartesianAxis.C] = LuaNumber2Float(table["C"]); isPtp = true;
            }
            if (table["I"] != null)
            {
                ptp.target.i = LuaNumber2Int(table["I"]); isPtp = true;
            }

            if (isJnt && isPtp)
            {
                throw new ArgumentException("Both ptp and jnt arguments.");
            }
            if (isJnt)
            {
                currentCommand = jnt;
            }
            else if (isPtp)
            {
                currentCommand = ptp;
            }

            while (!doneCommand)
            {
                System.Threading.Thread.Sleep(1);
            }
        }