예제 #1
0
            /// <summary>
            /// Request KinectTracker to find movement
            /// </summary>
            /// <param name="timeOut">Amout of time to wait for a response in milliseconds</param>
            /// <returns>true if movement was found. false otherwise</returns>
            public virtual bool Find(int timeOut)
            {
                // Stores the command to be sent to object finder
                Command cmdFindObjectTop;
                // Stores the response from object finder and the candidate while moving
                Response rspFindObjectTop = null;

                // 1. Prepare the command
                if (!GetResource())
                {
                    return(false);
                }

                cmdFindObjectTop = new Command(sgnFindObject.CommandName, "", CmdMan.AutoId++);

                // 2. Send the object finderGoto command
                CmdMan.Console("\tFinding movement");
                if (!CmdMan.SendAndWait(cmdFindObjectTop, timeOut, out rspFindObjectTop))
                {
                    // 2.1. Cant send socket. Operation canceled.
                    CmdMan.Console("\tCan't send command. Operation canceled");
                    FreeResource();
                    return(false);
                }

                // 3. End of move
                FreeResource();

                // 3.1. Parse human finder response
                return(rspFindObjectTop.Success);
            }
예제 #2
0
            /// <summary>
            /// Request PersonFinder to find specified person
            /// </summary>
            /// <param name="humanName">Name of the person to find</param>
            /// <param name="hFOVorX">When this method returns contains one of the following values:
            /// a) The horizontal fov if the response contains 3 parameters (name and FOVs)
            /// b) The x coordinate of the centroid of the face based on the center of the camera lens if the response contains 4 parameters (name and coords)
            /// c) Double.NaN if no response was received or the response does not contain position data</param>
            /// <param name="vFOVorY">When this method returns contains one of the following values:
            /// a) The vertical fov if the response contains 3 parameters (name and FOVs)
            /// b) The y coordinate of the centroid of the face based on the center of the camera lens if the response contains 4 parameters (name and coords)
            /// c) Double.NaN if no response was received or the response does not contain position data</param>
            /// <param name="z">When this method returns contains one of the following values:
            /// a) The z coordinate of the centroid of the face based on the center of the camera lens if the response contains 4 parameters (name and coords)
            /// b) Double.NaN if no response was received or the response does not contain coordinate position data</param>
            /// <param name="timeOut">Amout of time to wait for a response in milliseconds</param>
            /// <returns>true if specified person was found. false otherwise</returns>
            public virtual bool FindHuman(ref string humanName, out double hFOVorX, out double vFOVorY, out double z, int timeOut)
            {
                // Stores the command to be sent to person finder
                Command cmdFindHuman;
                // Stores the response from person finder and the candidate while moving
                Response rspFindHuman = null;

                hFOVorX = Double.NaN;
                vFOVorY = Double.NaN;
                z       = Double.NaN;

                // 1. Prepare the command
                if (!GetResource())
                {
                    return(false);
                }

                cmdFindHuman = new Command(sgnFindHuman.CommandName, humanName, CmdMan.AutoId++);

                // 2. Send the person finderGoto command
                CmdMan.Console("\tFinding human [" + humanName + "]");
                if (!CmdMan.SendAndWait(cmdFindHuman, timeOut, out rspFindHuman))
                {
                    // 2.1. Cant send socket. Operation canceled.
                    CmdMan.Console("\tCan't send command. Operation canceled");
                    FreeResource();
                    return(false);
                }

                // 3. End of move
                FreeResource();

                // 3.1. Parse human finder response
                if (!rspFindHuman.Success)
                {
                    // 3.2. Failed response
                    CmdMan.Console("\tHuman not found");
                    return(false);
                }

                // 4.0 Recover values from response
                SignatureAnalysisResult result = sgnFindHuman.Analyze(rspFindHuman);

                if (result.Success)
                {
                    result.Update(0, ref humanName);
                    if (result.ParameterCount >= 3)
                    {
                        result.Update(1, ref hFOVorX);
                        result.Update(2, ref vFOVorY);
                    }
                    if (result.ParameterCount >= 4)
                    {
                        result.Update(3, ref z);
                    }
                }

                CmdMan.Console("\tFind human complete");
                return(result.Success);
            }
예제 #3
0
            /// <summary>
            /// Commnds the SpeechRecognizer to load the specified grammar file
            /// </summary>
            /// <param name="grammarFile">The grammar file to load</param>
            /// <returns>true if grammar file was loaded, false otherwise</returns>
            public bool LoadGrammar(string grammarFile)
            {
                // Stores the command to be sent to speech generator
                Command cmdLoadGrammar;
                // Stores the response from speech generator and the candidate while lookingfor
                Response rspLoadGrammar = null;

                // 1. Prepare the command
                if (!GetResource())
                {
                    return(false);
                }

                cmdLoadGrammar = new Command(sgnGrammar.CommandName, grammarFile, CmdMan.AutoId++);

                // 2. Send the status command
                if (!CmdMan.SendAndWait(cmdLoadGrammar, DefaultDelay, out rspLoadGrammar))
                {
                    // 2.1. Cant send socket. Operation canceled.
                    FreeResource();
                    return(false);
                }

                // 3. End of command execution
                FreeResource();

                // 3.2. Parse speech generator response
                if (!rspLoadGrammar.Success)
                {
                    // 3.2. Failed response
                    return(false);
                }
                return(true);
            }
예제 #4
0
            /// <summary>
            /// Request the manipulator aperture pecentage and tilt angle
            /// </summary>
            /// <param name="aperturePercentage">Percentage aperture of the gripper of the manipulator.</param>
            /// <param name="tilt">Tilt angle of the manipulator.</param>
            /// <param name="timeOut">Amout of time to wait for an man response in milliseconds</param>
            /// <returns>true if data fetch was successfully. false otherwise</returns>
            public virtual bool Status(out int aperturePercentage, out double tilt, int timeOut)
            {
                // Stores the command to be sent to man
                Command cmdStatus;
                // Stores the response from man and the candidate while moving
                Response rspStatus = null;
                bool     result;

                aperturePercentage = 0;
                tilt = 0;

                // 1. Prepare the command
                if (!GetResource())
                {
                    return(false);
                }

                string parameters = "";

                cmdStatus = new Command(sgnStatus.CommandName, parameters, CmdMan.AutoId++);

                // 2. Send the manAbsPos command
                CmdMan.Console("\tReading man orientation " + parameters);
                if (!CmdMan.SendAndWait(cmdStatus, timeOut, out rspStatus))
                {
                    // 2.1. Cant send socket. Operation canceled.
                    CmdMan.Console("\tCan't send command. Operation canceled");
                    FreeResource();
                    return(false);
                }

                // 3. End of move
                FreeResource();

                // 3.1. Parse man response
                if (!rspStatus.Success)
                {
                    // 3.2. Failed response
                    CmdMan.Console("\tManipulator did not respond");
                    return(false);
                }

                // 4.0 Recover values from response
                SignatureAnalysisResult saResult = sgnStatus.Analyze(rspStatus);

                result = saResult.Success &&
                         (saResult.ParameterCount == 2) &&
                         (saResult.Update <int>(0, ref aperturePercentage) &
                          saResult.Update <double>(1, ref tilt));
                if (!result)
                {
                    CmdMan.Console("\tInvalid response");
                }
                else
                {
                    CmdMan.Console("\tGet man position complete");
                }
                return(result);
            }
예제 #5
0
            /// <summary>
            /// Request manipulator to move to the specified tilt angle in radians
            /// </summary>
            /// <param name="tilt">The specified tilt angle in radians</param>
            /// <param name="timeOut">Amout of time to wait for an man response in milliseconds</param>
            /// <returns>true if manipulator moved to specified tilt. false otherwise</returns>
            public virtual bool Tilt(ref double tilt, int timeOut)
            {
                // Stores the command to be sent to man
                Command cmdTilt;
                // Stores the response from man and the candidate while moving
                Response rspTilt = null;
                bool     result;

                // 1. Prepare the command
                if (!GetResource())
                {
                    return(false);
                }

                cmdTilt = new Command(sgnTilt.CommandName, tilt.ToString("0.00"), CmdMan.AutoId++);

                // 2. Send the manGoto command
                CmdMan.Console("\tSetting manipulator tilt [" + tilt + "]");
                if (!CmdMan.SendAndWait(cmdTilt, timeOut, out rspTilt))
                {
                    // 2.1. Cant send socket. Operation canceled.
                    CmdMan.Console("\tCan't send command. Operation canceled");
                    FreeResource();
                    return(false);
                }

                // 3. End of move
                FreeResource();

                // 3.1. Parse manipulator response
                if (!rspTilt.Success)
                {
                    // 3.2. Failed response
                    CmdMan.Console("\tManipulator did not move");
                    return(false);
                }

                // 4.0 Recover values from response
                SignatureAnalysisResult saResult = sgnTilt.Analyze(rspTilt);

                result = saResult.Success &&
                         (saResult.ParameterCount == 1) &&
                         (saResult.Update <double>(0, ref tilt));
                if (!result)
                {
                    CmdMan.Console("\tInvalid response");
                }
                else
                {
                    CmdMan.Console("\tSet manipulator tilt complete");
                }
                return(result);
            }
예제 #6
0
            /// <summary>
            /// Request KinectTracker for the centroid of the skeleton
            /// </summary>
            /// <param name="centroidX">X coordinate of the centroid of the Skeleton</param>
            /// <param name="centroidY">Y coordinate of the centroid of the Skeleton</param>
            /// <param name="centroidZ">Z coordinate of the centroid of the Skeleton</param>
            /// <param name="timeOut">Amout of time to wait for a response in milliseconds</param>
            /// <returns>true if centroid was retrieved successfully, false otherwise</returns>
            public virtual bool LocateSkeleton(out double centroidX, out double centroidY, out double centroidZ, int timeOut)
            {
                // Stores the command to be sent to object finder
                Command cmdLocate;
                // Stores the response from object finder and the candidate while moving
                Response rspLocate = null;

                centroidX = 0;
                centroidY = 0;
                centroidZ = 0;

                // 1. Prepare the command
                if (!GetResource())
                {
                    return(false);
                }

                cmdLocate = new Command(sgnLocate.CommandName, "skeleton", CmdMan.AutoId++);

                // 2. Send the object finderGoto command
                CmdMan.Console("\tLocating skeleton");
                if (!CmdMan.SendAndWait(cmdLocate, timeOut, out rspLocate))
                {
                    // 2.1. Cant send socket. Operation canceled.
                    CmdMan.Console("\tCan't send command. Operation canceled");
                    FreeResource();
                    return(false);
                }

                // 3. End of move
                FreeResource();

                // 3.1. Parse human finder response
                if (!rspLocate.Success)
                {
                    // 3.2. Failed response
                    CmdMan.Console("\tSkeleton centroid not found");
                    return(false);
                }

                // 4.0 Recover values from response
                SignatureAnalysisResult saResult = sgnCalibrate.Analyze(rspLocate);

                if (saResult.Success && (saResult.ParameterCount == 3))
                {
                    saResult.Update <double>(0, ref centroidX);
                    saResult.Update <double>(1, ref centroidY);
                    saResult.Update <double>(2, ref centroidZ);
                }

                CmdMan.Console("\tLocate Skeleton complete!");
                return(true);
            }
예제 #7
0
            /// <summary>
            /// Request robot base to move to the specified region
            /// </summary>
            /// <param name="x">The x coordinate position of the robot in the map</param>
            /// <param name="y">The y coordinate position of the robot in the map</param>
            /// <param name="angle">The angle the robot must turn on arrival</param>
            /// <param name="timeOut">Amout of time to wait for an arm response in milliseconds</param>
            /// <returns>true if robot moved to the specified location. false otherwise</returns>
            public bool Position(out double x, out double y, out double angle, int timeOut)
            {
                // Stores the command to be sent to robot base
                Command cmdPosition;
                // Stores the response from robot base and the candidate while lookingfor
                Response rspPosition = null;

                x     = 0;
                y     = 0;
                angle = 0;

                // 1. Prepare the command
                if (!GetResource())
                {
                    return(false);
                }
                cmdPosition = new Command(sgnPosition.CommandName, "", CmdMan.AutoId++);

                // 2. Send the lookat command
                CmdMan.Console("\tGeting robot position " + cmdPosition.StringToSend);
                if (!CmdMan.SendAndWait(cmdPosition, timeOut, out rspPosition))
                {
                    // 2.1. Cant send socket. Operation canceled.
                    CmdMan.Console("\tCan't send command. Operation canceled");
                    FreeResource();
                    return(false);
                }

                // 3. End of move
                FreeResource();

                // 3.2. Parse base response
                if (!rspPosition.Success)
                {
                    // 3.2. Failed response
                    CmdMan.Console("\tCan not get robot position");
                    return(false);
                }

                // 4.0 Recover values from response
                SignatureAnalysisResult saResult = sgnPosition.Analyze(rspPosition);

                if (saResult.Success && saResult.ParameterCount >= 3)
                {
                    saResult.Update <double>(0, ref x);
                    saResult.Update <double>(1, ref y);
                    saResult.Update <double>(2, ref angle);
                }

                CmdMan.Console("\tRobot Position [" + rspPosition.Parameters + "]");
                return(true);
            }
예제 #8
0
            /// <summary>
            /// Request robot base to move to the specified region
            /// </summary>
            /// <param name="x">The x coordinate position of the robot in the map</param>
            /// <param name="y">The y coordinate position of the robot in the map</param>
            /// <param name="angle">The angle the robot must turn on arrival</param>
            /// <param name="timeOut">Amout of time to wait for an arm response in milliseconds</param>
            /// <returns>true if robot moved to the specified location. false otherwise</returns>
            public bool GoToXY(ref double x, ref double y, ref double angle, int timeOut)
            {
                // Stores the command to be sent to robot base
                Command cmdGoToXY;
                // Stores the response from robot base and the candidate while lookingfor
                Response rspGoToXY = null;

                // 1. Prepare the command
                if (!GetResource())
                {
                    return(false);
                }
                string parameters = "xy " + x.ToString("0.00") + " " + y.ToString("0.00") + " " + angle.ToString("0.00");

                cmdGoToXY = new Command(sgnGoTo.CommandName, parameters, CmdMan.AutoId++);

                // 2. Send the lookat command
                CmdMan.Console("\tMoving base to region " + cmdGoToXY.StringToSend);
                if (!CmdMan.SendAndWait(cmdGoToXY, timeOut, out rspGoToXY))
                {
                    // 2.1. Cant send socket. Operation canceled.
                    CmdMan.Console("\tCan't send command. Operation canceled");
                    FreeResource();
                    return(false);
                }

                // 3. End of move
                FreeResource();

                // 3.2. Parse base response
                if (!rspGoToXY.Success)
                {
                    // 3.2. Failed response
                    CmdMan.Console("\tRobot's base did not move");
                    return(false);
                }

                // 4.0 Recover values from response
                SignatureAnalysisResult saResult = sgnMove.Analyze(rspGoToXY);

                if (saResult.Success)
                {
                    saResult.Update <double>(1, ref x);
                    saResult.Update <double>(2, ref y);
                    saResult.Update <double>(3, ref angle);
                }

                CmdMan.Console("\tMove robot complete to region [" + rspGoToXY.Parameters + "]");
                return(true);
            }
예제 #9
0
            /// <summary>
            /// Request head to move the specified orientation
            /// </summary>
            /// <param name="neck">The neck angle of the face</param>
            /// <param name="pan">The pan  of the face</param>
            /// <param name="tilt">The tilt of the face</param>
            /// <param name="timeOut">Amout of time to wait for a head response in milliseconds</param>
            /// <returns>true if head moved to the specified location. false otherwise</returns>
            public bool LookAt(ref double neck, ref double pan, ref double tilt, int timeOut)
            {
                // Stores the command to be sent to head
                Command cmdLookAt;
                // Stores the response from head and the candidate while lookingfor
                Response rspLookAt = null;

                // 1. Prepare the command
                if (!GetResource())
                {
                    return(false);
                }
                string parameters = neck.ToString("0.00") + " " + pan.ToString("0.00") + " " + tilt.ToString("0.00");

                cmdLookAt = new Command(sgnHeadLookAt.CommandName, parameters, CmdMan.AutoId++);

                // 2. Send the lookat command
                CmdMan.Console("\tMoving head to position " + parameters);
                if (!CmdMan.SendAndWait(cmdLookAt, timeOut, out rspLookAt))
                {
                    // 2.1. Cant send socket. Operation canceled.
                    CmdMan.Console("\tCan't send command. Operation canceled");
                    FreeResource();
                    return(false);
                }

                // 3. End of move
                FreeResource();

                // 3.1. Parse head response
                if (!rspLookAt.Success)
                {
                    // 3.2. Failed response
                    CmdMan.Console("\tHead did not move");
                    return(false);
                }

                // 4.0 Recover values from response
                SignatureAnalysisResult saResult = sgnHeadLookAt.Analyze(rspLookAt);

                if (saResult.Success && (saResult.ParameterCount == 3))
                {
                    saResult.Update <double>(0, ref neck);
                    saResult.Update <double>(1, ref pan);
                    saResult.Update <double>(2, ref tilt);
                }

                CmdMan.Console("\tMoving head to position complete");
                return(true);
            }
예제 #10
0
            /// <summary>
            /// Request head to show the specified expression
            /// </summary>
            /// <param name="expression">The expression to be shown by the face</param>
            /// <param name="showTime">The amoun of time in seconds the expression will be shown</param>
            /// <param name="timeOut">Amout of time to wait for a head response in milliseconds</param>
            /// <returns>true if head showed the specified expression. false otherwise</returns>
            public bool Show(string expression, double showTime, int timeOut)
            {
                // Stores the command to be sent to head
                Command cmdShow;
                // Stores the response from head and the candidate while lookingfor
                Response rspShow = null;

                // 1. Prepare the command
                if (!GetResource())
                {
                    return(false);
                }
                string parameters = expression + " " + showTime.ToString("0.00");

                cmdShow = new Command(sgnHeadShow.CommandName, parameters, CmdMan.AutoId++);

                // 2. Send the show command
                CmdMan.Console("\tShowing head expression " + parameters);
                if (!CmdMan.SendAndWait(cmdShow, timeOut, out rspShow))
                {
                    // 2.1. Cant send socket. Operation canceled.
                    CmdMan.Console("\tCan't send command. Operation canceled");
                    FreeResource();
                    return(false);
                }

                // 3. End of move
                FreeResource();

                // 3.1. Parse head response
                if (!rspShow.Success)
                {
                    // 3.2. Failed response
                    CmdMan.Console("\tHead did not move");
                    return(false);
                }

                // 4.0 Recover values from response
                SignatureAnalysisResult saResult = sgnHeadLookAt.Analyze(rspShow);

                if (saResult.Success && (saResult.ParameterCount == 2))
                {
                    saResult.Update <string>(0, ref expression);
                    saResult.Update <double>(1, ref showTime);
                }

                CmdMan.Console("\tShow expression complete");
                return(true);
            }
예제 #11
0
            /// <summary>
            /// Request KinectTracker to find specified object
            /// </summary>
            /// <param name="skeletonId">Id of the skeleton calibrated</param>
            /// <param name="timeOut">Amout of time to wait for a response in milliseconds</param>
            /// <returns>true if calibration was successfull, false otherwise</returns>
            public virtual bool Calibrate(out int skeletonId, int timeOut)
            {
                // Stores the command to be sent to object finder
                Command cmdCalibrate;
                // Stores the response from object finder and the candidate while moving
                Response rspCalibrate = null;

                skeletonId = -1;

                // 1. Prepare the command
                if (!GetResource())
                {
                    return(false);
                }

                cmdCalibrate = new Command(sgnCalibrate.CommandName, "", CmdMan.AutoId++);

                // 2. Send the object finderGoto command
                CmdMan.Console("\tCalibrating skeleton [" + skeletonId + "]");
                if (!CmdMan.SendAndWait(cmdCalibrate, timeOut, out rspCalibrate))
                {
                    // 2.1. Cant send socket. Operation canceled.
                    CmdMan.Console("\tCan't send command. Operation canceled");
                    FreeResource();
                    return(false);
                }

                // 3. End of move
                FreeResource();

                // 3.1. Parse human finder response
                if (!rspCalibrate.Success)
                {
                    // 3.2. Failed response
                    CmdMan.Console("\tCalibration failed");
                    return(false);
                }

                // 4.0 Recover values from response
                SignatureAnalysisResult saResult = sgnCalibrate.Analyze(rspCalibrate);

                if (saResult.Success && (saResult.ParameterCount == 1))
                {
                    saResult.Update <int>(0, ref skeletonId);
                }

                CmdMan.Console("\tCalibrate complete");
                return(true);
            }
예제 #12
0
            /// <summary>
            /// Commnds the SpeechRecognizer to enable, disable or get the status of the the speech recognition
            /// </summary>
            /// <param name="stat">Parameter to include in de sprec_status command.</param>
            /// <returns>true if command executed successfully. false otherwise</returns>
            private bool Status(ref string stat)
            {
                // Stores the command to be sent to speech generator
                Command cmdStatus;
                // Stores the response from speech generator and the candidate while lookingfor
                Response rspStatus = null;

                // 1. Prepare the command
                if (!GetResource())
                {
                    return(false);
                }

                if ((stat != "enable") && (stat != "disable") && (stat != "get"))
                {
                    return(false);
                }

                cmdStatus = new Command(sgnStatus.CommandName, stat, CmdMan.AutoId++);

                // 2. Send the status command
                if (!CmdMan.SendAndWait(cmdStatus, 300, out rspStatus))
                {
                    // 2.1. Cant send socket. Operation canceled.
                    FreeResource();
                    return(false);
                }

                // 3. End of command execution
                FreeResource();

                // 3.2. Parse speech generator response
                if (!rspStatus.Success)
                {
                    // 3.2. Failed response
                    return(false);
                }

                // 4.0 Recover values from response
                stat = rspStatus.Parameters;

                return(true);
            }
예제 #13
0
            /// <summary>
            /// Request speech generator to use the specified voice
            /// </summary>
            /// <param name="voiceName">The name of the voice to set. Use an empty string to get the actual voice.</param>
            /// <param name="timeOut">Amout of time to wait for an speech generator response in milliseconds</param>
            /// <returns>true if Speech Generator changed the voice successfully. false otherwise</returns>
            public bool Voice(ref string voiceName, int timeOut)
            {
                // Stores the command to be sent to speech generator
                Command cmdVoice;
                // Stores the response from speech generator and the candidate while lookingfor
                Response rspVoice = null;

                // 1. Prepare the command
                if (!GetResource())
                {
                    return(false);
                }

                cmdVoice = new Command(sgnVoice.CommandName, voiceName, CmdMan.AutoId++);

                // 2. Send the say command
                CmdMan.Console("\tSet voice: " + cmdVoice.StringToSend);
                if (!CmdMan.SendAndWait(cmdVoice, timeOut, out rspVoice))
                {
                    // 2.1. Cant send socket. Operation canceled.
                    CmdMan.Console("\tCan't send command. Operation canceled");
                    FreeResource();
                    return(false);
                }

                // 3. End of move
                FreeResource();

                // 3.2. Parse speech generator response
                if (!rspVoice.Success)
                {
                    // 3.2. Failed response
                    CmdMan.Console("\tCannot change selected voice");
                    return(false);
                }

                // 4.0 Recover values from response
                voiceName = rspVoice.Parameters;

                CmdMan.Console("\tSet voice complete! [" + rspVoice.Parameters + "]");
                return(true);
            }
예제 #14
0
            /// <summary>
            /// Sets the position of the robot
            /// </summary>
            /// <param name="x">The x coordinate position of the robot in the map</param>
            /// <param name="y">The y coordinate position of the robot in the map</param>
            /// <param name="angle">The orientation of the robot in the map</param>
            /// <param name="timeOut">Amout of time to wait for an arm response in milliseconds</param>
            /// <returns>true if robot moved to the specified location. false otherwise</returns>
            public bool Position(double x, double y, double angle, int timeOut)
            {
                // Stores the command to be sent to robot base
                Command cmdPosition;
                // Stores the response from robot base and the candidate while lookingfor
                Response rspPosition = null;

                // 1. Prepare the command
                if (!GetResource())
                {
                    return(false);
                }
                string parameters = x.ToString("0.00") + " " + y.ToString("0.00") + " " + angle.ToString("0.00");

                cmdPosition = new Command(sgnPosition.CommandName, parameters, CmdMan.AutoId++);

                // 2. Send the lookat command
                CmdMan.Console("\tSet robot position " + cmdPosition.StringToSend);
                if (!CmdMan.SendAndWait(cmdPosition, timeOut, out rspPosition))
                {
                    // 2.1. Cant send socket. Operation canceled.
                    CmdMan.Console("\tCan't send command. Operation canceled");
                    FreeResource();
                    return(false);
                }

                // 3. End of move
                FreeResource();

                // 3.2. Parse base response
                if (!rspPosition.Success)
                {
                    // 3.2. Failed response
                    CmdMan.Console("\tFailed to set robot position");
                    return(false);
                }

                CmdMan.Console("\tSet robot position complete [" + rspPosition.Parameters + "]");
                return(true);
            }
예제 #15
0
            /// <summary>
            /// Request robot base to move to the specified region
            /// </summary>
            /// <param name="region">The name of the destination region</param>
            /// <param name="timeOut">Amout of time to wait for an arm response in milliseconds</param>
            /// <returns>true if robot moved to the specified location. false otherwise</returns>
            public bool GoToRegion(string region, int timeOut)
            {
                // Stores the command to be sent to robot base
                Command cmdGoToRegion;
                // Stores the response from robot base and the candidate while lookingfor
                Response rspGoToRegion = null;

                // 1. Prepare the command
                if (!GetResource())
                {
                    return(false);
                }
                string parameters = "region " + region;

                cmdGoToRegion = new Command(sgnGoTo.CommandName, parameters, CmdMan.AutoId++);

                // 2. Send the lookat command
                CmdMan.Console("\tMoving base to region " + cmdGoToRegion.StringToSend);
                if (!CmdMan.SendAndWait(cmdGoToRegion, timeOut, out rspGoToRegion))
                {
                    // 2.1. Cant send socket. Operation canceled.
                    CmdMan.Console("\tCan't send command. Operation canceled");
                    FreeResource();
                    return(false);
                }

                // 3. End of move
                FreeResource();

                // 3.2. Parse base response
                if (!rspGoToRegion.Success)
                {
                    // 3.2. Failed response
                    CmdMan.Console("\tRobot's base did not move");
                    return(false);
                }

                CmdMan.Console("\tMove robot complete to region [" + rspGoToRegion.Parameters + "]");
                return(true);
            }
예제 #16
0
            /// <summary>
            /// Request speech generator to move to shut up
            /// </summary>
            /// <returns>true if Speech Generator stopped the speech synthesis. false otherwise</returns>
            public bool ShutUp()
            {
                // Stores the command to be sent to speech generator
                Command cmdShutUp;
                // Stores the response from speech generator and the candidate while lookingfor
                Response rspShutUp = null;

                // 1. Prepare the command
                if (!GetResource())
                {
                    return(false);
                }

                cmdShutUp = new Command(sgnShutUp.CommandName, "", CmdMan.AutoId++);

                // 2. Send the say command
                CmdMan.Console("\tShutting up: " + cmdShutUp.StringToSend);
                if (!CmdMan.SendAndWait(cmdShutUp, 300, out rspShutUp))
                {
                    // 2.1. Cant send socket. Operation canceled.
                    CmdMan.Console("\tCan't send command. Operation canceled");
                    FreeResource();
                    return(false);
                }

                // 3. End of move
                FreeResource();

                // 3.2. Parse speech generator response
                if (!rspShutUp.Success)
                {
                    // 3.2. Failed response
                    CmdMan.Console("\tRobot's speech generator did not respond");
                    return(false);
                }

                CmdMan.Console("\tShutUp complete");
                return(true);
            }
예제 #17
0
            /// <summary>
            /// Request speech generator to move to synthetize the text contained in the specified textfile
            /// </summary>
            /// <param name="file">The file which contains the text to be synthetized by the Speech Generator</param>
            /// <param name="timeOut">Amout of time to wait for an speech generator response in milliseconds</param>
            /// <returns>true if Speech Generator synthetized the specified text. false otherwise</returns>
            public bool Read(string file, int timeOut)
            {
                // Stores the command to be sent to speech generator
                Command cmdRead;
                // Stores the response from speech generator and the candidate while lookingfor
                Response rspRead = null;

                // 1. Prepare the command
                if (!GetResource())
                {
                    return(false);
                }

                cmdRead = new Command(sgnRead.CommandName, file, CmdMan.AutoId++);

                // 2. Send the say command
                CmdMan.Console("\tReading: " + cmdRead.StringToSend);
                if (!CmdMan.SendAndWait(cmdRead, timeOut, out rspRead))
                {
                    // 2.1. Cant send socket. Operation canceled.
                    CmdMan.Console("\tCan't send command. Operation canceled");
                    FreeResource();
                    return(false);
                }

                // 3. End of move
                FreeResource();

                // 3.2. Parse speech generator response
                if (!rspRead.Success)
                {
                    // 3.2. Failed response
                    CmdMan.Console("\tRobot's speech generator did not spoke");
                    return(false);
                }

                CmdMan.Console("\tReading complete [" + rspRead.Parameters + "]");
                return(true);
            }
예제 #18
0
            /// <summary>
            /// Request PersonFinder remember (learn) specified person
            /// </summary>
            /// <param name="humanName">Name of the person to remember</param>
            /// <param name="timeOut">Amout of time to wait for a response in milliseconds</param>
            /// <returns>true if specified person was trained. false otherwise</returns>
            public virtual bool RememberHuman(string humanName, int timeOut)
            {
                // Stores the command to be sent to person finder
                Command cmdRememberHuman;
                // Stores the response from person finder and the candidate while moving
                Response rspRememberHuman = null;

                // 1. Prepare the command
                if (!GetResource())
                {
                    return(false);
                }

                cmdRememberHuman = new Command(sgnRememberHuman.CommandName, humanName, CmdMan.AutoId++);

                // 2. Send the person finderGoto command
                CmdMan.Console("\tTrying to remember human [" + humanName + "]");
                if (!CmdMan.SendAndWait(cmdRememberHuman, timeOut, out rspRememberHuman))
                {
                    // 2.1. Cant send socket. Operation canceled.
                    CmdMan.Console("\tCan't send command. Operation canceled");
                    FreeResource();
                    return(false);
                }

                // 3. End of move
                FreeResource();

                // 3.1. Parse human finder response
                if (!rspRememberHuman.Success)
                {
                    // 3.2. Failed response
                    CmdMan.Console("\tHuman not found");
                    return(false);
                }

                CmdMan.Console("\tRemember human complete");
                return(true);
            }
예제 #19
0
            /// <summary>
            /// Request KinectTracker train (learn) specified object
            /// </summary>
            /// <param name="objectName">Name of the object to train</param>
            /// <param name="timeOut">Amout of time to wait for a response in milliseconds</param>
            /// <returns>true if specified object was trained. false otherwise</returns>
            public virtual bool Train(string objectName, int timeOut)
            {
                // Stores the command to be sent to object finder
                Command cmdTrainObjectTop;
                // Stores the response from object finder and the candidate while moving
                Response rspTrainObjectTop = null;

                // 1. Prepare the command
                if (!GetResource())
                {
                    return(false);
                }

                cmdTrainObjectTop = new Command(sgnTrainObject.CommandName, objectName, CmdMan.AutoId++);

                // 2. Send the object finderGoto command
                CmdMan.Console("\tTrying to train object [" + objectName + "]");
                if (!CmdMan.SendAndWait(cmdTrainObjectTop, timeOut, out rspTrainObjectTop))
                {
                    // 2.1. Cant send socket. Operation canceled.
                    CmdMan.Console("\tCan't send command. Operation canceled");
                    FreeResource();
                    return(false);
                }

                // 3. End of move
                FreeResource();

                // 3.1. Parse human finder response
                if (!rspTrainObjectTop.Success)
                {
                    // 3.2. Failed response
                    CmdMan.Console("\tObject not found");
                    return(false);
                }
                CmdMan.Console("\tTrain object complete");
                return(true);
            }
예제 #20
0
            /// <summary>
            /// Request ObjectFinder to find specified object with the camera located on Bottom
            /// </summary>
            /// <param name="objectName">Name of the object to find</param>
            /// <param name="x">When this method returns contains one of this values:
            /// a) The x-coordinate of the object position if the response contains three position values
            /// b) The location of the object respect to the HFOV of the camera (angle measured in radians) if the response contains two position values.
            /// c) Double.NaN if the response does not contains position values
            /// </param>
            /// <param name="y">When this method returns contains one of this values:
            /// a) The y-coordinate of the object position if the response contains three position values
            /// b) The location of the object respect to the VFOV of the camera (angle measured in radians) if the response contains two position values.
            /// c) Double.NaN if the response does not contains position values
            /// </param>
            /// <param name="z">When this method returns contains one of this values:
            /// a) The z-coordinate of the object position if the response contains three position values
            /// b) Double.NaN
            /// </param>
            /// <param name="timeOut">Amout of time to wait for a response in milliseconds</param>
            /// <returns>true if specified object was found. false otherwise</returns>
            public virtual bool FindObjectBottom(ref string objectName, out double x, out double y, out double z, int timeOut)
            {
                // Stores the command to be sent to object finder
                Command cmdFindObjectBottom;
                // Stores the response from object finder and the candidate while moving
                Response rspFindObjectBottom = null;

                x = Double.NaN;
                y = Double.NaN;
                z = Double.NaN;

                // 1. Prepare the command
                if (!GetResource())
                {
                    return(false);
                }

                cmdFindObjectBottom = new Command(sgnFindObjectBottom.CommandName, objectName, CmdMan.AutoId++);

                // 2. Send the object finderGoto command
                CmdMan.Console("\tFinding object [" + objectName + "]");
                if (!CmdMan.SendAndWait(cmdFindObjectBottom, timeOut, out rspFindObjectBottom))
                {
                    // 2.1. Cant send socket. Operation canceled.
                    CmdMan.Console("\tCan't send command. Operation canceled");
                    FreeResource();
                    return(false);
                }

                // 3. End of move
                FreeResource();

                // 3.1. Parse head response
                if (!rspFindObjectBottom.Success)
                {
                    // 3.2. Failed response
                    CmdMan.Console("\tHuman not found");
                    return(false);
                }

                // 4.0 Recover values from response
                SignatureAnalysisResult result = sgnFindObjectBottom.Analyze(rspFindObjectBottom);

                if (result.Success)
                {
                    result.Update <string>(0, ref objectName);
                    if (result.ParameterCount == 4)
                    {
                        result.Update <double>(1, ref x);
                        result.Update <double>(2, ref y);
                        result.Update <double>(3, ref z);
                    }
                    else if (result.ParameterCount == 3)
                    {
                        result.Update <double>(1, ref x);
                        result.Update <double>(2, ref y);
                        z = Double.NaN;
                    }
                }

                CmdMan.Console("\tFind object complete");
                return(true);
            }
예제 #21
0
            /// <summary>
            /// Request robot base the array of obstacles detected
            /// </summary>
            /// <param name="treshold">The treshold for obstacle detection</param>
            /// <param name="obstacles">An array containing the distances and angles of the detected obstacles</param>
            /// <param name="timeOut">Amout of time to wait for an arm response in milliseconds</param>
            /// <returns>true if robot moved to the specified location. false otherwise</returns>
            public bool Obstacle(double treshold, out Vector2[] obstacles, int timeOut)
            {
                // Stores the command to be sent to robot base
                Command cmdObstacle;
                // Stores the response from robot base and the candidate while lookingfor
                Response rspObstacle = null;

                obstacles = new Vector2[0];

                // 1. Prepare the command
                if (!GetResource())
                {
                    return(false);
                }
                string parameters = treshold.ToString("0.00");

                cmdObstacle = new Command(sgnMove.CommandName, parameters, CmdMan.AutoId++);

                // 2. Send the lookat command
                CmdMan.Console("\tChecking for obstacles " + cmdObstacle.StringToSend);
                if (!CmdMan.SendAndWait(cmdObstacle, timeOut, out rspObstacle))
                {
                    // 2.1. Cant send socket. Operation canceled.
                    CmdMan.Console("\tCan't send command. Operation canceled");
                    FreeResource();
                    return(false);
                }

                // 3. End of move
                FreeResource();

                // 3.2. Parse base response
                if (!rspObstacle.Success)
                {
                    // 3.2. Failed response
                    CmdMan.Console("\tCheck for obstacles failed");
                    return(false);
                }

                // Get obstacles
                MatchCollection mc = rxObstacles.Matches(rspObstacle.Parameters);

                if (mc.Count > 0)
                {
                    int i = 0;
                    obstacles = new Vector2[mc.Count];
                    foreach (Match m in mc)
                    {
                        if (!m.Success)
                        {
                            obstacles[i++] = new Vector2();
                            continue;
                        }
                        obstacles[i++] = new Vector2(
                            Double.Parse(m.Result("${r}")),
                            Double.Parse(m.Result("${t}")));
                    }
                }

                CmdMan.Console("\tCheck for obstacles complete [" + obstacles.Length + "]");
                return(true);
            }
예제 #22
0
            /// <summary>
            /// Request manipulator to open the grip
            /// </summary>
            /// <param name="percentage">Percentage aperture of the grip</param>
            /// <param name="timeOut">Amout of time to wait for an man response in milliseconds</param>
            /// <returns>true if manipulator opend the grip. false otherwise</returns>
            public virtual bool OpenGrip(ref int percentage, int timeOut)
            {
                // Stores the command to be sent to man
                Command cmdOpenGrip;
                // Stores the response from man and the candidate while moving
                Response rspOpenGrip = null;
                bool     result;

                // 1. Prepare the command
                if (!GetResource())
                {
                    return(false);
                }

                if ((percentage >= 0) || (percentage <= 100))
                {
                    cmdOpenGrip = new Command(sgnOpenGrip.CommandName, percentage.ToString(), CmdMan.AutoId++);
                }
                else
                {
                    cmdOpenGrip = new Command(sgnOpenGrip.CommandName, "", CmdMan.AutoId++);
                    percentage  = 50;
                }

                // 2. Send the manOpenGrip command
                CmdMan.Console("\tClosing manipulator grip to [" + percentage.ToString() + "%]");
                if (!CmdMan.SendAndWait(cmdOpenGrip, timeOut, out rspOpenGrip))
                {
                    // 2.1. Cant send socket. Operation canceled.
                    CmdMan.Console("\tCan't send command. Operation canceled");
                    FreeResource();
                    return(false);
                }

                // 3. End of move
                FreeResource();

                // 3.1. Parse manipulator response
                if (!rspOpenGrip.Success)
                {
                    // 3.2. Failed response
                    CmdMan.Console("\tManipulator did not move");
                    return(false);
                }

                // 4.0 Recover values from response
                SignatureAnalysisResult saResult = sgnOpenGrip.Analyze(rspOpenGrip);

                result = saResult.Success &&
                         (saResult.ParameterCount == 1) &&
                         (saResult.Update <int>(0, ref percentage));
                if (!result)
                {
                    CmdMan.Console("\tInvalid response");
                }
                else
                {
                    CmdMan.Console("\tOpen manipulator grip complete");
                }
                return(result);
            }