|
#1
|
|||
|
|||
Client Server Networking Problem
Hi,
I'm using the example of Client and Server networking script for my problem. When I run the Server script it runs with no errors. But when I run the Client scripts I get the following error. Could you tell me what is this error? And how can I solve it? I would be grateful, if you could help me out as soon as possible. Thanks, Mihir |
#2
|
|||
|
|||
Vizard serializes the arguments to a string and sends that to the remote computer. To serialize the data, Vizard uses the cPickle library that comes with Python. Perhaps you are trying to send an object that cPickle does not recognize.
It's difficult to tell without having a simple example that reproduces the error. For help with code on the forum it's always best to follow the posting Vizard code guidelines. |
#3
|
|||
|
|||
Hi Jeff,
Its really difficult for me to produce an example that replicates my error. I have attached my code with as short as possible. As I am using the vizconnect tool. I have also attached the vizconnect_desktop.py my code is Code:
import csv import viz import vizfx import vizconnect import vizact import makingCSVFile import zspace import vizshape import vizcam import vizinfo import viznet import vizinput from tools import collision_test filePath = vizinput.fileOpen(filter=[('DAE Files','*.dae'),('OSG Files','*.ive;*.osgb;*.osg'),('VRML Files','*.wrl'),('All File','*.*')],directory='3DModels') logoss1=None Listchilderen=[] GrabedObject=None ModelsList=[] ModelsList.append(logoss1) DissasembeldPart=False models=None grabItems=None class ExplosiveModel(viz.VizNode): """ creates a model with a given dae file and gets parts and moves them on specified axes """ def __init__(self, rowData): self.isu = vizfx.addChild(filePath) logoss1 = self.isu Listchilderen = logoss1.getNodeNames() viz.VizNode.__init__(self, self.isu.id) self.scale = .035125 #this scale is determined by doc (dividing model size by .035, we get desired size) self.isu.setScale([self.scale]*30) self.current = 0 #index of current self.rowData = rowData[:] self.layerParents = [] self.partDict = {} for tool in vizconnect.getToolsWithMode('Grabber'): tool.getRaw().setCollisionTester(collision_test.Distance(node=tool.getRaw(), distanceThreshold=1000)) def initZSpace(): import zspace viz.setMultiSample(8) viz.clearcolor(viz.SLATE) #initialize zSpace display display = zspace.init() #Scale up the zSpace display to avoid having to #scale down all the models to fit within the display viewport display.setScale(200) #save handle to wand tracker wandTracker = zspace.getWandTracker() wandTracker.setLedEnabled(True) SEND_UPDATE_TIMER = 1 UPDATE = viznet.id('update') CLIENT_DISCONNECTED = viznet.id('client_disconnected') CHAT = viznet.id('chat') SERVER_NAME=viz.input('Enter Server Name') while not viznet.client.connect(SERVER_NAME,port_in=14951,port_out=14950): if viz.ask('Could not connect to ' + SERVER_NAME + ' would you like to try another?'): SERVER_NAME=viz.input('Enter Server Name') else: viz.quit() break #___________________________________________________________________________________ #----------------------------------------------------------------------------------- def update(e): # need to edit this global grabbedObject global grabItems,models, filePath global ModelsList,logoss1,DissasembeldPart,Listchilderen, xmodel if e.client != viz.getComputerName(): try: if e.DisAssPart==True and DissasembeldPart==False: for i in Listchilderen: if i.startswith("Inst"): xmodel=logoss1.getChild(i) ModelsList.append(xmodel) models = viz.cycle(ModelsList) grabItems = set(models) DissasembeldPart=True e.GrabObj.setPosition(e.pos) e.GrabObj.setEuler(e.ori) elif e.DisAssPart==False and DissasembeldPart==True: for i1 in ModelsList: i1.remove() logoss1.remove() logoss1 = viz.add(filePath) logoss1.setPosition([0,0,0]) logoss1.setScale([0.1,0.1,0.1]) models = viz.cycle([logoss1]) grabItems = set(models) DissasembeldPart=False e.GrabObj.setPosition(e.pos) e.GrabObj.setEuler(e.ori) else: e.GrabObj.setPosition(e.pos) e.GrabObj.setEuler(e.ori) except KeyError: print 'errooooooooor' #print '-------------update client' viz.callback(UPDATE,update) #___________________________________________________________________________________ #----------------------------------------------------------------------------------- def client_disconnected(e): viz.callback(CLIENT_DISCONNECTED,client_disconnected) #___________________________________________________________________________________ #----------------------------------------------------------------------------------- def sendUpdate(): global GrabedObject, DissasembeldPart if GrabedObject!=None: ori= GrabedObject.getEuler() pos = GrabedObject.getPosition() GrabObj=GrabedObject DisAssPart=DissasembeldPart viznet.client.sendAll(UPDATE,client=viz.getComputerName(),pos=pos,ori=ori,GrabObj=GrabObj,DisAssPart=DisAssPart ) vizact.ontimer(.001,sendUpdate) #___________________________________________________________________________________ #----------------------------------------------------------------------------------- def onStopServer(e): viz.quit() viz.callback(viznet.SERVER_DISCONNECT_EVENT,onStopServer) #___________________________________________________________________________________ #----------------------------------------------------------------------------------- #alternatively, you could use the desktop vizconnect.go('vizconnect_desktop.py') #desktop vizconnect setup rowData = [] #read csv data for part numbers per step with open('names.csv', 'rb') as csvfile: reader = csv.reader(csvfile) for row in reader: rowData.append([row[0], row[1], row[2].split()]) print rowData #Set the animation speed and mode SPEED = 1200 MODE = viz.SPEED ROTATE_MODE = viz.PIVOT_ROTATE def AnimateView(pos): global GrabedObject action = vizact.goto(pos,SPEED,MODE,pivot=vizconnect.getViewpointDict(),rotate_mode=ROTATE_MODE) GrabedObject = vizconnect.getTransport().getRaw() vizconnect.getTransport().getNode3d().runAction(action) model = ExplosiveModel(rowData) model.setScale([0.02]*3) viz.clearcolor(viz.GRAY) #change background color if desired #Start off by moving to the first location AnimateView([0,2,-15]) |
#4
|
|||
|
|||
It's urgent. Please help me out as soon as possible.
|
#5
|
|||
|
|||
It looks like the transport object can't be sent using the network command and causes the cPickle error. Try sending the position and orientation of the transport every frame to all clients. On the receiving end, set the position and orientation of the transport:
Code:
transport.setPosition(pos) transport.setEuler(euler) |
#6
|
|||
|
|||
Hi Jeff,
I'm sorry I'm new to this Vizard. What changes should I make in my update function in my Client? Do you want me to change the e.GrabObject.setPosition(pos) to transport.setPosition(pos) correct on the client script? What changes do I need to make in the server script? I'm sorry for such silly question, but I new to programming as well. I am really sorry for the inconvenience caused Last edited by mihirradia; 02-28-2017 at 09:39 AM. |
#7
|
|||
|
|||
Sorry, it's difficult to help because I don't really understand the code or what you are trying to do. Troubleshooting custom code is beyond the scope of what we can help with on the forum.
I'm not sure this is going to make things work the way you want but to avoid the error remove the transport object, which is called 'GrabObj' in the line below: Code:
viznet.client.sendAll(UPDATE,client=viz.getComputerName(),pos=pos,ori=ori,GrabObj=GrabObj,DisAssPart=DisAssPart ) Maybe there's an easier way of setting this up. Can you explain generally how your application is supposed to work? We can't necessarily provide code but may have suggestions. |
#8
|
|||
|
|||
Hi Jeff,
I have a CAD model that is uploaded in the system. After that I am using the orientation and flying transports from the vizconnect tool to rotate the object in the virtual environment. Now, all I wanted is to do networking between two systems. For example, If I rotate the model in upward direction using transports in the client system, the information should get updated in the server system. I'm able to connect the systems the server displays the message of the client joined and left. But the client is not able to update the information and it is showing me the cPickle error. |
#10
|
|||
|
|||
Hi Jeff,
The sample scripts are working. I did what you told me to do to remove the transport object i.e "GrabObj" after doing that I am getting the below error. |
#11
|
|||
|
|||
Since you are no longer sending the GrabObj object, you can't receive it in the update function. You could try getting a handle to the transport in your script using the following:
Code:
transport = vizconnect.getTransport().getRaw() I can't guarantee that this will help or not. As I mentioned before, to get help with code on the forum it needs to follow the guidelines for posting code. For more in depth assistance, you might contact sales@worldviz.com and they can provide options for custom development and priority support. |
|
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
Client Server Networking Problem | mihirradia | Vizard | 5 | 02-21-2017 09:46 PM |
Client Server Networking Problem | pattie | Vizard | 12 | 07-04-2013 09:11 AM |
networking problem | Chapre | Vizard | 2 | 02-17-2012 08:17 AM |
Problem with server Events | vOliver | Vizard | 2 | 09-15-2010 02:21 PM |
Linking problems with Live Character | Frank Verberne | Vizard | 5 | 06-04-2008 11:42 AM |