PDA

View Full Version : Glitch - variable speed, even though a fixed speed has been programmed


EKF
06-26-2014, 01:18 AM
Hi
I have Vizard 3 and I'm using a brick wall maze which a programing friend helped to write. People walk through the maze (first person perspective) using the keyboard arrow keys.
This worked fine on my old laptop, but I have just moved Vizard to a new laptop, and the walking speed is now really variable despite it being programmed at a fixed speed. I've uninstalled the antivirus software on the advice of a colleague, but this still doesn't help. I also created .exe files rather than loading directly, and I have the same problem.
Any advice greatly appreciated.
Thanks

Frank Verberne
06-26-2014, 02:30 AM
Do you have some sample code that determines the walking speed? Do you also get variable walking speed with other input devices (like a mouse or joystick) or another keyboard? Is the variable walking speed specific to the new laptop; have you tried running the .exe on another (desktop) computer? These are a few questions that come to mind. Especially your code could be the source of your problem.

EKF
06-26-2014, 02:52 AM
Hi
The problem is specific to this laptop. It works on a very similar laptop (although we initially had a speed issue and removed the antivirus software to solve this). I've also realised that the issue is in one direction only (we have a .txt file as input and east-west is working normalliy, but north-south seems to be exponentially speeding up along the path).

I've pasted our keyboard info below:
def checkKeyboard():
MOVE_SPEED_MULTIPLIER=0.6
ROTATE_SPEED_MULTIPLIER=0.6
tomove = 0
torotate = 0
#print 'viz.key',viz.key

if viz.key.isDown(viz.KEY_UP):
tomove = mazeExptParams.MOVE_SPEED*MOVE_SPEED_MULTIPLIER
elif viz.key.isDown(viz.KEY_DOWN):
tomove = -mazeExptParams.MOVE_SPEED*MOVE_SPEED_MULTIPLIER
elif viz.key.isDown(viz.KEY_RIGHT):
torotate = mazeExptParams.ROTATE_SPEED*ROTATE_SPEED_MULTIPLIE R
elif viz.key.isDown(viz.KEY_LEFT):
torotate = -mazeExptParams.ROTATE_SPEED*ROTATE_SPEED_MULTIPLIE R
elif viz.key == viz.KEY_F1:
torotate = -mazeExptParams.ROTATE_SPEED*ROTATE_SPEED_MULTIPLIE R
viz.move(0,0,tomove)
viz.rotate(viz.BODY_ORI,torotate,0,0)


Thanks
Emily

EKF
06-26-2014, 04:19 AM
apologies. To add to the code. The code listed above is our 'runMaze' file. We also have this code in our 'MazeExptParams' file:

MOVE_SPEED =0.6
ROTATE_SPEED =1.2


Thanks
Emily

Erikvdb
06-26-2014, 05:58 AM
Hi Emily,
Velocity is distance over time. In your code, that last element isn't specified, so I assume Vizard just applies the same translation regardless of how much time has past since updating the last frame. Of course, the problem is that frametimes vary all the time, maybe just very slightly if it runs very stable on one machine, but on other hardware you'll get totally different timings.

Add viz.elapsed() or viz.getFrameElapsed() as an additional multiplier and adjust your MOVE_SPEED_MULTIPLIER accordingly (the new speed is likely going to be very slow)

So try:
tomove = mazeExptParams.MOVE_SPEED*MOVE_SPEED_MULTIPLIER*vi z.getFrameElapsed()
#etc.
And see if that helps.

EKF
06-26-2014, 06:19 AM
Fantastic, that worked. Thank you very much, I really appreciate it.