示例#1
0
 /// <summary>
 ///   Add a leg to the hexapod's trunk
 /// </summary>
 /// <param name="Leg"></param>
 public void AddLeg(HexaLeg Leg)
 {
     legs.Add(Leg);
     log.WriteLog(
         "[INIT] Added new leg; Endpoint: " + Leg.Point.ToString() + "; " +
         "Lambda: " + Leg.Lambda.ToString() + "°; " +
         "Support-Criteria: " + Leg.Support.ToString() + "; " +
         "Switch-Criteria: " + Leg.SwitchLeg.ToString()
         );
 }
示例#2
0
        /// <summary>
        ///   Read configuration file
        /// </summary>
        /// <returns>Read configuration in form of a list of finished legs</returns>
        public List <HexaLeg> Read()
        {
            List <HexaLeg> legs = new List <HexaLeg>();
            Dictionary <string, configFile> x = new Dictionary <string, configFile>();
            configFile cF = new configFile();

            string config = File.ReadAllText(this.filePath);

            // Try to convert read text to structure
            try {
                x = JsonConvert.DeserializeObject <Dictionary <string, configFile> >(config);
            } catch (Exception ex) {
                throw new ConfigError("[Read]" + ex.Message);
            }

            // Try to break down structure to individually legs
            try {
                cF = x["Hexapod"];
                HexaLeg hl;

                foreach (tempLeg tL in cF.Legs)
                {
                    hl = new HexaLeg(
                        tL.Lambda,
                        new Vector3D(tL.Offset),
                        new Vector3D(tL.Hip),
                        new Vector3D(tL.Thigh),
                        new Vector3D(tL.Shank),
                        tL.Support,
                        tL.Switch
                        );
                    legs.Add(hl);
                }
            } catch (Exception ex) {
                throw new ConfigError("[Mapping]" + ex.Message);
            }

            return(legs);
        }