MoveIt! - MoveGroupInterface init in C++ class
Hello friends,
im doing an object following stuff. But im stuck with MoveIt programming question. The all in your own MoveIt node starts with making an move_group object like
moveit::planning_interface::MoveGroupInterface move_group("robot");
I need this object to be passed to my own class ArmTrack::ArmTrack(node_handle, move_group);
because im doing some calculating and executing some movements immediately (thus i need to share this move_group
object with all class members).
Initializing move_group
every time when subscriber callback receives data is kind of time consuming for me.
And also i have tried to initialize moveit::planning_interface::MoveGroupInterface move_group("robot");
inside the class constructor via the boost::scoped_ptr
i think it compiles then when node is run it crashes immediately;
BUT somehow i tried i think everything and im getting very sad that is not possible.
Using ROS Melodic, MoveIt!, Gazebo.
Would appreciate any tips-tricks to find solution. Thank you.
Asked by anok on 2020-01-26 16:27:08 UTC
Comments
Hello, Do you create the MGI object inside your function ? I think you should call a pointer if you want to pass a MGI object into class, same thing for NodeHandle. Could you please try to initialize a MGI object and a NodeHandle in your main, and define your class constructor like this : ArmTrack::ArmTrack(ros::nodeHandle& node_handle, moveit::planning_interface::MoveGroupInterface& move_group); I had a similar issue and it worked for me. When you call a variable/object in a function or a class, it creates a copy of this variable. Using a pointer allows your class to modify directly your move_group object and your node_handle, without creating a copy.
Asked by edote on 2020-05-25 02:33:42 UTC