Commit 287e2291 authored by Nicholas Shindler's avatar Nicholas Shindler
Browse files

clean up hv_bridge

parent b1b3258f
#!/usr/bin/env python
import mp
class Getter: # parent class for setting values
def __init__(self, name, codes, mp):
# constructor for settings class
self.mp = mp
self.codes = codes
self.name = name
def init(self):
# initialize client connection
self.mp.include_probes(self.codes)
def run(self, data):
## Publish data
self.pub.publish(data)
#!/usr/bin/env python
import mp
class Setter: # parent class for setting values
def __init__(self, mp):
# constructor for settings class
self.mp = mp
def init(self, code):
self.code = code
# initialize client connection
self.mp.include_probes(self.code)
def callback(self, msg):
# subscriber callback function
if type(self.code) != tuple:
# if the message is a single item value pair
self.mp.write_probe(self.code, msg)
elif len(msg) > 1:
# handle an array of messages
# each message coresponds to a probe (1 to 1)
# if(msg.length != self.code.length) throw "message size missmatch"
command = []
i = 0
for c in self.code:
command.append((c, msg[i]))
i = i + 1
self.mp.write_probes(command)
else:
# publish the same message to each of the probes
command = []
for c in self.code:
command.append((c, msg))
self.mp.write_probes(command)
......@@ -57,7 +57,7 @@ class LidarListener(Reader):
for elem in strarr:
if elem != "":
datStr += chr(int(elem, 16))
# parse char string as floats
dat = [
struct.unpack("<f", datStr[i : i + 4]) for i in range(0, len(datStr), 4)
......@@ -86,7 +86,7 @@ class LidarListener(Reader):
except TypeError as e:
pass
#rospy.logwarn(e)
# rospy.logwarn(e)
except Exception as e:
# well this is sad
rospy.logerr("error publishing lidar data")
......
......@@ -201,12 +201,12 @@ class HVClient(Client):
(probe_name, probe_type) = Client.lookup_probe(self, t)
if any([lst.needs(probe_name) for lst in self.lstnr]):
val = Client.decode_probe_data(self, probe_type, v)
#print ("New Message[name: " + str(probe_name) + " val: " + str(val) + "]")
# print ("New Message[name: " + str(probe_name) + " val: " + str(val) + "]")
[serv.add(probe_name, val) for serv in self.lstnr]
else:
# msg can be used for debugging. otherwise this block is probably not needed
#rospy.loginfo("Probe info not needed: %s" % probe_name)
# rospy.loginfo("Probe info not needed: %s" % probe_name)
pass
except Exception as e:
......
......@@ -181,7 +181,7 @@ if __name__ == "__main__":
)
while not rospy.is_shutdown():
# write any messages from ROS to the robot
#hv_bot.capture(1 / 200)
# hv_bot.capture(1 / 200)
hv_bot.write()
hv_bot.publish()
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment