WorldViz User Forum  

Go Back   WorldViz User Forum > Vizard

Reply
 
Thread Tools Rate Thread Display Modes
  #1  
Old 04-15-2004, 03:11 PM
JRichizzle JRichizzle is offline
Member
 
Join Date: Mar 2003
Location: Houston, TX
Posts: 43
Stand-alone executables, etc.

We have a unique application in which subjects are going to have to select programs to run during an experiment. The programs will be simulations of continuous motion through various virtual environments (VRMLs) without head-tracking. The subject will have an LCD display directly in front of them while on a treadmill. This display will be driven by a Windows XP-based PC operating system. We envision the subjects selecting simulations via some graphical user interface in which icons represent links to any one of the aforementioned motion simulations (i.e. Vizard scripts).

Can one create stand-alone programs in Vizard?

We thought we might have to create the master GUI with 3rd-party program to act as a middle-man between the subject and the programs in Vizard. If so, we need to figure out how to communicate between this master GUI and Vizard.

I expect to have to answer questions to clarify this question, but I thought I would get the conversation rolling with this much for now.

Thanks!
Reply With Quote
  #2  
Old 04-15-2004, 03:29 PM
farshizzo farshizzo is offline
WorldViz Team Member
 
Join Date: Mar 2003
Posts: 2,849
Hi,

It is possible to run a vizard script from within another program. All you have to do is execute the following command:

"C:\Program Files\Vizard20\bin\winviz.exe" <path to your script> 0

Use the following piece of code in your program to call this command:
Code:
ShellExecute(NULL, "open", "C:\\Program Files\\Vizard20\\bin\\winviz", "C:\\somescript.py 0", NULL, SW_SHOW);
I'm not sure if this is related to what you want, but Vizard comes with a program that allows you to create an html page with links to vizard scripts. When a user clicks on a script link it will launch that script. This way you can design some fancy looking page with links to your scripts. Let me know if you are interested in this and I'll give you some more detail about using it.
Reply With Quote
  #3  
Old 04-15-2004, 03:31 PM
JRichizzle JRichizzle is offline
Member
 
Join Date: Mar 2003
Location: Houston, TX
Posts: 43
html info

Yes, I would like to learn more about how to create this html page with links to programs. Please send more info when you can. Thanks!
Reply With Quote
  #4  
Old 04-15-2004, 04:12 PM
farshizzo farshizzo is offline
WorldViz Team Member
 
Join Date: Mar 2003
Posts: 2,849
Hi,

There is a zip file on our webpage that contains this program and an example. Click on the following link to download it:

http://www.worldviz.com/download/files/quickworld.zip

The main program is Quickstart.exe. When you run this program it will load the html page demo.html. There are no restrictions on how your html page should be layed out. To create a link to a script just insert the following html code at the appropriate location in your html page:
Code:
<SPAN id="script1.py" class="demo">Run Script</SPAN>
The id field of the SPAN tag should be the path to any Vizard script. You can change Run Script to any text you want. Let me know if you need any more help.

Good luck!
Reply With Quote
  #5  
Old 07-28-2004, 02:08 PM
JRichizzle JRichizzle is offline
Member
 
Join Date: Mar 2003
Location: Houston, TX
Posts: 43
Question Launching Vizard from Visual Basic

So, is the "ShellExecute..." command in the post above a C or C++ command?
Reply With Quote
  #6  
Old 07-28-2004, 02:33 PM
farshizzo farshizzo is offline
WorldViz Team Member
 
Join Date: Mar 2003
Posts: 2,849
Hi,

The above code sample will only work with C/C++. It should work in Visual Basic with very little modification. There should be an example in the Visual Basic documentation. I've never used Visual Basic before, so I don't know the exact syntax.
Reply With Quote
  #7  
Old 07-30-2004, 08:36 AM
JRichizzle JRichizzle is offline
Member
 
Join Date: Mar 2003
Location: Houston, TX
Posts: 43
Question Calling scripts from within a script

Howdy,

Is it possible to run other .py scripts with a command within a .py script?

E.g., a keyboard callback within a program that, when one presses the spacebar, launches a second program.

E.g.2, an if/then statement that launches a second program.

Better yet, can I develop a my own custom GUI using Vizard?
Reply With Quote
  #8  
Old 07-30-2004, 12:08 PM
farshizzo farshizzo is offline
WorldViz Team Member
 
Join Date: Mar 2003
Posts: 2,849
Hi,

You can run a vizard script from any programming environment. All you need to do is execute the following in the command line:

"C:\Program Files\Vizard20\bin\winviz.exe" "script.py" 0

The way to do this is different for each programming language, so you will have to look at the documentation for it. Here's an example of how to do it in python, however I don't recommend launching a vizard script within another vizard script.
Code:
import viz
import win32process

def startscript(filename):
	execCommand = viz._BIN_PRIMARY + ' "' + filename + '" 0'
	win32process.CreateProcess(None, execCommand, 
								  None, None, 1, 0, None, 
								  None, win32process.STARTUPINFO())

startscript('myscript.py')
Reply With Quote
  #9  
Old 07-30-2004, 12:42 PM
JRichizzle JRichizzle is offline
Member
 
Join Date: Mar 2003
Location: Houston, TX
Posts: 43
Sweet, thanks!! I didn't really want to call scripts with a script, but was curious about the possibilities. We're going to call scripts with a GUI program written in Visual Basic.

Far-shizzle mah nizzle,
JRichizzle.

p.s. do you know anything about the timeline for the release of a version in which stand-alone executables can be created?
Reply With Quote
  #10  
Old 04-27-2005, 08:19 AM
sjroorda sjroorda is offline
Member
 
Join Date: Apr 2005
Posts: 13
Sorry for kicking this topic, but I'm curious for the answer on the last question of the topic starter:
Quote:
we need to figure out how to communicate between this master GUI and Vizard
Is this possible in a certain way?

My application is a little more complex than 'just' selecting a world from a menu: I want to send commands to my wordt from within the (Delphi) user interface. These commands are for example 'lights on/off', 'play sound', 'open door', etc.. Should I use a specific port for sending data to? I don't get any data in the mynetwork-function.

I have another additional question: is it possible to remove the title bar and borders from the Vizard window without going fullscreen? I only want the rendered image, nothing more. (goal: I want to include two different viewpoints into my Delphi UI).

Thanks in advance,

Siemen
Reply With Quote
  #11  
Old 04-27-2005, 02:42 PM
farshizzo farshizzo is offline
WorldViz Team Member
 
Join Date: Mar 2003
Posts: 2,849
Hi,

The Vizard network commands use a datagram socket on port 4950 to communicate. Sending the string "hello" will result in the following character sequence being sent:

"\x00\x00\x00\x00,s\x00\x00hello\x00\x00\x00"

Note that "\x00" is the hex value 0x00. I have never tried communicating with Vizard from another application using this method. However, if you follow the above protocol I don't see why it would not work. Let me know if you are having any problems with this.

If you have not already invested a lot of effort in your Delphi UI, you might want to consider directly embedding Vizard within a GUI application made with python. We have a few samples of embedding the Vizard render window inside of a wxPython GUI.

Currently there is no built-in method of removing the border of the render window. I'll look into a work around for this in the meantime.
Reply With Quote
  #12  
Old 04-28-2005, 02:28 AM
sjroorda sjroorda is offline
Member
 
Join Date: Apr 2005
Posts: 13
Thanks for this information, I managed to get data from one computer running a Delphi UI to my Vizard-program. However, with a 'print message', I get an array of two elements, each (!) containing the string I've sent, so no real datagram package as you describe. I guess a miscommunication between Delphi and Vizard is the cause, but I get the data, and that's the point . I even get a Vizard-msg 'Oops, typetag lacks the magic ,' in response!
Reply With Quote
  #13  
Old 04-28-2005, 10:57 AM
farshizzo farshizzo is offline
WorldViz Team Member
 
Join Date: Mar 2003
Posts: 2,849
Hi,

The message structure passed to python should be an array of 3+ elements. The first element should be the address of the user that sent the message. The second element should by the type information of what they sent. The rest of the data should be the actual content of the message, in your case it should be a string. I'll do some tests here to make sure sending the data over a socket works.
Reply With Quote
  #14  
Old 04-28-2005, 11:26 AM
farshizzo farshizzo is offline
WorldViz Team Member
 
Join Date: Mar 2003
Posts: 2,849
Hi,

I did some tests here and got it working. Here is the C++ code I used to generate the packet:
Code:
std::string packString(const char *message)
{
	std::string pack = message;
	int stringLen = ceil( (pack.size() + 1) / 4.0 ) * 4;
	for(int i = pack.size(); i < stringLen; i++)

		pack += '\0';
	return pack;
}

std::string createPacket(const char *message)
{
	return packString("master") + packString(",s") + packString(message);
}
The createPacket function uses the packString function to generate 3 string packets. The first string packet is the address of the computer you are sending from. You can set this to whatever you want. The second string packet is the type of the data. If you will only be sending one string then you don't need to change this. The last string packet is the message you want to send. The packString function simply pads the string with some NULL characters. After this, simply send the string returned by createPacket over the socket. Let me know if you can't get this working.
Reply With Quote
  #15  
Old 05-03-2005, 04:02 AM
sjroorda sjroorda is offline
Member
 
Join Date: Apr 2005
Posts: 13
Thank you for the code; I ported it to Delphi and everything works fine! However, I tested somewhat, and I got a curious case regarding the way of sending commands like these. The general structure of a network package to be sent is as follows:

{sender}{type of information}{information itself}

all fields added with 0-bytes up to a multiple of 4 bytes. Example (seperated by newlines for readability):

sender#0#0
,ss#0
test1#0#0#0
test2#0#0#0

Type of information is, for example, ,ss if 2 strings are sent, ,ii if two integers are send and ,lii if an array of 2 integers is sent. However, consider these two cases:

myNetwork.send([1,2,3,'s','test']);
myNetwork.send([1,2,3,'s'],'test');

Both send ,liiiss as type! How do I know, if I want to process information sent by Vizard, which data really was sent? Vizard understands, regarding a 'print msg'.

Despite my continuing flow of maybe far too technical questions: thanks for the good and quick support
Reply With Quote
  #16  
Old 05-03-2005, 11:06 AM
farshizzo farshizzo is offline
WorldViz Team Member
 
Join Date: Mar 2003
Posts: 2,849
Hi,

When you get the data you can check the size of the list using the len function. This way you know how many elements are in it.
Reply With Quote
  #17  
Old 07-13-2005, 10:15 AM
JRichizzle JRichizzle is offline
Member
 
Join Date: Mar 2003
Location: Houston, TX
Posts: 43
Winviz title bar and borders

Again, bringing this thread back to life...

Is there a known work-around for removing the title bar and borders from the winviz render window? (other than setting window position and size manually such that they are invisible to the user)
Reply With Quote
  #18  
Old 07-13-2005, 12:11 PM
farshizzo farshizzo is offline
WorldViz Team Member
 
Join Date: Mar 2003
Posts: 2,849
Are you wanting to do this without going into fullscreen mode? Going into fullscreen mode should remove the titlebar and border. The latest beta version of Vizard has a function to remove the border without going into fullscreen mode, but I don't believe it is available for download yet. Let me know if you would like to try out the beta version.
Reply With Quote
  #19  
Old 07-13-2005, 12:15 PM
JRichizzle JRichizzle is offline
Member
 
Join Date: Mar 2003
Location: Houston, TX
Posts: 43
I would like to remove borders and title bar in normal screen mode (not fullscreen). Unfortunately, I need to be able to do this in v2.51. This is because the project I am working on is a NASA flight experiment with tight constraints on software.

Is there a way you could share the function with me without having to install the beta version?
Reply With Quote
  #20  
Old 07-14-2005, 01:48 PM
farshizzo farshizzo is offline
WorldViz Team Member
 
Join Date: Mar 2003
Posts: 2,849
I've attached a zip file which contains a script that will remove the border around the window. The zip file also contains the file "win32gui.pyd". You will need to place this file in the same directory as your script. If you use the code in a different script be sure to modify the variable scriptName to the name of your script. Let me know if it doesn't work.
Attached Files
File Type: zip removeborder.zip (24.7 KB, 870 views)
Reply With Quote
  #21  
Old 07-14-2005, 02:40 PM
JRichizzle JRichizzle is offline
Member
 
Join Date: Mar 2003
Location: Houston, TX
Posts: 43
How do I call the function? Should there be a line with the following code:

NextWindow(hwnd, obj)

What numbers should take the places of hwnd and obj ?
Reply With Quote
  #22  
Old 07-14-2005, 04:23 PM
farshizzo farshizzo is offline
WorldViz Team Member
 
Join Date: Mar 2003
Posts: 2,849
You don't need to call any function, the code should automatically remove the border. I've made a small fix so you should download the attached file. It creates a function called RemoveBorder which accepts the name of a window. This name should be the name of your script.
Attached Files
File Type: zip removeborder.zip (24.7 KB, 807 views)
Reply With Quote
  #23  
Old 07-14-2005, 04:27 PM
JRichizzle JRichizzle is offline
Member
 
Join Date: Mar 2003
Location: Houston, TX
Posts: 43
Works like a champion!!! Thanks so much for all your help!
Reply With Quote
  #24  
Old 08-30-2005, 04:11 AM
sjroorda sjroorda is offline
Member
 
Join Date: Apr 2005
Posts: 13
Quote:
Originally posted by farshizzo
The Vizard network commands use a datagram socket on port 4950 to communicate.

[...]
Again a subtile kick! I need to send this data to two different Vizard-instances on the same computer. Creating a UDP-socket works great for one of them, but the other never receives any data. I guess this has to do with the fact that at the moment the first instance catches the data, this UDP-packet is gone.

A trivial solution for this would be connecting a second socket to a different port, but I can nowhere find a way to specify the port number!

Is this possible, is there another way, or should I look for a completely different workaround?

Last edited by sjroorda; 08-30-2005 at 04:19 AM.
Reply With Quote
  #25  
Old 08-31-2005, 09:54 AM
farshizzo farshizzo is offline
WorldViz Team Member
 
Join Date: Mar 2003
Posts: 2,849
Hi,

The option to specify a port to communicate over is not available in the current version. In the meantime you can create your own sockets using python. There is a post in the following thread which contains sample python code for creating sockets manually.
http://www.worldviz.com/forum/showth...=&threadid=370
Reply With Quote
  #26  
Old 09-01-2005, 08:13 AM
sjroorda sjroorda is offline
Member
 
Join Date: Apr 2005
Posts: 13
Great, it's working!
Reply With Quote
  #27  
Old 09-13-2005, 09:44 AM
cr5 cr5 is offline
Member
 
Join Date: Sep 2005
Posts: 3
Question sending network messages to vizard

i managed to get messages into vizard over a network as shown earlier in this thread. they appear in the right format but everytime vizard receives a message, it freezes rendering for about 4 seconds. which sums up fast if i send tracking data from another machine about 25 times a second...

it's v.2.53, win xp. tested on two machines, same effect. any help?
Reply With Quote
  #28  
Old 09-13-2005, 10:43 AM
farshizzo farshizzo is offline
WorldViz Team Member
 
Join Date: Mar 2003
Posts: 2,849
Hi,

I just created a test script here that sends tracking data from an intersense to another script. The data is being sent every frame, so 60 times a second. I tried receiving the data on two separate machines, and on both of them the latency for receiving data was around 1 millisecond. These tests were also done on winxp.

Are you sending the data over a local network? Is Windows XP firewall enabled? We've had problems with that before. Are you using Vizard's built-in networking functionality to receive the messages?
Reply With Quote
  #29  
Old 09-14-2005, 05:10 AM
cr5 cr5 is offline
Member
 
Join Date: Sep 2005
Posts: 3
i use a local network and get the same result if i connect only the two machines with fixed ip's, firewalls disabled. the latency in receiving data seems very low, as when i click on send on one machine the rendering in vizard freezes immediately (for some seconds). i use the built in network thingy, like this:

Code:
def mynetwork(msg):
	euler = view.get(viz.HEAD_EULER)
	euler[0] += msg[2]
	euler[1] += msg[3]
	euler[1] = viz.clamp(euler[1],-90.0,90.0)
	view.rotate(euler,viz.HEAD_ORI)

viz.callback(viz.NETWORK_EVENT, mynetwork)
the incoming messages look like this:

Code:
['MaxJitter', ',ff', 0.32187500596046448, -0.70416665077209473]
again, except for the freezes, everything basically works. could setting up the machine anew help in any way? (i usually work on OS X and other unixes and tried to ignore messy windows for the last years...)
Reply With Quote
  #30  
Old 09-14-2005, 06:58 PM
farshizzo farshizzo is offline
WorldViz Team Member
 
Join Date: Mar 2003
Posts: 2,849
Hi,

After some testing I found the problem. When a message is received by Vizard it attempts to lookup the name of the sender. On some networks this may take a long time due to slow DNS servers. I modified Vizard to not perform this lookup and it definitely speeds up receives. This will most likely solve your problem too. I will try to get a patch by the end of the week, let me know if you need it sooner. Sorry for all the trouble.
Reply With Quote
Reply

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


All times are GMT -7. The time now is 12:57 AM.


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