There is a solution. Create a class that has a MoveGroup
attribute, initialized with the constructor.
Moreover you can implement several service functions in that class which are acting on the same move_group
attribute.
This is my post and answer related how to do it.
Here is my working example for a cyton gamma 1500 robot arm.
EDIT
If you really want to share objects through applications have a look at this (not really related to ROS but c++).
Originally posted by zweistein with karma: 231 on 2015-11-02
This answer was ACCEPTED on the original site
Post score: 1
Original comments
Comment by donmrsir on 2015-11-03:
Ty for the answer! It looks to me (If i correctly undestood your code/answer), that this not the solution for my problem, since what you get doing that is that the move_group class is defined for all of the services and fuctions in your node
Comment by donmrsir on 2015-11-03:
My problem is that i want to use the same move_group in different nodes . Right now i have to init a new move_group every time i call a new node, that takes a lot of time, also i dont know if this can cause any problems.
Comment by zweistein on 2015-11-03:
I can't see the reason to have multiple nodes having the same move_group class. I doubt that you can share this object over multiple nodes (source codes c++ or python). Why do you need more than one node to control the arm?
Comment by zweistein on 2015-11-03:
By using multi-threading in a node, you can have multiple services (service servers) running in parallel. You can even define multiple node handles and run them asynchronously. Hence, you don't need more than one node. An object created in a program is not designed to get shared as a resource.
Comment by donmrsir on 2015-11-03:
The reason why i needed to use more than one node, was because this way my system would work in a more intuitive way. But yes maybe is better to just use one node with a lot of services for simplicity, i will give it a try.
Comment by donmrsir on 2015-11-03:
Anyway im taking this question as the correct one, since the link you posted seems to me like a good point to start researching about this problem.