コード例 #1
0
 /**
  * <summary>Reset the robotic marionette</summary>
  * <see cref="IRoboticModel.Reset"/>
  */
 public AngleSet Reset()
 {
     log.Debug("RESET!");
     AngleSet angles = new AngleSet();
     angles.AngleMap.Add(RoboticAngle.HeadLift, 0);
     angles.AngleMap.Add(RoboticAngle.LeftArmLift, 0);
     angles.AngleMap.Add(RoboticAngle.RightArmLift, 0);
     angles.AngleMap.Add(RoboticAngle.RearLift, 0);
     angles.AngleMap.Add(RoboticAngle.CurtainOpen, Math.PI);
     avghipcenter = 0;
     return angles;
 }
コード例 #2
0
        /// <summary>
        ///A test for IsMovementFinished
        ///</summary>
        //        [TestMethod()]
        public void IsMovementFinishedTest()
        {
            List<RoboticAngle> roboticAngleList = new List<RoboticAngle>(defaultChannelMap.Keys);
            AngleSet requested = new AngleSet();
            for (int i = 0; i < roboticAngleList.Count; i++)
                requested.AngleMap.Add(roboticAngleList[i], 0.5);
            (target as IConsumer<AngleSet>).Update(requested);

            bool actual = target.IsMovementFinished();
            Assert.IsFalse(actual);

            Thread.Sleep(5000);

            actual = target.IsMovementFinished();
            Assert.IsTrue(actual);
        }
コード例 #3
0
        public void UpdateTest()
        {
            List<RoboticAngle> roboticAngleList = new List<RoboticAngle>(defaultChannelMap.Keys);
            AngleSet requested = new AngleSet();
            for (int i = 0; i < roboticAngleList.Count; i++)
                requested.AngleMap.Add(roboticAngleList[i], 0.5);
            (target as IConsumer<AngleSet>).Update(requested);

            AngleSet actual = target.GetAngles(roboticAngleList);
            Assert.AreEqual(requested, actual);
        }
コード例 #4
0
        /// <summary>
        ///A test for GetAngles
        ///</summary>
        //        [TestMethod()]
        public void StartGetAnglesTest()
        {
            List<RoboticAngle> roboticAngleList = new List<RoboticAngle>(defaultChannelMap.Keys);
            AngleSet expected = new AngleSet();
            for (int i = 0; i < roboticAngleList.Count; i++)
                expected.AngleMap.Add(roboticAngleList[i], 0);

            AngleSet actual;
            actual = target.GetAngles(roboticAngleList);
            Assert.IsNotNull(actual);
            Assert.AreEqual(expected.AngleMap, actual.AngleMap);
        }
コード例 #5
0
ファイル: RoboticArmModel.cs プロジェクト: yanatan16/RoboNUI
 /**
  * <summary>Reset the robotic arm</summary>
  * <see cref="IRoboticModel.Reset"/>
  */
 public AngleSet Reset()
 {
     AngleSet angles = new AngleSet();
     angles.AngleMap.Add(RoboticAngle.ArmBaseRotate, 0);
     angles.AngleMap.Add(RoboticAngle.ArmShoulderLift, 0);
     angles.AngleMap.Add(RoboticAngle.ArmElbowBend, 0);
     angles.AngleMap.Add(RoboticAngle.ArmWristTilt, 0);
     angles.AngleMap.Add(RoboticAngle.ArmWristRotate, 0);
     angles.AngleMap.Add(RoboticAngle.ArmHandGrasp, 0);
     return angles;
 }
コード例 #6
0
ファイル: RoboticArmModel.cs プロジェクト: yanatan16/RoboNUI
        /**
         * <summary>Translate between joints to angles for the robotic arm</summary>
         * <see cref="IRoboticModel.Translate"/>
         */
        public AngleSet Translate(JointSet js)
        {
            AngleSet angles = new AngleSet();

            ControllerJoints Elbow = (UseRightArm ? ControllerJoints.ElbowRight : ControllerJoints.ElbowLeft);
            ControllerJoints Shoulder = (UseRightArm ? ControllerJoints.ShoulderRight : ControllerJoints.ShoulderLeft);
            ControllerJoints Wrist = (UseRightArm ? ControllerJoints.WristRight : ControllerJoints.WristLeft);
            ControllerJoints Hand = (UseRightArm ? ControllerJoints.HandRight : ControllerJoints.HandLeft);

            // Shoulder joints
            if (js.JointMap.ContainsKey(Elbow) &&
                js.JointMap.ContainsKey(Shoulder) &&
                js.JointMap.ContainsKey(Wrist) &&
                js.JointMap.ContainsKey(Hand))
            {
                Position3d topArm = js.JointMap[Elbow] - js.JointMap[Shoulder];
                angles.AngleMap.Add(RoboticAngle.ArmBaseRotate,
                    Math.Atan2(topArm.z, topArm.x)
                );
                angles.AngleMap.Add(RoboticAngle.ArmShoulderLift,
                    Math.Atan2(topArm.y, topArm.x)
                );

                Position3d bottomArm = js.JointMap[Wrist] - js.JointMap[Elbow];
                double elbowangle = Math.Acos(bottomArm.Dot(topArm) / (topArm.Magnitude() * bottomArm.Magnitude()));
                double elbowsign = (UseRightArm ? -1 : 1) * Math.Sign(topArm.Cross(bottomArm).z);
                double elbowshift = -Math.PI / 4;
                angles.AngleMap.Add(RoboticAngle.ArmElbowBend,
                    elbowangle * elbowsign + elbowshift
                );

                Position3d hand = js.JointMap[Hand] - js.JointMap[Wrist];
                double wristangle = Math.Acos(bottomArm.Dot(hand) / (hand.Magnitude() * bottomArm.Magnitude()));
                double wristsign = (UseRightArm ? 1 : -1) * Math.Sign(bottomArm.Cross(hand).z);
                double wristshift = Math.PI / 6;
                double wristmult = 2;
                angles.AngleMap.Add(RoboticAngle.ArmWristTilt,
                    (wristangle * wristsign + wristshift) * wristmult
                );

                keptHand = hand;
                keptTopArm = topArm;
            }

            if (js.JointMap.ContainsKey(Hand) &&
                js.JointMap.ContainsKey(ControllerJoints.Fingertip) &&
                js.JointMap.ContainsKey(ControllerJoints.Fingerstart))
            {
                Position3d fingertip = js.JointMap[ControllerJoints.Fingertip];
                Position3d fingerstart = js.JointMap[ControllerJoints.Fingerstart];
                Position3d hand = js.JointMap[Hand];
                double open = (fingertip - fingerstart).Magnitude();
                double fingerscale = 1;

                Position3d realperp = (fingertip - hand).Cross(fingerstart - hand);
                Position3d imagperp = keptHand.Cross(keptTopArm);
                double rotateangle = Math.Acos(realperp.Dot(imagperp) / (realperp.Magnitude() * imagperp.Magnitude()));
                double rotatesign = Math.Sign(keptHand.Dot(realperp.Cross(imagperp)));
                double rotatescale = 1;

                angles.AngleMap.Add(RoboticAngle.ArmWristRotate, rotateangle * rotatesign * rotatescale);
                angles.AngleMap.Add(RoboticAngle.ArmHandGrasp, open * fingerscale);
            }

            return angles;
        }
コード例 #7
0
        /**
         * <summary>Translate between joints to angles for the robotic arm</summary>
         * <see cref="IRoboticModel.Translate"/>
         */
        public AngleSet Translate(JointSet js)
        {
            double hipdiff = js.JointMap[ControllerJoints.HipCenter].y - avghipcenter;
            avghipcenter = (avghipcenter + js.JointMap[ControllerJoints.HipCenter].y) / 2;

            // Find the height above for each node
            Position3d lefthand = js.JointMap[ControllerJoints.HandLeft] - js.JointMap[ControllerJoints.ShoulderLeft];
            Position3d righthand = js.JointMap[ControllerJoints.HandRight] - js.JointMap[ControllerJoints.ShoulderRight];

            double handLeftAngle = -Math.Atan2(lefthand.y, -lefthand.x);
            double handRightAngle = -Math.Atan2(righthand.y, righthand.x);

            Position3d hip = js.JointMap[ControllerJoints.HipCenter];
            Position3d head = js.JointMap[ControllerJoints.Head];
            double dely = head.y - hip.y;
            double delz = Math.Max(0,hip.z - head.z);
            double bendAngle = Math.Atan2(delz, dely);

            double bendPct = Math.PI/4 - (bendAngle - Math.PI/2) / (Math.PI/2);
            double headAngle = bendAngle * Math.PI * 2 - Math.PI - hipdiff;
            double rearAngle = -headAngle - hipdiff;

            log.ErrorFormat("handRight: {0}", handRightAngle);

            AngleSet angles = new AngleSet();
            angles.AngleMap.Add(RoboticAngle.HeadLift, headAngle);
            angles.AngleMap.Add(RoboticAngle.LeftArmLift, handLeftAngle);
            angles.AngleMap.Add(RoboticAngle.RightArmLift, handRightAngle);
            angles.AngleMap.Add(RoboticAngle.RearLift, rearAngle);
            angles.AngleMap.Add(RoboticAngle.CurtainOpen, -Math.PI);

            //log.Debug("Translating JointSet to AngleSet: as(" + angles.ToString() + ")");

            return angles;
        }