WorldViz User Forum  

Go Back   WorldViz User Forum > Vizard

 
 
Thread Tools Rate Thread Display Modes
Prev Previous Post   Next Post Next
  #1  
Old 04-13-2011, 07:31 AM
miles miles is offline
Member
 
Join Date: Jan 2011
Posts: 21
Driving simulation

Hello all,

I have been tasked with creating a driving simulation to use with our existing code. I am fairly new to interfacing with devices, so I am having difficultly understanding what I need to do to make our hardware work with our existing virtual environment.

Our virtual environment can currently be navigated using mouse & keyboard or by using our Intersense system. We have a steering wheel (USB) and foot pedals (Serial with USB adapter), both from ECCI.

Here is the existing code to connect to either the Intersense or the mouse & keyboard. INTERSENSE and DRIVING are both flags set earlier in the program.
Code:
link = 0

# If we're using InterSense, attempt to connect to the tracker, then add a link to it
if INTERSENSE:
	print 'Checking for intersense attached to system'
	#Turn mouse control off
	viz.mouse(viz.OFF)
	
	tracker = viz.add('intersense.dls')
	if tracker:
		link = viz.link(tracker, viz.MainView)
		print 'Successful link to Intersense.'
	else:
		print 'Intersense tracker not found. Switching to mouse control.'
		link = 0
else:
	print 'Not using intersense'
	viz.mouse(viz.ON)
	viz.mouse.setTrap(viz.ON)
	
# If we don't find the tracker or have not loaded InterSense, we should be using the mouse and keyboard to control movement

# If we haven't found a link, we must use the initial link between the keyboard and mainView that is created
#	when we initialize a Vizard program.  Travis found this deep in the code, it wasn't well documented
if link == 0:
	import viztracker
	tracker = viztracker.KeyboardMouse6DOF()
	
	fixedTracker = viz.addGroup()
	link = viz.link(fixedTracker, viz.MainView)
	print 'Using keyboard link'
	
	# So instead of getting data from the InterSense to apply to the mainView, we use data from the keyboard and mouse
	#	Like in a video game.  Arrow keys move, not WASD
	
	def updateView():
		x,y,z = tracker.getPosition()
		fixedTracker.setPosition(x, 1.2, z)
		fixedTracker.setEuler(tracker.getEuler())
		
	vizact.ontimer(0, updateView)
	
	# If both InterSense and the keyboard aren't working, shut down the program
	if link == 0:
		print 'Could not load a tracker. Exiting.'
		sys.exit()
Do I need to write a plugin for the driving hardware? I've also looked into the built in joystick library, vizjoy, but I couldn't seem to find what I was looking for.

Any suggestions are appreciated,
Thanks,
-miles
Reply With Quote
 

Thread Tools
Display Modes Rate This Thread
Rate This Thread:

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 Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
How to create mini car driving by wiimote superantTTY Vizard 7 05-18-2010 05:18 AM
How to pause the Vizard simulation? 4711 Vizard 4 03-18-2010 04:45 PM
Particle simulation imperialkat Vizard 0 01-29-2010 12:01 PM
driving simulator paulpars Vizard 1 05-12-2006 11:46 AM


All times are GMT -7. The time now is 05:42 AM.


Powered by vBulletin® Version 3.8.7
Copyright ©2000 - 2024, vBulletin Solutions, Inc.
Copyright 2002-2023 WorldViz LLC