Go to the documentation of this file.00001 #include <ros/ros.h>
00002 #include <sensor_msgs/JointState.h>
00003 #include <map>
00004
00005 #include <actionlib/client/simple_action_client.h>
00006 #include <actionlib/client/terminal_state.h>
00007
00008 #include <path_navigation_msgs/TransformPathExecutionAction.h>
00009 #include <path_navigation_msgs/TransformPathExecutionActionResult.h>
00010 #include <path_navigation_msgs/PathExecutionAction.h>
00011 #include <path_navigation_msgs/PathExecutionActionResult.h>
00012
00013 #include <trajectory_msgs/JointTrajectory.h>
00014 #include <control_msgs/FollowJointTrajectoryAction.h>
00015 #include <control_msgs/FollowJointTrajectoryFeedback.h>
00016
00017 #include <moveit_msgs/RobotTrajectory.h>
00018
00019 #define DEFAULT_TRAJECTORY_ACTION_TOPIC "/joint_trajectory_action"
00020
00021 namespace moveit_controller_multidof {
00022
00035 class RobotTrajectoryExecutor {
00036 public:
00037 typedef actionlib::SimpleActionClient<control_msgs::FollowJointTrajectoryAction> FollowJointTrajectoryActionClient;
00038 typedef actionlib::SimpleActionClient<path_navigation_msgs::PathExecutionAction> PathNavigationActionClient;
00039 typedef typename path_navigation_msgs::PathExecutionGoal PathGoal;
00040 typedef typename path_navigation_msgs::PathExecutionResult PathGoalResult;
00041 typedef typename path_navigation_msgs::PathExecutionResultConstPtr PathGoalResultConstPtr;
00042
00043 typedef typename control_msgs::FollowJointTrajectoryGoal TrajectoryGoal;
00044 typedef typename control_msgs::FollowJointTrajectoryResult TrajectoryGoalResult;
00045
00046
00047 enum ExecStatus {
00048 RUNNING, SUCCEEDED, PREEMPTED, TIMED_OUT, ABORTED, FAILED, UNKNOWN
00049 };
00050 typedef ExecStatus ExecutionStatus;
00051
00059 RobotTrajectoryExecutor(const std::string& _virtual_joint_name,
00060 const std::string _trajectory_action_topic,
00061 const std::string _path_action_topic);
00062
00063 ~RobotTrajectoryExecutor();
00064 bool sendTrajectory(const moveit_msgs::RobotTrajectory &t);
00065
00066 bool cancelExecution();
00067
00068 bool waitForExecution(const ros::Duration & timeout);
00069
00070 ExecutionStatus getLastExecutionStatus();
00071
00072 private:
00073 RobotTrajectoryExecutor(const RobotTrajectoryExecutor& other);
00074
00075 bool connectClients();
00076 bool clientsConnected();
00077
00078
00079 void pathDoneCB(const actionlib::SimpleClientGoalState& state, const PathGoalResultConstPtr& result);
00080
00081
00082 void trajectoryDoneCB(const actionlib::SimpleClientGoalState& state,
00083 const control_msgs::FollowJointTrajectoryResultConstPtr& result);
00084
00085
00086
00087 bool sendTrajectoryActionRequest(const trajectory_msgs::JointTrajectory& trajectory, float waitForResult=-1);
00088
00089 bool sendNavigationActionRequest(const std::vector<geometry_msgs::Transform>& transforms,
00090 const std::string& transforms_frame_id, const float waitForResult,
00091 const std::vector<ros::Duration>& times=std::vector<ros::Duration>());
00092
00093
00094
00095 bool sendNavigationActionRequest(const nav_msgs::Path& p,
00096 const std::string& transforms_frame_id,
00097 const float waitForResult=-1);
00098
00099
00100 void setLastStateFrom(const actionlib::SimpleClientGoalState& state);
00101
00102 bool hasTrajectoryServer() const;
00103
00104 std::string trajectory_action_topic;
00105 std::string path_action_topic;
00106
00107 FollowJointTrajectoryActionClient * joint_trajectory_action_client;
00108 PathNavigationActionClient * path_navigation_action_client;
00109
00110 bool has_path_navigator;
00111 bool has_trajectory_executor;
00112
00113 bool has_current_request;
00114 bool has_current_trajectory;
00115
00116 trajectory_msgs::JointTrajectory current_trajectory;
00117
00118 bool path_running;
00119 bool trajectory_running;
00120
00121
00122 boost::mutex lock;
00123
00124 ExecutionStatus last_exec;
00125
00126 std::string virtual_joint_name;
00127 };
00128
00129 }