[robocup-msrs] Answers to questions

Nikos Vlassis vlassis at dpem.tuc.gr
Mon Jun 25 12:21:01 EDT 2007


Hi Kyle,

I tried the code below but there were some problems:

> using simengine = Microsoft.Robotics.Simulation.Engine;
>
> using simcommon = Microsoft.

Something is missing here. What do you mean?

After commenting out the 2nd using, I got the following compilation errors:

-----------------------------------------------
Error	1	The type or namespace name 'VisualEntity' could not be found
(are you missing a using directive or an assembly
reference?)	C:\Microsoft Robotics Studio 1.5 (CTP May
2007)\samples\simulation\competitions\simulatedsoccerservices\simplerobudogsoccerplayer\SimpleRobuDOGSoccerPlayer.cs	133	9	simpleRobuDOGsoccerplayer

Error	2	The type or namespace name 'InsertSimulationEntity' does not
exist in the namespace 'Microsoft.Robotics.Simulation.Engine' (are you
missing an assembly reference?)	C:\Microsoft Robotics Studio 1.5 (CTP
May 2007)\samples\simulation\competitions\simulatedsoccerservices\simplerobudogsoccerplayer\SimpleRobuDOGSoccerPlayer.cs	135	56	simpleRobuDOGsoccerplayer

Error	3	The type or namespace name 'DeleteSimulationEntity' does not
exist in the namespace 'Microsoft.Robotics.Simulation.Engine' (are you
missing an assembly reference?)	C:\Microsoft Robotics Studio 1.5 (CTP
May 2007)\samples\simulation\competitions\simulatedsoccerservices\simplerobudogsoccerplayer\SimpleRobuDOGSoccerPlayer.cs	141	56	simpleRobuDOGsoccerplayer
-----------------------------------------------

The last 2 disappeared (but error 1 remained) when I used
using simengine = Microsoft.Robotics.Simulation.Engine.Proxy;

thanks,
Nikos
--




On 6/13/07, Kyle Johns <kylej at microsoft.com> wrote:
>
>
>
>
> As George says, it is very easy to write code to find the position of your
> players or the soccer ball and also to move them.  The state of each entity
> in the simulation environment is held in a class which derives from
> VisualEntity.   You can query the simulation engine for the state of any
> VisualEntity in the environment.  If you are running on the same node as the
> simulation engine, you will get back a pointer to the actual object.  If you
> are running on a node on another machine, you will get back a pointer to a
> copy of the entity.
>
>
>
> The SimulatedWebCam service (source is in
> samples\simulation\sensors\simulatedwebcam) provides a good
> example of how to query the simulation engine for a particular entity and
> then receive the response:
>
>
>
> You must first add a reference to the following  two DLLs in your project:
>
> Bin\SimulationCommon.Proxy.Dll
>
> Bin\SimulationEngine.Proxy.Dll
>
>
>
> In the Start method of your service, add the following code to send a
> subscription request to the simulation engine:
>
>
>
> (this code assumes that you are running on the same node as the referee)
>
>
>
> using simengine = Microsoft.Robotics.Simulation.Engine;
>
> using simcommon = Microsoft.
>
> simengine.SimulationEnginePort _notificationTarget;
>
>
>
>             _notificationTarget = new simengine.SimulationEnginePort();
>
>             simengine.EntitySubscribeRequestType esrt = new
> simengine.EntitySubscribeRequestType();
>
>             esrt.Name =
> "blueteam/field/2/simulatedsoccerplayer/robotmotioncontrol";
> // for example
>
>             esrt.Subscriber = ServiceInfo.Service;
>
>             _simEngine.Subscribe(esrt, _notificationTarget);
>
>             MainPortInterleave.CombineWith(
>
>                 new Interleave(
>
>                     new TeardownReceiverGroup
>
>                     (
>
>                     ),
>
>                     new ExclusiveReceiverGroup(
>
>
> Arbiter.Receive<simengine.InsertSimulationEntity>(true, _notificationTarget,
> InsertEntityNotificationHandler),
>
>
> Arbiter.Receive<simengine.DeleteSimulationEntity>(true, _notificationTarget,
> DeleteEntityNotificationHandler)
>
>                     ),
>
>                     new ConcurrentReceiverGroup()
>
>                 )
>
>             );
>
>
>
> This sends a request to the simulation engine for a pointer to the entity
> with the specified name.  The MainPortInterleave.CombineWith statement adds
> two new message handlers which handle the InsertSimulationEntity and
> DeleteSimulationEntity messages.  A possible implementation for these would
> be:
>
>
>
>         VisualEntity _entity = null;
>
>         void
> InsertEntityNotificationHandler(simengine.InsertSimulationEntity
> ins)
>
>         {
>
>             _entity = (VisualEntity)ins.Body;
>
>         }
>
>
>
>         void
> DeleteEntityNotificationHandler(simengine.DeleteSimulationEntity
> del)
>
>         {
>
>             _entity = null;
>
>         }
>
>
>
> Now, at any time in your simulation, you can query this entity for its
> position and orientation:
>
>
>
> Vector3 myPosition = _entity.State.Pose.Position.
>
>
>
> The orientation of the robot is represented by a quaternion in
> _entity.State.Pose.Orientation.  Or, there is also a
> property on VisualEntity that returns the orientation as a rotation angle
> (in degrees) around each axis:
>
>
>
> Xna.Vector3 rotation = _entity.Rotation;
>
>
>
>
>
>
>
>
> This is the code that the referee uses to move the soccer ball around the
> field.  Once you have a pointer to the "SoccerBall" entity, you can move it
> by calling the QueueMovePoseForPlayerEntity using the following call:
>
>
>
>             SpawnIterator<VisualEntity,Vector3>(_entity, newPosition,
>
>                 QueueMovePoseForPlayerEntity);
>
>
>
>         IEnumerator<ITask> QueueMovePoseForPlayerEntity(VisualEntity
> playerEntity, Vector3 position)
>
>         {
>
>             Port<EmptyValue> sequence = new Port<EmptyValue>();
>
>
>
>             playerEntity.DeferredTaskQueue.Post(new Task(
>
>                 delegate()
>
>                 {
>
>                     playerEntity.PhysicsEntity.IsKinematic
> = true;
>
>                     Vector3 target = position;
>
>                     // Keep the robot altitude roughly the same but drop it
> from 1 cm
>
>                     target.Y =
> playerEntity.State.Pose.Position.Y + 0.01f;
>
>
>
>                     playerEntity.State.Pose = new Pose(target);
>
>
> playerEntity.PhysicsEntity.SetPose(playerEntity.State.Pose);
>
>                     sequence.Post(EmptyValue.SharedInstance);
>
>                 }));
>
>
>
>             yield return Arbiter.Receive(false, sequence,
> delegate(EmptyValue e) { });
>
>
>
>             playerEntity.DeferredTaskQueue.Post(new Task(
>
>                 delegate()
>
>                 {
>
>                     playerEntity.PhysicsEntity.IsKinematic
> = false;
>
>                 }));
>
>         }
>
>
>
> You can move the soccer ball in a similar way:
>
>
>
> _soccerBallEntity.DeferredTaskQueue.Post(new Task<Vector3>(position,
> MoveInternal));
>
>
>
>         MoveInternal(Vector3 position)
>
>         {
>
>             _soccerBallEntity.PhysicsEntity.IsKinematic =
> true;
>
>             _soccerBallEntity.PhysicsEntity.SetPose(new
> Pose(position));
>
>         }
>
>
>
>
>
> You can find an additional example of how to query the simulation engine for
> a simulation entity in the SimulatedDifferentialDrive service.
>
>
>
> -Kyle
>
>
>
>
>
>
>
> From: George Chrysanthakopoulos
>  Sent: Monday, June 11, 2007 10:22 AM
>  To: Nikos Vlassis; Kyle Johns
>  Cc: robocup-msrs at cc.gatech.edu
>  Subject: RE: [robocup-msrs] Answers to questions
>
>
>
>
> Hi Nikos our engine is built in a way that pretty much *everything* is
> accessible through code, local or remote. Kyle and I will send instructions
> on a few ways you can interact with the simulation engine, to
> programmatically reposition *any* entity, in real time. This is all doable.
>
>
>
> Thanx
>
> g
>
>
>
>
> From: robocup-msrs-bounces at cc.gatech.edu
> [mailto:robocup-msrs-bounces at cc.gatech.edu] On Behalf Of
> Nikos Vlassis
>  Sent: Monday, June 11, 2007 9:37 AM
>  To: Kyle Johns
>  Cc: robocup-msrs at cc.gatech.edu
>  Subject: Re: [robocup-msrs] Answers to questions
>
>
>
>
>
> Hi Kyle,
>
>  thanks for your answers.
>
>
>
>
> 8) How can we reset robots/ball to specific positions during development?
>  Moving the ball to a specific position is easy, moving the robots is more
> difficult.  To move the ball position, put the simulator into edit mode by
> pressing F5.  This pauses the physics engine so your soccer players and the
> ball will stop moving.  Find the Soccer Ball entity in the upper-left-hand
> pane and select it.  In the lower-left-hand pane, select the position
> propery.  Either type in new position numbers or press the control key and
> drag the ball around the field with the left mouse button to move it.  When
> you have it positioned properly, press F5 again to return to simulation
> mode.
>  I'm still working on an easy way to move the Robudogs around and I'll let
> you know as soon as I have it.
>
>
>
>
>  This is fine, but we need a way to do the above with C# code, otherwise
> it's not very useful. Clearly one of the main advantages of the simulation
> as opposed to the real system, is that collecting training data is cheap,
> and based on these data one can use various learning techniques for adapting
> whatever algorithms one is developing. Unless there is an
> automatic/programmable way to set the objects in the desired positions,
> there is no hope that one can use such techniques for learning how to play
> soccer. I believe it would be really a pity if we are not given this
> possibility --- in fact we assumed that this would be the case when we
> registered for this event, and it would be very disappointing if it turns
> out that this option is disabled. Whatever techniques one uses for algorithm
> design, I believe that there should be a programmable way to test the
> developed algorithms without interacting manually with the simulator
> graphics.
>
>  thanks,
>  Nikos
>
>
>
>


More information about the robocup-msrs mailing list