none
Route tracking RRS feed

  • Question

  • Hi

    In the simulation, since a number of points in the plane X-Y like {(0,0), (0,2), (1,3),...}, how I can make an object move along such a route?

    Thanks in advanze

    Thursday, July 12, 2012 11:13 AM

Answers

  • I notice that in your code, you change the Pose.Orientation and Velocity properties directly, but these changes are then lost immediately upon calling PhysicsEntity.UpdateState(...).

    Try instead calling PhysicsEntity.SetPose(...) and SetLinearVelocity(...).

    That is, instead of:

    State.Pose.Orientation = orientVal;
    State.Velocity = new Vector3(-4, 0, 11);

    Try something like:

    PhysicsEntity.SetPose(new Pose(State.Pose.Position, orientVal));
    PhysicsEntity.SetLinearVelocity(new Vector3(-4, 0, 11));
    Tuesday, September 4, 2012 9:24 PM
    Moderator

All replies

  • I suggest you start with the included simulation tutorials.  Every entity in the simulation can be controlled by passing messages to its service operations port.  You will need to understand concurrent communication even for simple tasks using VPL with RDS.

    It can be helpful to start the samples and interact with them to get a sense of the capabilities.

    Good Luck!

    -G

    • Proposed as answer by Gershon ParentModerator Friday, July 13, 2012 11:38 PM
    • Marked as answer by MarNass Tuesday, July 17, 2012 9:52 AM
    • Unmarked as answer by MarNass Tuesday, July 17, 2012 9:52 AM
    Friday, July 13, 2012 11:38 PM
    Moderator
  • Hi


    I have read and done the examples but I still know how to make an object change its orientation when the simulation started without colliding with another object. I need my order pasepor a number of points given either initially or preferably given in real-time and be redirected to pass through.

    Do not know if it's because I'm not using either the functions or because I have to implement some kind of command to make changes in the simulation in real-time.

    If you could guide me in this subject I would be very grateful.

    Thanks

    Tuesday, July 17, 2012 11:15 AM
  • You will need to detect and avoid collisions yourself. You can move objects by setting their orientation and velocity.

    If you want point to point moves

    For example to move from (0,0) to (0,2) in 10 steps, set the orientation to face (0,2,0) and set the velocity to (0,.2,0).

    Once it reaches (0,2), you can change the orientation to face (1,3) and set the velocity to reach (1,3) in however many steps you wish.

    Friday, July 20, 2012 8:46 PM
    Moderator
  • thanks

    I define my objet like VisualEntity an inicialize


    Vector3 firstposition =new Vector3(10, 0, 0)

    // Iniciaize

    public override void Initialize(xnagrfx.GraphicsDevice device, PhysicsEngine physicsEngine)
            {
                try
                {
                    // Build model

                    // platform
                    Vector3 platformDimensions = new Vector3(11.0f, 3.0f, 8.5f);
                    BoxShapeProperties platformDesc = new BoxShapeProperties("platform", 10.0f, new Pose(new Vector3(0, 2.0f, 0)), platformDimensions);
                    platformDesc.Material = new MaterialProperties("Material", 0.0f, 0.5f, 0.5f);
                    _platform = new BoxShape(platformDesc);
                    _platform.State.Name = "PlatformShape";
                    _platform.State.DiffuseColor = new Vector4(0, 1, 0, 1);
                    base.State.Flags = EntitySimulationModifiers.Dynamic;
                    //base.State.Flags = EntitySimulationModifiers.IgnoreGravity;
                    base.State.PhysicsPrimitives.Add(_platform);
                    
                    base.State.Velocity =new Vector3(1, 0, 0);
                    base.CreateAndInsertPhysicsEntity(physicsEngine);
                    base.PhysicsEntity.SolverIterationCount = 128;

                    base.Initialize(device, physicsEngine);           
                   
                }
                catch (Exception ex)
                {
                    // clean up
                    if (PhysicsEntity != null)
                        PhysicsEngine.DeleteEntity(PhysicsEntity);

                    HasBeenInitialized = false;
                    InitError = ex.ToString();
                }
            }


    and next override Update function


    public override void Update(FrameUpdate update)
            {
                Vector3 secondPos= new Vector3(10,0,110);

                if (Vector3.Length(State.Pose.Position - _firstposition) == 0)
                {
                    base.State.Pose.Position = _firstposition;
                    base.State.Velocity = new Vector3(10,0,11);
                }

                // update state for us and all the shapes that make up the rigid body
                PhysicsEntity.UpdateState(true);
               
                // sim engine will update children
                base.Update(update);
            }

    but when the box arrives at second position, don't stop or change the direction

    What is my mistake?



    Friday, August 3, 2012 10:01 AM
  • Hi,

    Can you confirm in the debugger that you do indeed enter the condition (if (Vector3.Length(State.Pose.Position - _firstposition) == 0))

    In general, I would suggest not comparing the positions exactly. I.e. if (Math.Abs(Vector3.Length(State.Pose.Position - _firstposition)) < "some small number, but not zero") seems safer.

    Monday, August 6, 2012 11:23 PM
    Moderator
  • Closing due to no response.
    Wednesday, August 15, 2012 1:21 PM
    Moderator
  • Sorry, I'm on holidays and i couldn't try it so far.

    My box not change his orientation or velocity. I change my code like

                public override void Update(FrameUpdate update)
                {

                     Quaternion orientVal = new Quaternion(-4, 0, 110, 1);

                     if ((State.Pose.Position.X - _firstposition.X) > 0)
                     {
                         base.State.Pose.Orientation = orientVal;
                         base.State.Velocity = new Vector3(-4, 0, 11);
                     }

                 PhysicsEntity.UpdateState(true);

                }

    and nothing.

    what more can I do?

    Tuesday, August 21, 2012 7:54 AM
  • Attach a debugger to your code (Attach -> Process -> DssHost.exe), add breakpoints, and step through the code.  See if your 'if' statements are working and if not inspect the variables until you understand why it's not doing what you want.

    If you need background information on how to debug, see this section of MSDN documentation.

    • Marked as answer by MarNass Tuesday, August 21, 2012 8:13 PM
    • Unmarked as answer by MarNass Tuesday, August 21, 2012 8:14 PM
    Tuesday, August 21, 2012 6:43 PM
    Moderator

  • Debug the code and check the condition entering when this is true and that the values ​​are updated, but in the simulation no change occurs.
    Tuesday, August 21, 2012 8:16 PM
  • My code

    https://www.dropbox.com/sh/ohkfjuwfw2x7ndi/cOX5c3W2bl

    Wednesday, August 29, 2012 3:23 PM
  • I notice that in your code, you change the Pose.Orientation and Velocity properties directly, but these changes are then lost immediately upon calling PhysicsEntity.UpdateState(...).

    Try instead calling PhysicsEntity.SetPose(...) and SetLinearVelocity(...).

    That is, instead of:

    State.Pose.Orientation = orientVal;
    State.Velocity = new Vector3(-4, 0, 11);

    Try something like:

    PhysicsEntity.SetPose(new Pose(State.Pose.Position, orientVal));
    PhysicsEntity.SetLinearVelocity(new Vector3(-4, 0, 11));
    Tuesday, September 4, 2012 9:24 PM
    Moderator
  • THANKS!!!!

    Now I can change the box direction.

    Friday, September 7, 2012 3:41 PM