3 #include <moveit_msgs/ApplyPlanningScene.h>
4 #include <moveit_msgs/ExecuteTrajectoryGoal.h>
5 #include <moveit_msgs/ExecuteTrajectoryResult.h>
6 #include <moveit_msgs/GetPlanningScene.h>
7 #include <std_srvs/Empty.h>
31 RBX_WARN(
"Failed to open file %s!", filename);
36 request = file.second[
"request"].as<moveit_msgs::MotionPlanRequest>();
37 success = file.second[
"success"].as<
bool>();
38 time = file.second[
"time"].as<
double>();
41 trajectory = file.second[
"trajectory"].as<moveit_msgs::RobotTrajectory>();
52 moveit_msgs::PlanningScene scene_msg;
53 scene->getSceneConst()->getPlanningSceneMsg(scene_msg);
57 node[
"success"] = success ?
"true" :
"false";
88 gpsc_.waitForExistence();
91 apsc_.waitForExistence();
94 co_.waitForExistence();
114 if (!
eac_.isServerConnected())
117 moveit_msgs::ExecuteTrajectoryGoal goal;
120 #if ROBOWFLEX_AT_LEAST_KINETIC
128 RBX_ERROR(
"Trajectory is not parameterized and cannot be executed! did you use "
129 "Trajectory::computeTimeParameterization?");
136 if (!
eac_.waitForResult())
137 RBX_INFO(
"ExecuteTrajectory action returned early");
139 return eac_.getState() == actionlib::SimpleClientGoalState::SUCCEEDED;
144 moveit_msgs::GetPlanningScene::Request request;
145 moveit_msgs::GetPlanningScene::Response response;
146 request.components.components = moveit_msgs::PlanningSceneComponents::ROBOT_STATE |
147 moveit_msgs::PlanningSceneComponents::ROBOT_STATE_ATTACHED_OBJECTS;
149 if (
gpsc_.call(request, response))
151 robot->setState(response.scene.robot_state);
160 moveit_msgs::GetPlanningScene::Request request;
161 moveit_msgs::GetPlanningScene::Response response;
162 request.components.components = moveit_msgs::PlanningSceneComponents::SCENE_SETTINGS |
163 moveit_msgs::PlanningSceneComponents::ROBOT_STATE |
164 moveit_msgs::PlanningSceneComponents::ROBOT_STATE_ATTACHED_OBJECTS |
165 moveit_msgs::PlanningSceneComponents::WORLD_OBJECT_NAMES |
166 moveit_msgs::PlanningSceneComponents::WORLD_OBJECT_GEOMETRY |
167 moveit_msgs::PlanningSceneComponents::OCTOMAP |
168 moveit_msgs::PlanningSceneComponents::TRANSFORMS |
169 moveit_msgs::PlanningSceneComponents::ALLOWED_COLLISION_MATRIX |
170 moveit_msgs::PlanningSceneComponents::LINK_PADDING_AND_SCALING |
171 moveit_msgs::PlanningSceneComponents::OBJECT_COLORS;
173 if (
gpsc_.call(request, response))
175 scene->useMessage(response.scene);
184 moveit_msgs::ApplyPlanningScene::Request request;
185 moveit_msgs::ApplyPlanningScene::Response response;
186 request.scene =
scene->getMessage();
188 return apsc_.call(request, response);
193 std_srvs::EmptyRequest request;
194 std_srvs::EmptyResponse response;
196 return co_.call(request, response);
202 RBX_DEBUG(
"Intercepted request goal ID: `%s`",
id);
207 action.
scene->useMessage(msg.goal.planning_options.planning_scene_diff);
208 action.
request = msg.goal.request;
220 RBX_WARN(
"Intercepted unknown request response ID: `%s`",
id);
224 RBX_DEBUG(
"Intercepted request response ID: `%s`",
id);
226 Action &action = request->second;
228 action.
success = msg.result.error_code.val == moveit_msgs::MoveItErrorCodes::SUCCESS;
229 action.
time = msg.result.planning_time;
230 action.
trajectory = msg.result.planned_trajectory;
MOVEIT_DEPRECATED double getWaypointDurationFromStart(std::size_t index) const
double getWayPointDurationFromStart(std::size_t index) const
std::size_t getWayPointCount() const
void getRobotTrajectoryMsg(moveit_msgs::RobotTrajectory &trajectory) const
Loads information about a robot from the parameter server.
A shared pointer wrapper for robowflex::Robot.
A const shared pointer wrapper for robowflex::Scene.
A shared pointer wrapper for robowflex::Scene.
Wrapper class around the planning scene and collision geometry.
A helper class that allows for pulling and pushing of scenes, robots, and trajectories to move group.
static const std::string EXECUTE
Name of execute trajectory service.
MoveGroupHelper(const std::string &move_group=MOVE_GROUP)
Constructor. Sets up service clients.
bool pushScene(const SceneConstPtr &scene)
Pushes the current planning scene to move group.
ResultCallback callback_
Callback function for move group results.
ros::ServiceClient gpsc_
Get planning scene service.
RobotPtr robot_
Robot on the parameter server used by move group.
ros::ServiceClient co_
Clear octomap service.
void moveGroupGoalCallback(const moveit_msgs::MoveGroupActionGoal &msg)
Callback function for a move group goal.
bool executeTrajectory(const robot_trajectory::RobotTrajectory &path)
Executes a planned trajectory through move group.
ros::Subscriber result_sub_
Move group result subscriber.
ros::Subscriber goal_sub_
Move group goal subscriber.
void setResultCallback(const ResultCallback &callback)
Sets a callback function that is called whenever a motion plan request is serviced by move group.
void moveGroupResultCallback(const moveit_msgs::MoveGroupActionResult &msg)
Callback function for a move group result.
bool pullScene(ScenePtr scene)
Pulls the current planning scene from move group.
~MoveGroupHelper()
Destructor. Cleans up services.
bool pullState(RobotPtr robot)
Pulls the current robot state from move group.
ros::NodeHandle nh_
Node handle.
static const std::string CLEAR_OCTOMAP
Name of clear octomap service.
actionlib::SimpleActionClient< moveit_msgs::ExecuteTrajectoryAction > eac_
static const std::string GET_SCENE
Name of get scene service.
std::map< std::string, Action > requests_
Move group requests.
static const std::string APPLY_SCENE
Name of apply scene service.
static const std::string MOVE_GROUP
Name of move_group namespace.
ros::ServiceClient apsc_
Apply planning scene service.
bool clearOctomap()
Clears the octomap in the planning scene of the movegroup.
#define RBX_WARN(fmt,...)
Output a warning logging message.
#define RBX_ERROR(fmt,...)
Output a error logging message.
#define RBX_INFO(fmt,...)
Output a info logging message.
#define RBX_DEBUG(fmt,...)
Output a debug logging message.
Functions for loading and animating robots in Blender.
bool YAMLToFile(const YAML::Node &node, const std::string &file)
Write the contents of a YAML node out to a potentially new file.
bool isNode(const YAML::Node &node)
Checks if a key exists within a YAML node.
std::pair< bool, YAML::Node > loadFileToYAML(const std::string &path)
Loads a file to a YAML node.
YAML::Node toNode(const geometry_msgs::Pose &msg)
Converts a pose message to YAML.
Move group interaction related classes and features.
Main namespace. Contains all library classes and functions.
Functions for loading and animating scenes in Blender.
A container struct for all relevant information about a motion planning request to move group.
bool success
Planning success.
moveit_msgs::MotionPlanRequest request
Motion planning request.
bool toYAMLFile(const std::string &filename)
Save a recorded action to a YAML file.
bool fromYAMLFile(const std::string &filename)
Load a recorded action from a YAML file.
double time
Planning time.
ScenePtr scene
Scene used for planning.
moveit_msgs::RobotTrajectory trajectory
Planned trajectory on success.
void callback(movegroup::MoveGroupHelper::Action &action)
robot_trajectory::RobotTrajectory trajectory(rmodel,"right_arm")