Declaring moveit robot model in header file
Hello everyone, I am new to C++ with ROS and would love to get some help. Currently, I am trying to write a C++ class object. In the class, I want to share a moveit robot model so I can use it among different function. Like this:
robot.cpp
#include <iostream>
#include <moveit/robot_model_loader/robot_model_loader.h>
#include <moveit/robot_model/robot_model.h>
#include <moveit/robot_state/robot_state.h>
#include "robot.h"
LoadRobot::LoadRobot()
{
// Load robot model
robot_model_loader::RobotModelLoader robot_model_loader("robot_description");
robot_model::RobotModelPtr kinematic_model = robot_model_loader.getModel();
}
void LoadRobot::create_group(){
const robot_state::JointModelGroup* joint_model_group = kinematic_model->getJointModelGroup("panda_arm");
//do something with joint_model_group ...
}
robot.h
#ifndef _ROBOT
#define _ROBOT
class LoadRobot{
public:
LoadRobot();
void create_group();
};
#endif
However, the LoadRobot constructor cannot pass kinematic_model
to create_group()
. What should I do instead? Should I put what's in the constructor to the header file and make them private?