public RobotArm() { armComms = new ArmCommunicator(); robotBase = new Joint(JointID.BASE, armComms); wrist = new Joint(JointID.WRIST, armComms); shoulder = new Joint(JointID.SHOULDER, armComms); elbow = new Joint(JointID.ELBOW, armComms); joints = new Joint[4]; // order is important; used by moveTo() joints[0] = robotBase; joints[1] = wrist; joints[2] = shoulder; joints[3] = elbow; }
public void ProcessedMovesListTimes() { ArmCommunicator communicator = new ArmCommunicator(); List<Move> movesList = new List<Move>(); movesList.Add(new Move() { direction = ArmCommunicator.POSITIVE, JointId = JointID.BASE, time = 500 }); movesList.Add(new Move() { direction = ArmCommunicator.POSITIVE, JointId = JointID.ELBOW, time = 350 }); movesList.Add(new Move() { direction = ArmCommunicator.NEGATIVE, JointId = JointID.SHOULDER, time = 300 }); movesList.Add(new Move() { direction = ArmCommunicator.POSITIVE, JointId = JointID.WRIST, time = 280 }); var processedMoves = communicator.ProcessedMovesList(movesList); Assert.AreEqual(280, processedMoves.First().time); Assert.AreEqual(20, processedMoves.ElementAt(1).time); Assert.AreEqual(50, processedMoves.ElementAt(2).time); Assert.AreEqual(150, processedMoves.ElementAt(3).time); Assert.AreEqual(10, processedMoves.ElementAt(4).time); }
public void ProcessedMovesListFirstByte() { // generate a list of legitimate moves ArmCommunicator communicator = new ArmCommunicator(); List<Move> movesList = new List<Move>(); movesList.Add(new Move() {direction = ArmCommunicator.POSITIVE, JointId = JointID.BASE, time = 500}); movesList.Add(new Move() {direction = ArmCommunicator.POSITIVE, JointId = JointID.ELBOW, time = 350}); movesList.Add(new Move() {direction = ArmCommunicator.NEGATIVE, JointId = JointID.SHOULDER, time = 300}); movesList.Add(new Move() {direction = ArmCommunicator.POSITIVE, JointId = JointID.WRIST, time = 280}); var processedMoves = communicator.ProcessedMovesList(movesList); Assert.AreEqual((ElbowUp + ShoulderDown + WristUp),processedMoves.First().opCode1); Assert.AreEqual((ElbowUp + ShoulderDown + WristUp + WristDown), processedMoves.ElementAt(1).opCode1); Assert.AreEqual((ElbowUp + ShoulderUp + ShoulderDown), processedMoves.ElementAt(2).opCode1); Assert.AreEqual((ElbowDown + ElbowUp), processedMoves.ElementAt(3).opCode1); Assert.AreEqual(0x00, processedMoves.ElementAt(4).opCode1); }