PDA

View Full Version : initialize sensor?


timbo
06-12-2008, 02:36 PM
Im trying to create a plugin for a visualeyez tracker and I dont have a lot of experience with c++. I see in the outline the function "initialize sensor" however, I have no idea what needs to be added and how it should be added into this function. Can anyone give me a hand?

Thanks,
Tim

farshizzo
06-13-2008, 11:12 AM
The InitializeSensor function is where you should initialize the connection to the device. You should set the status variable of the senor structure to TRUE or FALSE depending on if the initialized succeeded or failed.

The UpdateSensor function is called every frame and this is where you will place the tracking data into the data variable of the sensor structure.

Finally, the CloseSensor function is called when the script shuts down. This where you would disconnect from the device and cleanup your plugin.

timbo
06-13-2008, 01:13 PM
Thanks.

Currently we are using a c++ environment that recieves a UDP from LabView to update arm position. To simplify the process of writing the plugin could I create a socket that runs fast enough (60 Hz) to update arm position and target position?

farshizzo
06-13-2008, 01:19 PM
Yes, this is possible. You actually don't even need a plugin to accomplish this. Python has built-in support for socket handling. So you can do this all within your Python script. Search the forum, there are a few posts that have sample code that reads data from a socket.

timbo
06-16-2008, 11:31 AM
I understand how to create the socket in python from the examples on this forum and other sources. However, Im not sure how to sequester the x, y, and z data for the position of the LED. Using the code from an earlier question I see that you can recieve a "MAX_DATA_SIZE" but what I need is distinct values for x, y, and z. Is there something in the python socket library that can accomplish this? Thank you for all your help farshizzo!

farshizzo
06-16-2008, 06:10 PM
It depends on what data format the values are sent over the socket. If they are sent as text, then you can use standard text to float conversion. If the values are sent as binary data, then you can use the struct module to extract the values. The following post has an example of this, http://www.worldviz.com/forum/showthread.php?t=1347

timbo
06-24-2008, 10:58 AM
Thanks farshizzo it worked.