Raúl
Moderator
 Moderator
| Posts: 592 |  | Karma: 10
|
Re:Maze solver - 2010/02/10 14:39
In the case of the Maze Simulator, the simulated robot is created programatically, and so are created the associated simulated sensors as well. This means that there is no need to specify these services in the manifest: when you create the MazeSimulator service, the robot-related services are created as a consequence.
Note there is a method called AddPioneer3DXRobot in the MazeSimulatorRA service. This code creates the simulated sensors. For instance, the Laser Range Finder (LRF) is created using a call to CreateLaserRangeFinder:
| Code: | private LaserRangeFinderEntity CreateLaserRangeFinder()
{
// Create a Laser Range Finder Entity.
// Place it 30cm above base CenterofMass.
LaserRangeFinderEntity laser = new LaserRangeFinderEntity(
new Pose(new Vector3(0, 0.30f, 0)));
laser.State.Name = "SimulatedLRF";
laser.LaserBox.State.DiffuseColor =
new Vector4(0.25f, 0.25f, 0.8f, 1.0f);
// Create LaserRangeFinder simulation service and specify
// which entity it talks to
CreateService(
lrf.Contract.Identifier,
Microsoft.Robotics.Simulation.Partners.CreateEntityPartner(
"http://localhost/" + laser.State.Name)
);
return laser;
}
|
In short, as you are using this code, the service is created programatically, and therefore you don't need to add the sensor services to the manifest.
Now, you probably want to subscribe to these sensor services from another service, say a Control Service.
This Control Service has to establish a partnership with the sensor services. The way I do this is as follows:
For instance, for the bumper sensor, in your Control Service you will specify a partnership with the generic bumper contract:
| Code: | [Partner("Bumper",
Contract = bumper.Contract.Identifier,
CreationPolicy = PartnerCreationPolicy.UseExisting)]
bumper.ContactSensorArrayOperations _bumperPort =
new bumper.ContactSensorArrayOperations();
bumper.ContactSensorArrayOperations _bumperNotify =
new bumper.ContactSensorArrayOperations();
|
Note here that I use "UseExisting" as Creation Policy, given the specific simulated bumper service already exists (it was created during MazeSimulationRA service startup).
For other services that you specify in the manifest, you wouls use the option UsePartnerListEntry.
Hope this helps..
Raúl Arrabales Moreno. conscious-robots.com/raul |