コード例 #1
0
        void InsertEntityNotificationHandler(simengine.InsertSimulationEntity ins)
        {
            // _entity = (simengine.BumperArrayEntity)ins.Body;
            _entity = (PioneerBumperEntity)ins.Body;
            _entity.ServiceContract = Contract.Identifier;

            // reinitialize the state
            CreateDefaultState();

            pxContactSensor.ContactSensor cs = null;

            // The simulation bumper service uses a simple heuristic to assign contact sensors, to physics shapes:
            // Half the sensors go infront, the other half in the rear. Assume front sensors are first in the list
            // In the for loop below we create a lookup table that matches simulation shapes with sensors. When
            // the physics engine notifies us with a contact, it provides the shape that came into contact. We need to
            // translate that to sensor. In the future we might add an object Context field to shapes to make this easier
            for (int i = 0; i < _entity.Shapes.Length; i++)
            {
                cs      = new pxContactSensor.ContactSensor();
                cs.Name = _entity.Shapes[i].State.Name;
                cs.HardwareIdentifier = i;
                _state.Sensors.Add(cs);
                _bumperShapeToSensorTable.Add((physics.BoxShape)_entity.Shapes[i], cs);
            }

            // subscribe to bumper simulation entity for contact notifications
            _entity.Subscribe(_contactNotificationPort);
            // Activate a handler on the notification port, it will run when contacts occur in simulation
            Activate(Arbiter.Receive(false, _contactNotificationPort, PhysicsContactNotificationHandler));
        }
コード例 #2
0
 void DeleteEntityNotificationHandler(simengine.DeleteSimulationEntity del)
 {
     _entity = null;
 }
コード例 #3
0
        void InsertEntityNotificationHandler(simengine.InsertSimulationEntity ins)
        {
            // _entity = (simengine.BumperArrayEntity)ins.Body;
            _entity = (PioneerBumperEntity)ins.Body;
            _entity.ServiceContract = Contract.Identifier;

            // reinitialize the state
            CreateDefaultState();

            pxContactSensor.ContactSensor cs = null;

            // The simulation bumper service uses a simple heuristic to assign contact sensors, to physics shapes:
            // Half the sensors go infront, the other half in the rear. Assume front sensors are first in the list
            // In the for loop below we create a lookup table that matches simulation shapes with sensors. When
            // the physics engine notifies us with a contact, it provides the shape that came into contact. We need to
            // translate that to sensor. In the future we might add an object Context field to shapes to make this easier
            for (int i = 0; i < _entity.Shapes.Length; i++)
            {
                cs = new pxContactSensor.ContactSensor();
                cs.Name = _entity.Shapes[i].State.Name;
                cs.HardwareIdentifier = i;
                _state.Sensors.Add(cs);
                _bumperShapeToSensorTable.Add((physics.BoxShape)_entity.Shapes[i], cs);
            }

            // subscribe to bumper simulation entity for contact notifications
            _entity.Subscribe(_contactNotificationPort);
            // Activate a handler on the notification port, it will run when contacts occur in simulation
            Activate(Arbiter.Receive(false, _contactNotificationPort, PhysicsContactNotificationHandler));
        }
コード例 #4
0
        // Raul - Dec 2007 - Changed to use my simulated bumper
        private bumper.PioneerBumperEntity CreateBumperArray()
        {

            bumper.PioneerBumperEntity bumperArray = new bumper.PioneerBumperEntity();

            // entity name, must match manifest partner name
            bumperArray.State.Name = "SimulatedPioneerBumper";

            // start simulated bumper service
            pxbumper.Contract.CreateService(
                ConstructorPort,
                Microsoft.Robotics.Simulation.Partners.CreateEntityPartner(
                "http://localhost/" + bumperArray.State.Name));
            return bumperArray;
        }
コード例 #5
0
 void DeleteEntityNotificationHandler(simengine.DeleteSimulationEntity del)
 {
     _entity = null;
 }