コード例 #1
0
        /// <summary>
        /// Returns a list of paths stored in the robot.
        /// </summary>
        /// <returns></returns>
        public string[] GetPathList()
        {
            RovioResponse response = MovementControl(Commands.GetPathList);

            // solves version bug
            if (response.ContainsKey("version"))
            {
                Thread.Sleep(2000);
                return(this.GetPathList());
            }
            List <string> list = new List <string>();

            if (response["responses"] == "0")
            {
                //path_list_refreshed = 1;

                //if (list.indexOf(" = 0") != -1)
                //{
                //    list = list.substring(list.indexOf("responses = 0") + 13);
                //    if (trim(list).length)
                //    {
                //        var paths = list.split('|');
                //        for (i = 0; i < paths.length; i++)
                //        {
                //            addPathToList(paths[i]);
                //        }
                //    }
                //}
            }

            return(list.ToArray());
        }
コード例 #2
0
        /// <summary>
        ///  Turning on/off IR detector.
        /// </summary>
        /// <param name="state">0 - off, 1 - on</param>
        /// <returns></returns>
        public string SetIRState(bool enabled)
        {
            RovioResponse response = MovementControl(Commands.TestCommand,
                                                     new RequestItem("IR", enabled ? 1 : 0));

            return("");
        }
コード例 #3
0
        /// <summary>
        /// Deletes specified path.
        /// </summary>
        /// <param name="PathName">name of the path</param>
        /// <returns>Response code</returns>
        public string Deletepath(string PathName)
        {
            RovioResponse response = MovementControl(Commands.Deletepath,
                                                     new RequestItem("name", PathName));

            return("");
        }
コード例 #4
0
        internal Dictionary <FlashParameters, Int32> ReadAllParameters()
        {
            Dictionary <FlashParameters, Int32> dic = new Dictionary <FlashParameters, int>();
            RovioResponse response = MovementControl(Commands.ReadParameter);

            foreach (RovioResponseItem item in response)
            {
                if (!item.Key.StartsWith("v"))
                {
                    continue;
                }
                FlashParameters paraId = (FlashParameters)int.Parse(item.Key.Substring(1));
                int             value  = -1;
                if (string.IsNullOrEmpty(item.Value))
                {
                    value = -1;
                }
                else
                {
                    value = Int32.Parse(item.Value);
                }
                if (dic.ContainsKey(paraId))
                {
                    dic[paraId] = value;
                }
                else
                {
                    dic.Add(paraId, value);
                }
            }

            return(dic);
        }
コード例 #5
0
        /// <summary>
        /// Turn off or turn on Rovio head light.
        /// </summary>
        /// <param name="Value">0 - Off, 1 - On</param>
        /// <returns></returns>
        public string SetHeadLight(HeadLightState state)
        {
            RovioResponse response = MovementControl(Commands.TestCommand,
                                                     new RequestItem("LIGHT", (int)state));

            return("");
        }
コード例 #6
0
        /// <summary>
        /// Emails current image or if in path recording mode sets an action.
        /// </summary>
        /// <param name="email">email address ([email protected])</param>
        /// <returns></returns>
        public string EmailImage(string email)
        {
            RovioResponse response = MovementControl(Commands.EmailImage,
                                                     new RequestItem("email", email));

            return("");
        }
コード例 #7
0
ファイル: RovioStatus.cs プロジェクト: sunsunsun000/rovio
        public static RovioStatus Parse(RovioResponse response)
        {
            RovioStatus status = new RovioStatus();


            return(status);
        }
コード例 #8
0
        /// <summary>
        /// Stops the recoding of a path and stores it in flash memory; javascript will give default name if user does not provide one.
        /// </summary>
        /// <param name="PathName">name of the path</param>
        /// <returns>Response code</returns>
        public string StopRecording(string PathName)
        {
            RovioResponse response = MovementControl(Commands.StopRecording,
                                                     new RequestItem("name", PathName));

            return("");
        }
コード例 #9
0
        /// <summary>
        /// Replays a stored path from closest point to the beginning; If NorthStar signal is lost it stops.
        /// </summary>
        /// <remarks>In API 1.2 there is no mention of PathName parameter</remarks>
        /// <param name="PathName"></param>
        /// <returns></returns>
        public string PlayPathBackward(string PathName)
        {
            RovioResponse response = MovementControl(Commands.PlayPathBackward,
                                                     new RequestItem("name", PathName));

            return("");
        }
コード例 #10
0
        /// <summary>
        /// Read parameter in the robot’s Flash memory.
        /// </summary>
        /// <param name="index">0 – 19</param>
        /// <returns></returns>
        public Int32 ReadParameter(long index)
        {
            RovioResponse response = MovementControl(Commands.ReadParameter,
                                                     new RequestItem("index", index));

            return(Int32.Parse(response["value"]));
        }
コード例 #11
0
ファイル: RovioMcuReport.cs プロジェクト: sunsunsun000/rovio
        public static RovioMcuReport Parse(RovioResponse dic)
        {
            RovioMcuReport report = new RovioMcuReport();

            //0E0100000000000000000003CB744B
            string responses = dic["responses"];

            byte[] data = new byte[responses.Length / 2];
            for (int i = 0; i < data.Length; i++)
            {
                data[i] = byte.Parse(responses.Substring(i * 2, 2), System.Globalization.NumberStyles.HexNumber);
            }

            int offset = 0;
            //Length of the packet
            int length = data[offset]; offset += 1;

            //NOT IN USE
            offset += 1;
            //Direction of rotation of left wheel since last read (bit 2)
            int leftWheelDirection = data[offset]; offset += 1;
            //Number of left wheel encoder ticks since last read
            int leftWheelTicks = data[offset] + data[offset + 1] * 256; offset += 2;
            //Direction of rotation of right wheel since last read (bit 2)
            int rightWheelDirection = data[offset]; offset += 1;
            //Number of right wheel encoder ticks since last read
            int rightWheelTicks = data[offset] + data[offset + 1] * 256; offset += 2;
            //Direction of rotation of rear wheel since last read (bit 2)
            int rearWheelDirection = data[offset]; offset += 1;
            //Number of rear wheel encoder ticks since last read
            int rearWheelTicks = data[offset] + data[offset + 1] * 256; offset += 2;

            //NOT IN USE
            offset += 1;
            //Head position
            int headPosition = data[offset]; offset += 1;
            //Battery
            //  0x7F: Battery Full (0x7F or higher for new battery)
            //  0x??: Orange light in Rovio head. ( to be define)
            //  0x6A: Very low battery (Hungry, danger, very low battery level)
            //  libNS need take control to go home and charging
            //  0x64: Shutdown level (MCU will cut off power for protecting the battery)
            int battery = data[offset]; offset += 1;
            //status
            //bit 0 : Light LED (head) status, 0: OFF, 1: ON
            //bit 1 : IR-Radar power status. 0: OFF, 1: ON
            //bit 2 : IR-Radar detector status: 0: fine, 1: barrier detected.
            //bit 3-5: Charger staus
            //        0x00 : nothing happen
            //        0x01 : charging completed.
            //        0x02 : in charging
            //        0x04 : something wrong, error occur.
            //bit 6,7: undefined, do not use.
            byte status = data[offset]; offset += 1;

            report.HeadLight = ((status & 0x01) == 0x01) ? HeadLightState.On : HeadLightState.Off;

            return(report);
        }
コード例 #12
0
        /// <summary>
        /// Rename the old path.
        /// </summary>
        /// <param name="OldPathName"></param>
        /// <param name="NewPathName"></param>
        /// <returns></returns>
        public string RenamePath(string OldPathName, string NewPathName)
        {
            RovioResponse response = MovementControl(Commands.RenamePath,
                                                     new RequestItem("name", OldPathName),
                                                     new RequestItem("newname", NewPathName));

            return("");
        }
コード例 #13
0
ファイル: RovioMcuReport.cs プロジェクト: SaintLoong/rovio
        public static RovioMcuReport Parse(RovioResponse dic)
        {
            RovioMcuReport report = new RovioMcuReport();

            //0E0100000000000000000003CB744B
            string responses = dic["responses"];
            byte[] data = new byte[responses.Length / 2];
            for(int i=0;i<data.Length; i++)
                data[i] = byte.Parse(responses.Substring(i * 2, 2), System.Globalization.NumberStyles.HexNumber);

            int offset = 0;
            //Length of the packet
            int length = data[offset]; offset += 1;
            //NOT IN USE
            offset += 1;
            //Direction of rotation of left wheel since last read (bit 2)
            int leftWheelDirection = data[offset]; offset +=1;
            //Number of left wheel encoder ticks since last read
            int leftWheelTicks = data[offset] + data[offset + 1] * 256; offset += 2;
            //Direction of rotation of right wheel since last read (bit 2)
            int rightWheelDirection = data[offset]; offset +=1;
            //Number of right wheel encoder ticks since last read
            int rightWheelTicks = data[offset] + data[offset + 1] * 256; offset += 2;
            //Direction of rotation of rear wheel since last read (bit 2)
            int rearWheelDirection = data[offset]; offset +=1;
            //Number of rear wheel encoder ticks since last read
            int rearWheelTicks = data[offset] + data[offset + 1] * 256; offset += 2;
            //NOT IN USE
            offset += 1;
            //Head position
            int headPosition = data[offset]; offset += 1;
            //Battery
            //  0x7F: Battery Full (0x7F or higher for new battery)
            //  0x??: Orange light in Rovio head. ( to be define)
            //  0x6A: Very low battery (Hungry, danger, very low battery level)
            //  libNS need take control to go home and charging
            //  0x64: Shutdown level (MCU will cut off power for protecting the battery)
            int battery = data[offset]; offset += 1;
            //status
            //bit 0 : Light LED (head) status, 0: OFF, 1: ON
            //bit 1 : IR-Radar power status. 0: OFF, 1: ON
            //bit 2 : IR-Radar detector status: 0: fine, 1: barrier detected.
            //bit 3-5: Charger staus
            //        0x00 : nothing happen
            //        0x01 : charging completed.
            //        0x02 : in charging
            //        0x04 : something wrong, error occur.
            //bit 6,7: undefined, do not use.
            byte status = data[offset]; offset += 1;

            report.HeadLight = ((status & 0x01) == 0x01) ? HeadLightState.On : HeadLightState.Off;

            return report;
        }
コード例 #14
0
        internal static RovioStatusReport Parse(RovioStatusReport report, RovioResponse dic)
        {
            report.str = dic.ToString();

            report.Location = new RovioLocation(
                short.Parse(dic["x"]),
                short.Parse(dic["y"]),
                double.Parse(dic["theta"]));

            report.parseRoomId(dic["room"]);
            report.parseNavStrength(dic["ss"]);
            //如果信号太弱,将RoomId置为-1。
            if (!report.HasNavSignal)
            {
                report.RoomID = -1;
            }

            report.BeaconSignalStrength = UInt16.Parse(dic["beacon"]);
            report.BeaconPoitionX       = Int16.Parse(dic["beacon_x"]);
            report.NextRoomID           = int.Parse(dic["next_room"]);
            report.NextRoomSS           = UInt16.Parse(dic["next_room_ss"]);

            report.parseNavState(dic["state"]);
            report.ui_status     = int.Parse(dic["ui_status"]);
            report.resistance    = int.Parse(dic["resistance"]);
            report.sm            = int.Parse(dic["sm"]);
            report.WayPointIndex = int.Parse(dic["pp"]);
            report.parseFlags(dic["flags"]);

            report.brightness = byte.Parse(dic["brightness"]);

            report.ResolutionId           = int.Parse(dic["resolution"]);
            report.VideoCompression       = (VideoCompression)int.Parse(dic["video_compression"]);
            report.frame_rate             = int.Parse(dic["frame_rate"]);
            report.Privilege              = (UserPrivilege)int.Parse(dic["privilege"]);
            report.AuthenticationRequired = (int.Parse(dic["user_check"]) == 1);// ???? == 0

            //0 (lowest) – 31 (highest)
            report.speaker_volume = double.Parse(dic["speaker_volume"]) / 31.0;
            //0 (lowest) – 31 (highest)
            report.mic_volume = double.Parse(dic["mic_volume"]) / 31.0;
            report.parseWifiStrength(dic["wifi_ss"]);
            // 0 = Not showing the time. 1 = Showing time.
            report.show_time   = (int.Parse(dic["show_time"]) == 1);
            report.ddns_state  = (DdnsStates)int.Parse(dic["ddns_state"]);
            report.email_state = int.Parse(dic["email_state"]);
            report.parseBatteryStrength(dic["battery"]);
            report.parseCharging(dic["charging"]);
            report.HeadPositionTickCount = int.Parse(dic["head_position"]);
            report.ACFrequency           = (ACFrequency)int.Parse(dic["ac_freq"]);

            return(report);
        }
コード例 #15
0
ファイル: UPnPInfo.cs プロジェクト: SaintLoong/rovio
        public static UPnPInfo Parse(RovioResponse response)
        {
            UPnPInfo info = new UPnPInfo();
            info.Enable = (response["Enable"] == "1");
            info.Port = int.Parse(response["Port"]);
            info.IP = response["IP"];
            info.HttpPort = int.Parse(response["HTTP"]);
            info.RstpTcpPort = int.Parse(response["RTSP_TCP"]);
            info.RstpUdpPort = int.Parse(response["RTSP_UDP"]);

            return info;
        }
コード例 #16
0
        /// <summary>
        /// Generates a report from libNS module that provides Rovio’s current status.
        /// </summary>
        /// <returns></returns>
        public RovioStatusReport GetReport()
        {
            RovioResponse reports   = MovementControl(Commands.GetReport);
            ResponseCodes responses = (ResponseCodes)int.Parse(reports["responses"]);

            if (responses != ResponseCodes.SUCCESS)
            {
                throw new Exception("获取报告失败:" + responses);
            }

            report.Update(reports);
            return(report);
        }
コード例 #17
0
ファイル: UPnPInfo.cs プロジェクト: sunsunsun000/rovio
        public static UPnPInfo Parse(RovioResponse response)
        {
            UPnPInfo info = new UPnPInfo();

            info.Enable      = (response["Enable"] == "1");
            info.Port        = int.Parse(response["Port"]);
            info.IP          = response["IP"];
            info.HttpPort    = int.Parse(response["HTTP"]);
            info.RstpTcpPort = int.Parse(response["RTSP_TCP"]);
            info.RstpUdpPort = int.Parse(response["RTSP_UDP"]);

            return(info);
        }
コード例 #18
0
 public bool CheckConnection()
 {
     try
     {
         RovioResponse response = api.Request("/GetMyself.cgi", 2000,
                                              new RequestItem("ShowPrivilege", 0));
         return(true);
     }
     catch (Exception ex)
     {
         return(false);
     }
 }
コード例 #19
0
        /// <summary>
        /// Returns homing, docking and driving parameters.
        /// </summary>
        /// <returns></returns>
        public TuningParameters GetTuningParameters()
        {
            RovioResponse    response = MovementControl(Commands.GetTuningParameters);
            TuningParameters result   = new TuningParameters
            {
                LeftRight   = byte.Parse(response["LeftRight"]),
                Forward     = byte.Parse(response["Forward"]),
                Reverse     = byte.Parse(response["Reverse"]),
                DriveTurn   = byte.Parse(response["DriveTurn"]),
                HomingTurn  = byte.Parse(response["HomingTurn"]),
                ManDrive    = byte.Parse(response["ManDrive"]),
                ManTurn     = byte.Parse(response["ManTurn"]),
                DockTimeout = int.Parse(response["DockTimeout"]),
            };

            return(result);
        }
コード例 #20
0
 /// <summary>
 ///
 /// </summary>
 /// <param name="action"></param>
 /// <param name="speed">1 (fastest) – 10 (slowest) </param>
 internal string ManualDrive(int action, int speed, int?angle = null)
 {
     if (angle == null)
     {
         RovioResponse response = this.MovementControl(Commands.ManualDrive,
                                                       new RequestItem("drive", action),
                                                       new RequestItem("speed", speed));
     }
     else
     {
         RovioResponse response = this.MovementControl(Commands.ManualDrive,
                                                       new RequestItem("drive", action),
                                                       new RequestItem("speed", speed),
                                                       new RequestItem("angle", angle.Value));
     }
     return("");
 }
コード例 #21
0
        /// <summary>
        /// Change camera sensor’s settings.
        /// </summary>
        /// <param name="Frequency">50 – 50Hz, 60 – 60Hz, 0 – Auto detect</param>
        /// <returns></returns>
        public string SetCamera(ACFrequency frequency)
        {
            int number = 50;

            switch (frequency)
            {
            case ACFrequency._50Hz:
                number = 50;
                break;

            case ACFrequency._60Hz:
                number = 60;
                break;

            case ACFrequency.AutoDetect:
                number = 0;
                break;
            }
            RovioResponse response = rovio.Request("SetCamera.cgi?Frequency=" + number.ToString());

            return("");
        }
コード例 #22
0
 /// <summary>
 /// Change the brightness setting of camera's images.
 /// </summary>
 /// <param name="brightness">0 - 6 (The lower the value is, the dimmer the image is)</param>
 /// <returns></returns>
 public void ChangeBrightness(int brightness)
 {
     RovioResponse response = rovio.Request("ChangeBrightness.cgi?Brightness=" + brightness.ToString());
 }
コード例 #23
0
 /// <summary>
 /// Change the frame rate setting of camera's images.
 /// </summary>
 /// <param name="framerate">2 – 32 frame per seconds respectively</param>
 /// <returns></returns>
 public void ChangeFramerate(int framerate)
 {
     RovioResponse response = rovio.Request("ChangeFramerate.cgi?Framerate=" + framerate.ToString());
 }
コード例 #24
0
 /// <summary>
 /// Change the quality setting of camera's images. (only available with MPEG4)
 /// </summary>
 /// <param name="ratio">0 – 2 (representing low, medium and high quality respectively)</param>
 /// <returns></returns>
 public void ChangeCompressRatio(VideoCompression ratio)
 {
     RovioResponse response = rovio.Request("ChangeCompressRatio.cgi?Ratio=" + ratio.ToString());
 }
コード例 #25
0
 /// <summary>
 /// Change the resolution setting of camera's images.
 /// </summary>
 /// <param name="ResType">Camera supports 4 types of resolution:0 - {176, 144}1 - {352, 288}2 - {320, 240} (Default)3 - {640, 480}</param>
 /// <returns></returns>
 public void ChangeResolution(int ResType)
 {
     RovioResponse response = rovio.Request("ChangeResolution.cgi?ResType=" + ResType.ToString());
 }
コード例 #26
0
        /// <summary>
        /// The basic command for acquiring MJPEG.
        /// <remarks>NOT IMPLEMENTED</remarks>
        /// </summary>
        /// <returns></returns>
        public string GetData()
        {
            RovioResponse response = rovio.Request("GetData.cgi");

            return("");
        }
コード例 #27
0
ファイル: RovioStatus.cs プロジェクト: SaintLoong/rovio
        public static RovioStatus Parse(RovioResponse response)
        {
            RovioStatus status = new RovioStatus();

            return status;
        }
コード例 #28
0
ファイル: RovioStatusReport.cs プロジェクト: SaintLoong/rovio
        internal static RovioStatusReport Parse(RovioStatusReport report, RovioResponse dic)
        {
            report.str = dic.ToString();

            report.Location = new RovioLocation(
                short.Parse(dic["x"]),
                short.Parse(dic["y"]),
                double.Parse(dic["theta"]));

            report.parseRoomId(dic["room"]);
            report.parseNavStrength(dic["ss"]);
            //如果信号太弱,将RoomId置为-1。
            if (!report.HasNavSignal)
                report.RoomID = -1;

            report.BeaconSignalStrength = UInt16.Parse(dic["beacon"]);
            report.BeaconPoitionX = Int16.Parse(dic["beacon_x"]);
            report.NextRoomID = int.Parse(dic["next_room"]);
            report.NextRoomSS = UInt16.Parse(dic["next_room_ss"]);

            report.parseNavState(dic["state"]);
            report.ui_status = int.Parse(dic["ui_status"]);
            report.resistance = int.Parse(dic["resistance"]);
            report.sm = int.Parse(dic["sm"]);
            report.WayPointIndex = int.Parse(dic["pp"]);
            report.parseFlags(dic["flags"]);

            report.brightness = byte.Parse(dic["brightness"]);

            report.ResolutionId = int.Parse(dic["resolution"]);
            report.VideoCompression = (VideoCompression)int.Parse(dic["video_compression"]);
            report.frame_rate = int.Parse(dic["frame_rate"]);
            report.Privilege = (UserPrivilege)int.Parse(dic["privilege"]);
            report.AuthenticationRequired = (int.Parse(dic["user_check"]) == 1);// ???? == 0

            //0 (lowest) – 31 (highest)
            report.speaker_volume = double.Parse(dic["speaker_volume"]) / 31.0;
            //0 (lowest) – 31 (highest)
            report.mic_volume = double.Parse(dic["mic_volume"]) / 31.0;
            report.parseWifiStrength(dic["wifi_ss"]);
            // 0 = Not showing the time. 1 = Showing time.
            report.show_time = (int.Parse(dic["show_time"]) == 1);
            report.ddns_state = (DdnsStates)int.Parse(dic["ddns_state"]);
            report.email_state = int.Parse(dic["email_state"]);
            report.parseBatteryStrength(dic["battery"]);
            report.parseCharging(dic["charging"]);
            report.HeadPositionTickCount = int.Parse(dic["head_position"]);
            report.ACFrequency = (ACFrequency)int.Parse(dic["ac_freq"]);

            return report;
        }
コード例 #29
0
 /// <summary>
 /// Stores parameter in the robot’s Flash memory.
 /// </summary>
 /// <param name="index">0 – 19</param>
 /// <param name="value">32bit signed integer</param>
 /// <returns></returns>
 internal void SaveParameter(FlashParameters parameterId, Int32 value)
 {
     RovioResponse response = MovementControl(Commands.SaveParameter,
                                              new RequestItem("index", (int)parameterId),
                                              new RequestItem("value", value));
 }
コード例 #30
0
 /// <summary>
 /// Change the Speaker Volume setting of camera.
 /// </summary>
 /// <param name="SpeakerVolume">[0.0, 1.0]</param>
 /// <returns></returns>
 public void ChangeSpeakerVolume(double volume)
 {
     //Speaker Volume : 0 - 31 (The lower the value is, the lower the speaker volume is)
     int           rawValue = RovioAPI.SetDouble(volume, 0, 31);
     RovioResponse response = rovio.Request("ChangeSpeakerVolume.cgi?SpeakerVolume=" + rawValue);
 }
コード例 #31
0
ファイル: RovioStatusReport.cs プロジェクト: SaintLoong/rovio
 public void Update(RovioResponse dic)
 {
     Parse(this, dic);
 }
コード例 #32
0
        /// <summary>
        /// Clears home location in the robot's Flash memory.
        /// </summary>
        /// <returns></returns>
        public string ResetHomeLocation()
        {
            RovioResponse response = MovementControl(Commands.ResetHomeLocation);

            return("");
        }
コード例 #33
0
        /// <summary>
        /// Returns string version of libNS and NS sensor.
        /// </summary>
        /// <returns></returns>
        public string GetLibNSVersion()
        {
            RovioResponse response = MovementControl(Commands.GetLibNSVersion);

            return(response["version"]);
        }
コード例 #34
0
        /// <summary>
        /// Start recording a path.
        /// </summary>
        /// <returns></returns>
        public string StartRecoding()
        {
            RovioResponse response = MovementControl(Commands.StartRecoding);

            return("");
        }
コード例 #35
0
        /// <summary>
        /// Terminates recording of a path without storing it to flash memory.
        /// </summary>
        /// <returns></returns>
        public string AbortRecording()
        {
            RovioResponse response = MovementControl(Commands.AbortRecording);

            return("");
        }