|
|
(19 intermediate revisions by the same user not shown) |
Line 2: |
Line 2: |
| | | |
| This is MiniBot it is the robot that we maid for out Senior design project. | | This is MiniBot it is the robot that we maid for out Senior design project. |
− |
| |
| ---- | | ---- |
− | '''Networking'''
| + | ==Tutorials== |
− | we used [https://docs.python.org/2/library/socket.html import socket] for sending information over a network with a client and a server
| + | * [[python library for dynamixel servos]] |
− | | + | * [[Networking/import socket]] |
− | ''server''
| + | * [[haptic feedback ax-12a code]] |
− | | + | * [[cad files for solidworks and stl type also ax-12a model and baxter]] |
− | the code for the server is
| + | |
− | | + | |
− | -host = '192.168.0.102' #gets comp ip address
| + | |
− | | + | |
− | -port = 20000 #random port this can be set to almost anything between 1023 and 6000 ish once you start a server if you need to restart it you will need to close that terminal and open a new one so the port will no longer be in use
| + | |
− | | + | |
− | -s = socket.socket(socket.AF_INET, socket.SOCK_DGRAM) this part is what tells the socket what kind of data we want to use AF_INET tells network/internet and sock_DGRAM tells it to use udp packets (these are somewhat unstable as they are not checked) | + | |
− | | + | |
− | -s.bind((str(host), port)) #binds s to the server so it can be called
| + | |
| | | |
− | -data, addr = s.recvfrom(1024) this tells the program to wait till it gets a packet from the client the 1024 can be lowered but should be in base 2 if you leave it at 1024 it will be fine it just tells it to take data that is only 1024 or less
| |
− | host = '192.168.0.102'
| |
− | port = 20000
| |
− | s = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
| |
− | s.bind((str(host), port))
| |
| | | |
− | ''client''
| + | ==Code== |
− | this makes it so that if a port is taken it will try for a new port if one fails only works for client because server must be known
| + | * [[How to use the code]] |
− | x=1 #just a constant for the while loop
| + | * [http://WDMyCloud.device1083053.wd2go.com/api/1.0/rest/dir_contents/Public/Lofaro%20labs/e/server?device_user_id=9466339&request_auth_code=fd228b2b4791d42dc2a2195409b171726732655f2a9d933048105025f03771b5 Server] |
− | host = '192.168.0.111' #this is the current computers IP
| + | * [http://WDMyCloud.device1083053.wd2go.com/api/1.0/rest/dir_contents/Public/Lofaro%20labs/e/client?device_user_id=9466339&request_auth_code=4103245befd8acf07f6af168195e619a49ad1c8cf3f57d549fdad5498d77efe2 client] |
− | port = 21111 #this is just a random port number
| + | |
− | server = ('192.168.0.102',20000) #tells the computer where to listen and send the IP address in this one should match the computer above
| + | |
− | s = socket.socket(socket.AF_INET, socket.SOCK_DGRAM) #tells to use network/udp
| + | |
− | while (x == 1):
| + | |
− | try:
| + | |
− | print port
| + | |
− | s.bind((host, port)) #trys this port if it is taken then moves on to a new port
| + | |
− | x=0
| + | |
− | except IOError:
| + | |
− | port+=1
| + | |
− | else:
| + | |
− | port+=1
| + | |
This is MiniBot it is the robot that we maid for out Senior design project.