Commit 2527362d authored by Nicholas Shindler's avatar Nicholas Shindler
Browse files

create launch files, update reader/writer base classes

parent 2343dc1f
class Reader():
# reader class for getting data from the robot and passing to ROS
def __init__(self):
pass
def run(self):
# runs a listener thread, reading in data and placing it in a queue
def __init__(self, name, p):
# constructor for settings class
self.probes = p
self.name = name
self.queue = {}
for label in p:
self.queue[label] = 0
def run(self, data):
## Publish data
self.pub.publish(data)
def add(name, val):
# add data piece
try:
while True:
# Wait for incoming data from the RCP or for the listener
# pipe to close, indicating that we are
(r, w, x) = select.select((self.client.s, self.client.listener_pipe[0]), (), ())
if self.client.listener_pipe[0] in r:
# listener pipe signaled the thread to exit
os.close(self.client.listener_pipe[0])
return
if self.client.s in r:
(t, l, v) = self.client.receive_next_message()
if not self.client.do_async_message(t, l, v):
self.q.put((t, l, v))
try:
if self.callback == None:
raise NameError("No Callback has been defined")
self.callback(t,v)
except NameError:
pass
# time.sleep(0.1)
self.queue[name] = val
except Exception as e:
raise e
def needs(name):
# check if name is used by this class
return True if name in self.probes else False
def get_probes():
# return an array of all probes
return self.probes
class Reader():
# reader class for getting data from the robot and passing to ROS
def __init__(self):
pass
def run(self):
# runs a listener thread, reading in data and placing it in a queue
try:
while True:
# Wait for incoming data from the RCP or for the listener
# pipe to close, indicating that we are
(r, w, x) = select.select((self.client.s, self.client.listener_pipe[0]), (), ())
if self.client.listener_pipe[0] in r:
# listener pipe signaled the thread to exit
os.close(self.client.listener_pipe[0])
return
if self.client.s in r:
(t, l, v) = self.client.receive_next_message()
if not self.client.do_async_message(t, l, v):
self.q.put((t, l, v))
try:
if self.callback == None:
raise NameError("No Callback has been defined")
self.callback(t,v)
except NameError:
pass
# time.sleep(0.1)
except Exception as e:
raise e
def __init__(self, p):
# constructor for settings class
self.probes = p
def get_msgs():
# collect the messages to send
return self.msgs
def callback(self, msg):
# subscriber callback function
if type(self.code) != tuple:
# if the message is a single item value pair
self.msgs = [(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.msgs = command
else:
# publish the same message to each of the probes
command = []
for c in self.code:
command.append((c, msg))
self.msgs = command
<launch>
<node name="main_node.py" pkg="hv_bridge" type="bridge" args="--all" />
<node name="harvey_node" pkg="harvey" type="talker" />
</launch>
<launch>
<node name="main_node.py" pkg="hv_bridge" type="bridge" args="--all" />
</launch>
<launch>
<node name="main_node.py" pkg="hv_bridge" type="bridge" args="--controllers" />
<node name="teleop_node.py" pkg="hv_teleop" type="talker" />
</launch>
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