ROS Resources: Documentation | Support | Discussion Forum | Index | Service Status | ros @ Robotics Stack Exchange
Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

That's not ROS related but only C++, I would advise to start learning the language first and then come back to ROS.

As for your question if you want to have an object of type moveit::planning_interface::MoveGroupInterface you will need to declare an attribute pointing to an object of this type because if you don't the object will be destroyed at the end of the function (in your case the constructor). With a pointer the memory is allocated until you call delete :

#include <moveit/move_group_interface/move_group_interface.h>

class Move_operations_class 
{
    public:
        //Constructor
        Move_operations_class(const std::string &move_group_name) 
        {
            //Now DEFINE your pointer to MoveGroupInterface object
            move_group_ptr_ = new moveit::planning_interface::MoveGroupInterface(move_group_name);
        };

       //Destructor to dealocate memory
        ~Move_operations_class()
       {
           delete move_group_ptr_;
       }

        //DECLARE the pointer
        moveit::planning_interface::MoveGroupInterface *move_group_ptr_;
};

int main(int argc, char** argv)
{
    //ROS init

    Move_operations_class move_group_main("arm_torso");
    move_group_main.move_group_ptr_->setPoseReferenceFrame("base_footprint");

    return 0;
}