7
7
8
8
name = 'BeaglePotBlack'
9
9
10
- num_chars = [ '1' , '2' , '3' , '4' , '5' , '6' , '7' , '8' , '9' , '0' ]
10
+ conversion_factor = 0.0174532925 # multiply to get degrees from radians
11
11
12
12
port = 4774 # port of the data broadcast
13
13
buff = 1024 # maximum size of the data from the BBB
@@ -59,7 +59,6 @@ def display():
59
59
glRotatef (180 ,1 ,0 ,0 ) # The teapot is upside down by default
60
60
glRotatef (90 ,0 ,1 ,0 ) # Make it face spout forward
61
61
####
62
- # These next three should now be in the correct order
63
62
global yaw , roll , pitch
64
63
glRotatef (yaw ,1 ,0 ,0 )
65
64
glRotatef (roll ,0 ,1 ,0 )
@@ -73,8 +72,7 @@ def display():
73
72
return
74
73
75
74
def animate ():
76
- ####
77
- #Get data gets the values that are being broadcast over udp.
75
+ #gets the values that are being broadcast over udp.
78
76
global roll , pitch , yaw
79
77
[yaw , roll , pitch ] = get_data ()
80
78
glutPostRedisplay ()
@@ -91,18 +89,9 @@ def get_data():
91
89
if not sock :
92
90
make_sock ()
93
91
result = select .select ([sock ],[],[])
94
- msg = result [0 ][0 ].recv (buff )
95
- current_float_string = "" #hold the current float in string while it is constructed
96
- float_array = [] #array to be returned
97
- for char in msg :
98
- if char == ',' :
99
- float_array .append (float (current_float_string ))
100
- current_float_string = ""
101
- elif char == '\0 ' : #assuming that packet contains '\0' on the end, may be wrong
102
- float_array .append (float (current_float_string ))
103
- return float_array
104
- elif char in num_chars :
105
- current_float_string .append (char )
106
- return [0 , 0 , 0 ]
92
+ packet = result [0 ][0 ].recv (buff )
93
+ exploded = packet .split ("," )
94
+ return (conversion_factor * float (exploded [0 ]), conversion_factor * float (exploded [1 ]), conversion_factor * float (exploded [2 ]))
95
+
107
96
108
97
if __name__ == '__main__' : main ()
0 commit comments