strands-project/strands_qsr_lib

QSR lib ros client

Closed this issue · 2 comments

@yianni I have a question about the ros client:

Is this meant as a tool that can be used like in the ros_example_client.py to have an easy way of interfacing the ros service without bothering about the topics and service type? Because if it is, which would be great, then this line has to go into the ros_example_client.py. The reason being, if you want to create a ros node that calls this you will most likely have to have a call to init_node as well. ROS sadly doesn't like two of those in a single node. If you don't mind I will fix this.

@cdondrup

Yes, the aim of ros_example_client.py is to provide a seamless and easy way for calling the service without needing to know the underlying details.

Regarding your question. A client doesn't really need an init_node. However, judging by the comment I have left, without the init_node there I was having trouble with get_rostime in this line. I have to run the code again to see the effect of leaving it out as I can't recall whether it was giving messy times or didn't run at all.

Nevertheles, do you mean that ROS doesn't like something as following:

def foo():
  init_node('foo')
  cl = whatever_the_class_name_is()

when whatever_the_class_name_is is having an init_node in its constructor?

If that's the case, then I would suggest yes feel free to move it (or I can do it over the weekend). Still will need to test it, so if you go ahead please let me know... maybe close this ticket and open a new one with testing/issue label and assign it to me to have a look at it.

This helps?

That is exactly the issue. You are only allowed to call init_node once. As you correctly stated, if you don't do that you cannot call any rospy functions which is the reason this the is first line of code in all ROS nodes. Therefore, you should rely on the fact that someone has called init_node before trying to create an instance of the qsr ros client.
I moved the call to the executable ros_example_client which is the way it should be done normally. I tested all this for QTC and it works fine. I went ahead with this already because it is a necessary change for the qsr ros client class to be useful at all.