/// <summary>
        /// Subscribe to sensors and send notifications
        /// to BumperNotificationHandler
        /// </summary>
        void SubscribeToBumperSensors()
        {
            _contactSensorPort.Subscribe(_contactNotificationPort);

            // Attach handler to update notification on bumpers
            Activate(Arbiter.Receive <contactsensor.Update>(true, _contactNotificationPort, BumperNotificationHandler));
        }
Exemplo n.º 2
0
        protected override void Start()
        {
            #region request handler setup
            Activate(
                Arbiter.Interleave(
                    new TeardownReceiverGroup(
                        Arbiter.Receive <DsspDefaultDrop>(false, _mainPort, DropHandler)
                        ),
                    new ExclusiveReceiverGroup(
                        Arbiter.Receive <LaserRangeFinderResetUpdate>(true, _mainPort, LaserRangeFinderResetUpdateHandler),
                        Arbiter.Receive <LaserRangeFinderUpdate>(true, _mainPort, LaserRangeFinderUpdateHandler),
                        Arbiter.Receive <BumpersUpdate>(true, _mainPort, BumpersUpdateHandler),
                        Arbiter.Receive <BumperUpdate>(true, _mainPort, BumperUpdateHandler),
                        Arbiter.Receive <DriveUpdate>(true, _mainPort, DriveUpdateHandler),
                        Arbiter.Receive <WatchDogUpdate>(true, _mainPort, WatchDogUpdateHandler)
                        ),
                    new ConcurrentReceiverGroup(
                        Arbiter.Receive <Get>(true, _mainPort, GetHandler),
                        Arbiter.Receive <dssp.DsspDefaultLookup>(true, _mainPort, DefaultLookupHandler)
                        )
                    )
                );
            #endregion

            #region notification handler setup
            Activate(
                Arbiter.Interleave(
                    new TeardownReceiverGroup(),
                    new ExclusiveReceiverGroup(),
                    new ConcurrentReceiverGroup(
                        Arbiter.Receive <sicklrf.Reset>(true, _laserNotify, LaserResetNotification),
                        Arbiter.Receive <drive.Update>(true, _driveNotify, DriveUpdateNotification),
                        Arbiter.Receive <bumper.Replace>(true, _bumperNotify, BumperReplaceNotification),
                        Arbiter.Receive <bumper.Update>(true, _bumperNotify, BumperUpdateNotification)
                        )
                    )
                );

            // We cannot replicate the activation of laser notifications because the
            // handler uses Test() to skip old laser notifications.
            Activate(
                Arbiter.ReceiveWithIterator <sicklrf.Replace>(false, _laserNotify, LaserReplaceNotification)
                );
            #endregion

            // Start watchdog timer
            _mainPort.Post(new WatchDogUpdate(new WatchDogUpdateRequest(DateTime.Now)));

            // Create Subscriptions
            _bumperPort.Subscribe(_bumperNotify);
            _drivePort.Subscribe(_driveNotify);
            _laserPort.Subscribe(_laserNotify);

            DirectoryInsert();
        }
Exemplo n.º 3
0
 protected void SubscribeToBumpers()
 {
     _bumperPort.Subscribe(_bumperNotify);
     Activate(
         Arbiter.Interleave(
             new TeardownReceiverGroup(),
             new ExclusiveReceiverGroup(
                 Arbiter.Receive <bumper.Update>(true, _bumperNotify, BumperHandler)
                 ),
             new ConcurrentReceiverGroup()
             )
         );
 }
        /// <summary>
        /// Subscribe to notifications when bumpers are pressed
        /// </summary>
        void SubscribeToBumpers()
        {
            // Create bumper notification port
            bumper.ContactSensorArrayOperations bumperNotificationPort = new bumper.ContactSensorArrayOperations();

            // Subscribe to the bumper service, send notifications to bumperNotificationPort
            _bumperPort.Subscribe(bumperNotificationPort);

            // Start listening for Bumper Replace notifications
            Activate(
                Arbiter.Receive <bumper.Update>
                    (true, bumperNotificationPort, BumperHandler));
        }
        /// <summary>
        /// Subscribe to the Bumpers service
        /// </summary>
        void SubscribeToBumpers()
        {
            // Create the bumper notification port.
            #region CODECLIP 04-1
            bumper.ContactSensorArrayOperations bumperNotificationPort = new bumper.ContactSensorArrayOperations();
            #endregion

            // Subscribe to the bumper service, receive notifications on the bumperNotificationPort.
            #region CODECLIP 04-2
            _bumperPort.Subscribe(bumperNotificationPort);
            #endregion

            // Start listening for updates from the bumper service.
            #region CODECLIP 04-3
            Activate(
                Arbiter.Receive <bumper.Update>
                    (true, bumperNotificationPort, BumperHandler));
            #endregion
        }