How to use the code

From Lofaro Lab Wiki
Jump to: navigation, search


the client code needs to be one one computer and the server code needs to be on the other. it is also possible to run the two codes on one machine if you use the computers local network code

Screenshot from 2014-11-27 11.png

in the picture above I opened a terminal window and typed ifconfig as long as you are connected to a network you will see what is shown above that is from a Virtual machine if you are using a full install it might show another part other than eth0 it might show up with a wlan or something like that.

the point is that these codes will need the inet addr: in this example it would be

if you want to run them both on one machine you can use the one in the lo part in this case it would be

Screenshot from 2014-11-27 112.png

the file above is from the servo client code you need to do the ifconfig as above on both computers to find their ip addresses and you will need to put them in these locations in client. you will need to do this in all 3 of these files the server codes will only need their own ip addresses


you most likely need to add a powered usb splitter we attached just the USB2Dynamals and cameras to one computer and it gave the blue screen of Death when using a regular splitter, powered works fine.

The code for the project looks to see how many servos there are on the robot and also looks to see how many are on the controller. one important thing is that the ids of the servos must be in the same order. For example if the robot you see above is ordered from 1-10 left to right then the waist is 11 neck is 12 and the tilt is 13. The ones on the controller must be in that same order you can start from id 20 and go up if you want or you can just keep them the same number as long as they are in the same order they will be ok. The pan and tilt must have the two highest servo ids.

Vision system

OpenCV needs to be installed on the computer to be able to use the streaming video

in these files you will most likely need to change

capture=cv2.VideoCapture(3); its line 12 the things you will need to change is the '3' this has to do with what port the usb camera is plugged into. this will most likely need to be changed in both of them. also the current computers ip address needs to be incerted in the code on line 48 this is what the line will look like

self.wfile.write('<img src=""/>') #this ip is for other computers connecting

on the client computer you would need to go to the web surfer any one will do and type for the left camera and the right camera will be