keep RobotModelLoader around

Otherwise the robot_model_ does not remain valid
This commit is contained in:
v4hn 2018-06-01 11:12:47 +02:00 committed by Robert Haschke
parent a745f55ab7
commit 1a4f6c0e57
2 changed files with 7 additions and 2 deletions

View File

@ -51,6 +51,10 @@ namespace moveit { namespace core {
MOVEIT_CLASS_FORWARD(RobotState) MOVEIT_CLASS_FORWARD(RobotState)
}} }}
namespace robot_model_loader {
MOVEIT_CLASS_FORWARD(RobotModelLoader)
}
namespace moveit { namespace task_constructor { namespace moveit { namespace task_constructor {
MOVEIT_CLASS_FORWARD(Stage) MOVEIT_CLASS_FORWARD(Stage)
@ -140,6 +144,7 @@ protected:
private: private:
std::string id_; std::string id_;
robot_model_loader::RobotModelLoaderPtr robot_model_loader_;
moveit::core::RobotModelConstPtr robot_model_; moveit::core::RobotModelConstPtr robot_model_;
bool preempt_requested_; bool preempt_requested_;

View File

@ -109,8 +109,8 @@ void Task::setRobotModel(const core::RobotModelConstPtr& robot_model)
} }
void Task::loadRobotModel(const std::string& robot_description) { void Task::loadRobotModel(const std::string& robot_description) {
robot_model_loader::RobotModelLoader rml(robot_description); robot_model_loader_ = std::make_shared<robot_model_loader::RobotModelLoader>(robot_description);
setRobotModel(rml.getModel()); setRobotModel(robot_model_loader_->getModel());
if (!robot_model_) if (!robot_model_)
throw Exception("Task failed to construct RobotModel"); throw Exception("Task failed to construct RobotModel");
} }