Example #1
0
        static void Main(string[] args)
        {
            Dictionary<string, string> actions = new Dictionary<string, string>();
            actions["raise the roof"] = "raisetheroof";
            actions["walk forward"] = "walkforward";
            actions["walk left"] = "walkleft";
            actions["wave right"] = "waveright";
            actions["wave left"] = "waveleft";
            string filename = "Z:/dev/kinect-nao/recordings/";
            ActionLibrary lib = new ActionLibrary();

            foreach (string actionName in actions.Keys)
            {
                List<HumanSkeleton> seq = new List<HumanSkeleton>();
                using (StreamReader s = new StreamReader(filename + actions[actionName] + "/"
                    + actionName + "1.rec"))
                {
                    while (!s.EndOfStream)
                    {
                        seq.Add(new HumanSkeleton(s.ReadLine()));
                    }
                }

                //List<float[]> naoSeq = new List<float[]>();
                ActionSequence<NaoSkeleton> naoSeq = new ActionSequence<NaoSkeleton>();
                foreach (HumanSkeleton h in seq)
                {
                    AngleConverter ac = new AngleConverter(h);
                    naoSeq.append(ac.getNaoSkeleton());
                    //naoSeq.Add(ac.getAngles());
                }

                lib.appendToCache(naoSeq);
                lib.setCachedName(actionName);
                lib.saveCache();
                //bool isJointAction = true; // false if is a walking action
                //ExecuteOnNao(naoSeq, isJointAction);
            }
            lib.save(MainController.ACTION_LIB_PATH);
        }
Example #2
0
        public static ActionLibrary load(String path)
        {
            /*ActionLibrary al = new ActionLibrary();

            Stream stream = File.Open(path, FileMode.Open);
            BinaryFormatter bformatter = new BinaryFormatter();

            al = (ActionLibrary)bformatter.Deserialize(stream);
            stream.Close();

            return al;*/

            Dictionary<string, string> actions = new Dictionary<string, string>();
            actions["raise the roof"] = "raisetheroof";
            actions["walk forward"] = "walkforward";
            actions["walk left"] = "walkleft";
            actions["walk back"] = "walkbackward";
            actions["walk right"] = "walkright";
            actions["wave right"] = "waveright";
            actions["wave left"] = "waveleft";
            string filename = "Z:/dev/kinect-nao/recordings/";
            ActionLibrary lib = new ActionLibrary();

            foreach (string actionName in actions.Keys)
            {
                List<HumanSkeleton> seq = new List<HumanSkeleton>();
                using (StreamReader s = new StreamReader(filename + actions[actionName] + "/"
                    + actionName + "1.rec"))
                {
                    while (!s.EndOfStream)
                    {
                        seq.Add(new HumanSkeleton(s.ReadLine()));
                    }
                }

                ActionSequence<NaoSkeleton> naoSeq = new ActionSequence<NaoSkeleton>();
                foreach (HumanSkeleton h in seq)
                {
                    AngleConverter ac = new AngleConverter(h);
                    naoSeq.append(ac.getNaoSkeleton());
                }

                if (actionName.StartsWith("walk"))
                {
                    NaoSkeleton start = naoSeq.get(0);
                    NaoSkeleton end = naoSeq.get(naoSeq.size() - 1);
                    NaoSkeleton diff = new NaoSkeleton(new NaoPosition(end.Position.X - start.Position.X, end.Position.Y - start.Position.Y, end.Position.Z - start.Position.Z));
                    naoSeq = new ActionSequence<NaoSkeleton>();
                    naoSeq.append(diff);
                }
                lib.appendToCache(naoSeq);
                lib.setCachedName(actionName);
                lib.saveCache();
            }

            return lib;
        }
Example #3
0
 public double[] toArray(bool useJointvals)
 {
     // TODO: convert to joint vals if needed
     if (useJointvals)
     {
         AngleConverter ac = new AngleConverter(this);
         return Util.toDoubleArray(ac.getAngles());
     }
     else
         return new double[] {
             joints[JointID.HipCenter].x,
             joints[JointID.HipCenter].y,
             joints[JointID.HipCenter].z};
 }