Service Server and Client not working when launch by launch file
Hello all.
I am using a pandas data frame to format instructions and the data frame is hosted in a service server. I then have a client that is imported into a position supervising node. The client is a member of the position supervisor class which obviously will pull then next instruction on command.
If I run the parameter setup scripts and then rosrun each of these nodes then everything works as expected. However, I built a launch file and now every time the client is triggered to pull an instruction I get an error saying that the client is receiving a null response from the server.
Error:
[ERROR] [1578864176.167369]: Error processing request: local variable 'resp' referenced before assignment
['Traceback (most recent call last):\n', ' File "/opt/ros/melodic/lib/python2.7/dist-packages/rospy/impl/tcpros_service.py", line 629, in _handle_request\n response = convert_return_to_response(self.handler(request), self.response_class)\n', ' File "/home/mhyde/arm_cws/src/arm_data_frame/src/nodes/dataFrameServer.py", line 66, in handleRequest\n return resp\n', "UnboundLocalError: local variable 'resp' referenced before assignment\n"]
[ERROR] [1578864176.177881]: bad callback: <bound method positionSupervisor.arduinoStateCallback of <__main__.positionSupervisor object at 0x7fbb19878650>>
Traceback (most recent call last):
File "/opt/ros/melodic/lib/python2.7/dist-packages/rospy/topics.py", line 750, in _invoke_callback
cb(msg)
File "/home/mhyde/arm_cws/src/position_supervisor/src/nodes/positionSupervisor.py", line 99, in arduinoStateCallback
self.pullInstruction()
File "/home/mhyde/arm_cws/src/position_supervisor/src/nodes/positionSupervisor.py", line 52, in pullInstruction
self.instruction = self.instructionClient.client()
File "/home/mhyde/arm_cws/src/arm_data_frame/src/arm_data_frame/dataFrameClient.py", line 52, in client
return coor.motionType, coor.xCoor, coor.yCoor, coor.zCoor, coor.velFac, coor.accFac
AttributeError: 'NoneType' object has no attribute 'motionType'
Again, if I rosrun the dataFrameServer and the positionSupervisor and then manually publish to /arduinoState then everything works perfectly. I only get this error if I launch the dataFrame and Supervisor in a launch file.
Launch File:
<launch>
<node name="dataFrameServer" pkg="arm_data_frame" type="dataFrameServer.py" />
<node name="positionSupervisorParams" pkg="position_supervisor" type="positionSupervisorParams.py" />
<node name="positionSupervisor" pkg="position_supervisor" type="positionSupervisor.py" />
</launch>
I did try removing nodes from the launch file and it appears the issue is coming from including the position supervisor in the launch file. When I remove it, run the launch file, and then rosrun the positionSupervisor then everything works well.
Below is the code for everything involved. I don't think the param files are casuing the issues.
Server:
#!/home/mhyde/vEnvs/rosPy/bin/python
'''
ROS Service - Server:
Feeds Coors from the CSV File to
the Data Handler upon service request.
Implements a Pandas DataFrame to contain
Coor information as well as actuator
and motion commands.
'''
import rospy
from arm_msgs.srv import instructionPass, \
instructionPassResponse
from pandas import DataFrame, read_csv
class server(object):
'''
Coor Distributor
topic = /instructionPass
node = /instructionPassServer
'''
def __init__(self, filePath):
self.roboRoutine = DataFrame(read_csv(filePath, sep=","))
self.index = 0
self.instructionCount = 0
def countInstructions(self):
'''
Counts the amount of Coors
in routine
'''
self.instructionCount = self.roboRoutine ...