WorldViz User Forum changing the gain of a joystick during a program
 Register FAQ Search Today's Posts Mark Forums Read

#1
06-22-2009, 04:22 AM
 Saz Member Join Date: Nov 2008 Posts: 36
changing the gain of a joystick during a program

Hi,

I want to change the gain of the joystick by altering the scalar constant (in this case MOVE_SPEED)- so effectively the speed will alter - at a certain point in my program (22secs in). Here's what I have so far:
Code:
```def UpdateJoystick1():
#Get the joystick position
x,y,z = joy.getPosition()

#Move the viewpoint forward/backward based on y-axis value
if abs(y) > 0.0001: #Make sure value is above a certain threshold
viz.MainView.move(0,0,-y*MOVE_SPEED,viz.BODY_ORI)
#Move the viewpoint left/right based on x-axis value
if abs(x) > 0.001: #Make sure value is above a certain threshold
viz.MainView.move(x*0.1,0,0,viz.BODY_ORI)
#Turn the viewpoint left/right based on twist value
#if abs(twist) > 0.001: #Make sure value is above a certain threshold
#    viz.MainView.rotate(0,1,0,twist,viz.BODY_ORI,viz.RELATIVE_WORLD)

#UpdateJoystick every frame
vizact.ontimer(0,UpdateJoystick1)

def UpdateJoystick2():
#Get the joystick position
x,y,z = joy.getPosition()

#Move the viewpoint forward/backward based on y-axis value
if abs(y) > 0.0001: #Make sure value is above a certain threshold
viz.MainView.move(0,0,-y*MOVE_SPEED2,viz.BODY_ORI)
#Move the viewpoint left/right based on x-axis value
if abs(x) > 0.001: #Make sure value is above a certain threshold
viz.MainView.move(x*0.1,0,0,viz.BODY_ORI)
#Turn the viewpoint left/right based on twist value
#if abs(twist) > 0.001: #Make sure value is above a certain threshold
#    viz.MainView.rotate(0,1,0,twist,viz.BODY_ORI,viz.RELATIVE_WORLD)

#UpdateJoystick every frame
vizact.ontimer2(22,0,UpdateJoystick2)```
but it doesn't seem to make a difference at all - is it because it just comes on at the 22 sec point and then reverts back to the original joystick code? Would I need to insert starttimer and killtimer statements to initiate the two sections?
Any help - as usual - will be greatly appreciated!

 Posting Rules You may not post new threads You may not post replies You may not post attachments You may not edit your posts BB code is On Smilies are On [IMG] code is On HTML code is Off Forum Rules
 Forum Jump User Control Panel Private Messages Subscriptions Who's Online Search Forums Forums Home Getting Vizard Help with AI Announcements Vizard Precision Position Tracker (PPT) Plug-in development

 Similar Threads Thread Thread Starter Forum Replies Last Post fuyonggang Vizard 4 12-18-2008 06:14 PM Saz Vizard 3 12-17-2008 05:18 AM Vinicius Lima Vizard 7 10-23-2007 10:42 AM Vygreif Vizard 1 01-25-2006 10:56 AM Plasma Vizard 2 01-29-2004 07:08 PM

All times are GMT -7. The time now is 02:33 PM.