コード例 #1
0
 /// <summary>
 /// Constructor
 /// </summary>
 /// <param name="connection">The robot connection object</param>
 public RobotSynchronization(NaoConnectionHelper connection)
     : base(connection)
 {
     // initialize members
     _speechRecognition = new SpeechRecognition(connection.IP, connection.Port);
     _speechRecognition.WordRecognized += _speechRecognition_WordRecognized;
 }
コード例 #2
0
        public FindNaoMarkBackup(int markID, NaoConnectionHelper connection,
                                 float rotationAmount             = DEFAULT_ROTATION_AMOUNT,
                                 float maxRotation                = DEFAULT_MAX_ROTATION,
                                 float headPitchStepAmount        = DEFAULT_HEAD_PITCH_STEP_AMOUNT,
                                 float headYawStepAmount          = DEFAULT_HEAD_YAW_STEP_AMOUNT,
                                 float maxHeadYaw                 = DEFAULT_MAX_HEAD_YAW,
                                 LookDirection startLookDirection = LookDirection.Left)
        {
            if (!connection.TestConnection(string.Empty))
            {
                throw new ArgumentException("Could not connect to the robot!");
            }

            this._connection         = connection;
            this.RotationAmount      = rotationAmount;
            this.MaxRotation         = maxRotation;
            this.HeadPitchStepAmount = headPitchStepAmount;
            this.MarkID             = markID;
            this.HeadYawStepAmount  = headYawStepAmount;
            this.MaxHeadYaw         = maxHeadYaw;
            this.StartLookDirection = startLookDirection;

            // initialize background worker
            _findMarkWorker         = new BackgroundWorker();
            _findMarkWorker.DoWork += new DoWorkEventHandler(_findMarkWorker_DoWork);
            _findMarkWorker.WorkerSupportsCancellation = true;
            _findMarkWorker.RunWorkerCompleted        += new RunWorkerCompletedEventHandler(_findMarkWorker_RunWorkerCompleted);
        }
コード例 #3
0
 public NaoCoopRobotBackup(string ip, int port)
 {
     this._connection = new NaoConnectionHelper(ip, port);
     if (this._connection == null || !this._connection.TestConnection())
     {
         throw new Exception("Could not connect to the Robot.");
     }
 }
コード例 #4
0
 /// <summary>
 /// Disposes the current object
 /// </summary>
 public void Dispose()
 {
     // dispose the robot
     _connection = null;
     _commandExecutionEngine.Dispose();
     _stateMachine.Stop();
     _stateMachine = null;
 }
コード例 #5
0
        public ExecuterBase(NaoConnectionHelper connection)
        {
            /*
             * if (connection==null || !connection.TestConnection(string.Empty))
             * {
             *  throw new ArgumentException("Could not connect to the robot!");
             * }
             */

            this._connection = connection;
        }
コード例 #6
0
ファイル: WalkToNaoMark.cs プロジェクト: rurdea/NaoCoopApp
        /// <summary>
        /// Constructor
        /// </summary>
        /// <param name="connection">Robot connection</param>
        /// <param name="markInfo">Checkpoint mark information</param>
        /// <param name="startLookDirection">Start look direction</param>
        public WalkToNaoMark(NaoConnectionHelper connection, WalkToLandMarkInfo markInfo,
                             FindNaoMark.LookDirection startLookDirection = FindNaoMark.LookDirection.Left)
        {
            this.MarkInfo               = markInfo;
            this.StartLookDirection     = startLookDirection;
            this._robotConnectionHelper = connection;

            if (!_robotConnectionHelper.TestConnection(string.Empty))
            {
                throw new ArgumentException("Could not connect to the robot!");
            }

            _walkWorker.DoWork += new DoWorkEventHandler(_walkWorker_DoWork);
            _walkWorker.WorkerSupportsCancellation = true;
            _walkWorker.RunWorkerCompleted        += new RunWorkerCompletedEventHandler(_walkWorker_RunWorkerCompleted);
        }
コード例 #7
0
 /// <summary>
 /// Disposes the specified command
 /// </summary>
 public void Dispose()
 {
     if (_robotSynch != null)
     {
         _robotSynch.Dispose();
     }
     _connection = null;
     if (_objectHandlingExecuter != null)
     {
         _objectHandlingExecuter.Dispose();
     }
     if (_walkToNaoMark != null)
     {
         _walkToNaoMark.Dispose();
     }
 }
コード例 #8
0
        /// <summary>
        /// Default constructor
        /// </summary>
        /// <param name="ip">The robot ip</param>
        /// <param name="port">The robot port</param>
        /// <param name="markInfo">The checkpoint's mark information</param>
        /// <param name="grabLocation">The grab location information</param>
        /// <param name="logger">The logger</param>
        public NaoCoopRobot(string ip, int port, WalkToLandMarkInfo markInfo, GrabLocationInfo grabLocation, ILog logger)
        {
            this._logger           = logger;
            this._connection       = new NaoConnectionHelper(ip, port);
            this._markInfo         = markInfo;
            this._grabLocationInfo = grabLocation;

            /*
             * if (this._connection == null || !this._connection.TestConnection())
             * {
             *  throw new Exception("Could not connect to the Robot.");
             * }
             */
            this._objectHandlingExecuter = new ObjectHandlingExecuter(_connection);
            this._robotSynch             = new RobotSynchronization(_connection);
            this.Initialize();
        }
コード例 #9
0
        /// <summary>
        /// Disposes current object
        /// </summary>
        public void Dispose()
        {
            if (_worker.IsBusy)
            {
                _worker.CancelAsync();
            }
            _worker.Dispose();

            try
            {
                // make sure we unsubribe to speech recognition proxy
                using (var speechRecognitionProxy = _connection.GetProxy <SpeechRecognitionProxy>())
                {
                    speechRecognitionProxy.unsubscribe(SUBSCRIBER_NAME);
                }
            }
            catch {}
            _connection = null;
        }
コード例 #10
0
        /// <summary>
        /// Constructor
        /// </summary>
        /// <param name="ip">the ip of the robot</param>
        /// <param name="port">the port of the robot</param>
        /// <param name="logger">applicatoin logger</param>
        /// <param name="id">robot id</param>
        public NaoCoopRobot(string ip, int port, ILog logger, Guid?id = null)
        {
            _logger                 = logger;
            _connection             = new NaoConnectionHelper(ip, port);
            _commandExecutionEngine = new NaoCoopCommandExecutionEngine(_connection);

            /*
             * if (this._connection == null || !this._connection.TestConnection())
             * {
             * throw new Exception("Could not connect to the Robot.");
             * }
             */
            this.StateCommands = new OrderedDictionary <NaoState, OrderedDictionary <NaoCommand, Dictionary <string, string> > >();

            if (id == null)
            {
                id = Guid.NewGuid();
            }
            this.ID     = id.Value;
            this.Status = RobotStatus.Idle;
        }
コード例 #11
0
        /// <summary>
        /// Constructor
        /// </summary>
        /// <param name="ip">The robot ip</param>
        /// <param name="port">The robot port</param>
        /// <param name="words">The words to monitor</param>
        /// <param name="language">The words language</param>
        /// <param name="wordSpotting">Word spotting option (full phrase or individual words)</param>
        /// <param name="interval">The interval between two memory reads</param>
        /// <param name="precision">Words precision</param>
        public SpeechRecognition(string ip, int port, List <string> words = null, string language = DEFAULT_LANGUAGE, bool wordSpotting = DEFAULT_WORD_SPOTTING, int interval = DEFAULT_INTERVAL, float precision = DEFAULT_MIN_PRECISION)
        {
            this.RecognizedWords = words;

            // check connection
            this._connection = new NaoConnectionHelper(ip, port);
            if (!this._connection.TestConnection())
            {
                throw new Exception("Could not connect to the Robot!");
            }

            this.Language           = language;
            this.Interval           = interval;
            this.EnableWordSpotting = wordSpotting;
            this.Precision          = precision;

            // initialize worker
            _worker = new BackgroundWorker();
            _worker.WorkerSupportsCancellation = true;
            _worker.DoWork += new DoWorkEventHandler(_worker_DoWork);
        }
コード例 #12
0
 /// <summary>
 /// Constructor
 /// </summary>
 /// <param name="connection"></param>
 public ObjectHandlingExecuter(NaoConnectionHelper connection)
     : base(connection)
 {
 }
コード例 #13
0
 /// <summary>
 /// Constructor
 /// </summary>
 /// <param name="connection">Connection object</param>
 public NaoCoopCommandExecutionEngine(NaoConnectionHelper connection)
 {
     this._connection             = connection;
     this._robotSynch             = new RobotSynchronization(connection);
     this._objectHandlingExecuter = new ObjectHandlingExecuter(connection);
 }