Beispiel #1
0
        public static UserTransformableRecording Load(string filename)
        {
            UserTransformableRecording newRecording = new UserTransformableRecording();

            try {
                FileStream file = File.OpenRead(Path.Combine(Application.persistentDataPath, filename));

                BinaryReader reader     = new BinaryReader(file);
                int          nKeyframes = reader.ReadInt32();

                for (int i = 0; i < nKeyframes; i++)
                {
                    newRecording.AddKeyframe(new UserTransformKeyframe(ref reader));
                }

                if (reader.ReadUInt32() != 0xffffffff)
                {
                    throw new Exception("Invalid save file");
                }

                OneButtonAlert.Create("Loaded recording successfully.");
            }
            catch (Exception e) {
                OneButtonAlert.Create("Failed to load saved recording.");
            }

            return(newRecording);
        }
Beispiel #2
0
 public void onConnectSuccess()
 {
     try {
         OneButtonAlert.Create("Connected successfully!");
         SaveDefaults();
         Close();
         RobotInterface.instance.MoveNow(new RobotInterface.MoveJointsCommand(new float[] { 0, -Mathf.PI / 2.0f, Mathf.PI / 2.0f, -Mathf.PI / 2.0f, 0, 0 }));
         RobotInterface.instance.FetchRealPose();
     } catch (Exception e) {
         OutputText.instance.text = OutputText.instance.text + "\n" + e.Message + "\n" + e.StackTrace;
     }
 }
Beispiel #3
0
        public void Save(string filename)
        {
            try {
                FileStream file = File.Create(Path.Combine(Application.persistentDataPath, filename));

                BinaryWriter writer = new BinaryWriter(file);
                writer.Write((UInt32)keyframes.Count);

                for (int i = 0; i < keyframes.Count; i++)
                {
                    keyframes[i].PutToBinary(ref writer);
                }

                writer.Write((UInt32)0xffffffff);

                writer.Flush();
                file.Flush();
                OneButtonAlert.Create("Saved recording successfully.");
            }
            catch (Exception e) {
                OneButtonAlert.Create("Failed to save recording.");
            }
        }
Beispiel #4
0
 public void onConnectFailure(string errorMessage)
 {
     OneButtonAlert.Create("Failed to connect. Error message:\n" + errorMessage);
 }