Re: exact simulation time?

"fransklip" <[email protected]>
Newsgroups gmane.comp.cybernetics.webot.contest
Message-ID <[email protected]>
Thanks Olivier,

This text now makes much more sense to me then when I read the manual
for the first time.
Knowing that "controllers are working asnychronously." is also
important, and it in not obvious to newbies.

b.t.w.,
the second case of the manual text:

    "if 0 <= dt > ms, ... "

should it not read:

    "if 0 <= dt < ms, ... "

?

Regards,  Frans

--- In [email protected], Olivier Michel
<Olivier.Michel@c...> wrote:
> fransklip wrote:
> 
> >Olivier,
> >
> >There appears to be an always changing time difference between the
> >simulation time as displayed in the status line of Webots and my own
> >timekeeping routine. The difference is changing between 0 and 32 msec.
> >
> >Even if my controller program starts immediately with the most simple
> >timing loop, the Webots time does not show multiples of 32 msecs:
> >  for i := 1 to 10
> >    robot_step(32);
> >
> >Is this a feature, a bug?
> >  
> >
> This is a feature. It's because controllers are working asnychronously.
> 
> >It would be nice to get the correct and exact simulation time, e.g.
> >with a new routine robot_get_time()
> >  
> >
> You can get it from the return value of the robot_step function. See
the 
> Webots manuals for more details about it:
> 
> 
>         NAME
> 
>    robot_step/ -- execute a simulation step/
> 
> 
>         SYNOPSIS
> 
>   #include <device/robot.h>
> 
>   unsigned int robot_step(unsigned int ms);
> 
> 
>         DESCRIPTION
> 
> This function requests the simulator to perform a simulation step of ms 
> milliseconds, that is to advance in the simulated time of this
amount of 
> time. In synchronous simulation mode, the request is always fulfilled 
> and the function always return 0. In asynchronous mode, the request may 
> not be fulfilled. In this case, the return value dt, representing the 
> delay, may not be 0. Let controller_date be the current time of the 
> controller, the return value be interpreted as follow:
> 
>     *
> 
>       if dt = 0, then, the behavior is equivalent to the one of
>       synchronous mode.
> 
>     *
> 
>       if 0 <= dt > ms, then the actuator values were set at
>       controller_date + dt and the sensor values where measured at
>       controller_date + ms, as requested. It means that the step
>       actually lasted the requested number of milliseconds, but the
>       actuators command could not be executed on time.
> 
>     *
> 
>       if dt > ms, then the actuators values were set at controller_date
>       + dt and the sensors values where measured also at controller_date
>       + dt. It means that the requested step duration could not be
>       respected and lasted dt milliseconds instead of ms milliseconds.
> 
> >n.b.
> >To keep the time in my robot controller, I have encapsulated the
> >Webots library robot_step() routine:
> >
> >  private int simtime = 0;
> >
> >  void step( int msecs ) {
> >    simtime += msecs;
> >    robot_step( msecs ); 
> >  }
> >
> >  int getTime() {
> >    return simtime;
> >  }
> >  
> >
> Should be:
> 
> private int simtime = 0;
> 
>   void step( int msecs ) {
>     int actual = robot_step( msecs );
>     if (actual>msecs) simtime+=actual; else simtime+=msecs;
>   }
> 
>   int getTime() {
>     return simtime;
>   }
> 
> >Another item (not important to me):
> >
> >the pop-up slider window in Webots shows angle values that are the
> >inverse of the values that a controller program has to specify to set
> >the same servo in the same direction.
> >  
> >
> Thanks for pointing that out. It needs to be fixed!
> 
> -Olivier


------------------------ Yahoo! Groups Sponsor ---------------------~-->
Buy Ink Cartridges or Refill Kits for your HP, Epson, Canon or Lexmark
Printer at MyInks.com. Free s/h on orders $50 or more to the US & Canada.
http://www.c1tracking.com/l.asp?cid=5511
http://us.click.yahoo.com/mOAaAA/3exGAA/qnsNAA/pU_rlB/TM
---------------------------------------------------------------------~->

To unsubscribe from this group, send an email to:
[email protected]

 

Your use of Yahoo! Groups is subject to http://docs.yahoo.com/info/terms/
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.