ROS Resources: Documentation | Support | Discussion Forum | Index | Service Status | ros @ Robotics Stack Exchange |
1 | initial version |
A few things to note:
service
variable to be initialised you're incurring the overhead of communicating with the parameter server by using get_param(..)
there. That's a full XML-RPC session setup, communication (ie: transmit and receive), (de)serialisation and teardown just to read a single parameter.rospy
to always do a full lookup and rebinding of the ServiceProxy
upon invoking it. That is a lot of overhead as the network stack and multiple other nodes are involved (ie: service server and the master).Finally: from this:
This all causes the one service call to result in about 4 ms of delay and I want to get my program to 1 ms precision.
I get two impressions:
If my first impression is correct: don't do that. If you must, only invoke the already initialised (ie: bound) service call in your loop. The rest should be done in the initialisation phase of your script.
For the second: I would personally not use services for something like this, but that is of course your choice and would depend on many things we do not know.
2 | No.2 Revision |
A few things to note:
service
variable to be initialised you're incurring the overhead of communicating with the parameter server by using get_param(..)
there. That's a full XML-RPC session setup, communication (ie: transmit and receive), (de)serialisation and teardown just to read a single parameter.rospy
to always do a full lookup and rebinding of the ServiceProxy
upon invoking it. That is a lot of overhead as the network stack and multiple other nodes are involved (ie: service server and the master).Finally: from this:
This all causes the one service call to result in about 4 ms of delay and I want to get my program to 1 ms precision.
I get two impressions:
If my first impression is correct: don't do that. If you must, only invoke the already initialised (ie: bound) service call in your loop. The rest should be done in the initialisation phase of your script.
For the second: I would personally not use services for something like this, but that is of course your choice and would depend on many things we do not know.
3 | No.3 Revision |
A few things to note:
service
variable to be initialised you're incurring the overhead of communicating with the parameter server by using get_param(..)
there. That's a full XML-RPC session setup, communication (ie: transmit and receive), (de)serialisation and teardown just to read a single parameter.rospy
to always do a full lookup and rebinding of the ServiceProxy
upon invoking it. That is a lot of overhead as the network stack and multiple other nodes are involved (ie: service server and the master).Finally: And from this:
This all causes the one service call to result in about 4 ms of delay and I want to get my program to 1 ms precision.
I get two impressions:
If my first impression is correct: don't do that. If you must, only invoke the already initialised (ie: bound) service call in your loop. The rest should be done in the initialisation phase of your script.
For the second: I would personally not use services for something like this, but that is of course your choice and would depend on many things we do not know.
Finally: in #q328017 you mention the word "real-time". You're most likely already aware, but a standard Python interpreter is not a deterministic runtime environment. rospy
is incapable of deterministic execution, and the TCP/IP based communication system used is also non-deterministic. If "real-time" was meant to say "fast enough", then it's probably possible, but it won't be deterministic.
4 | No.4 Revision |
A few things to note:
service
variable to be initialised you're incurring the overhead of communicating with the parameter server by using get_param(..)
there. That's a full XML-RPC session setup, communication (ie: transmit and receive), (de)serialisation and teardown just to read a single parameter.rospy
to always do a full lookup and rebinding of the ServiceProxy
upon invoking it. That is a lot of overhead as the network stack and multiple other nodes are involved (ie: service server and the master).And from this:
This all causes the one service call to result in about 4 ms of delay and I want to get my program to 1 ms precision.
I get two impressions:
If my first impression is correct: don't do that. If you must, only invoke the already initialised (ie: bound) service call in your loop. The rest should be done in the initialisation phase of your script.
For the second: I would personally not use services for something like this, but that is of course your choice and would depend on many things we do not know.
Finally: in #q328017 you mention the word "real-time". You're most likely already aware, but a standard Python interpreter is not a deterministic runtime environment. rospy
is incapable of deterministic execution, and the TCP/IP based communication system used is also non-deterministic. If "real-time" was meant to say "fast enough", then it's probably possible, but it won't be deterministic.