Skip to content

Commit

Permalink
Delete createRobotModel(). Minor cleanup.
Browse files Browse the repository at this point in the history
  • Loading branch information
AndyZe committed Mar 23, 2023
1 parent a6a1ccc commit 22a5fbc
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 31 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -42,16 +42,6 @@

namespace planning_scene
{

/**
* Helper function to create a RobotModel from a urdf/srdf.
* @param urdf_model The universal robot description
* @param srdf_model The semantic robot description
* @return nullptr on failure
*/
moveit::core::RobotModelPtr createRobotModel(const urdf::ModelInterfaceSharedPtr& urdf_model,
const srdf::ModelConstSharedPtr& srdf_model);

/**
* convert Pose msg to Eigen::Isometry, normalizing the quaternion part if necessary.
* @param msg Input message
Expand Down
7 changes: 5 additions & 2 deletions moveit_core/planning_scene/src/planning_scene.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -136,9 +136,12 @@ PlanningScene::PlanningScene(const urdf::ModelInterfaceSharedPtr& urdf_model,
if (!srdf_model)
throw moveit::ConstructException("The SRDF model cannot be nullptr");

robot_model_ = createRobotModel(urdf_model, srdf_model);
if (!robot_model_)
robot_model_ = std::make_shared<moveit::core::RobotModel>(urdf_model, srdf_model);
if (!robot_model_ || !robot_model_->getRootJoint())
{
robot_model_ = nullptr;
throw moveit::ConstructException("Could not create RobotModel");
}

initialize();
}
Expand Down
20 changes: 1 addition & 19 deletions moveit_core/planning_scene/src/utilities.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -44,29 +44,11 @@ namespace
static const rclcpp::Logger LOGGER = rclcpp::get_logger("moveit_planning_scene.utilities");
}

moveit::core::RobotModelPtr createRobotModel(const urdf::ModelInterfaceSharedPtr& urdf_model,
const srdf::ModelConstSharedPtr& srdf_model)
{
auto robot_model = std::make_shared<moveit::core::RobotModel>(urdf_model, srdf_model);
if (!robot_model || !robot_model->getRootJoint())
return moveit::core::RobotModelPtr();

return robot_model;
}

void poseMsgToEigen(const geometry_msgs::msg::Pose& msg, Eigen::Isometry3d& out)
{
Eigen::Translation3d translation(msg.position.x, msg.position.y, msg.position.z);
Eigen::Quaterniond quaternion(msg.orientation.w, msg.orientation.x, msg.orientation.y, msg.orientation.z);
if ((quaternion.x() == 0) && (quaternion.y() == 0) && (quaternion.z() == 0) && (quaternion.w() == 0))
{
RCLCPP_WARN(LOGGER, "Empty quaternion found in pose message. Setting to neutral orientation.");
quaternion.setIdentity();
}
else
{
quaternion.normalize();
}
quaternion.normalize();
out = translation * quaternion;
}

Expand Down

0 comments on commit 22a5fbc

Please sign in to comment.