joint_trajectory_action.h
Go to the documentation of this file.
1 /*
2  * Software License Agreement (BSD License)
3  *
4  * Copyright (c) 2014, Fraunhofer IPA
5  * Author: Thiago de Freitas
6  *
7  * All rights reserved.
8  *
9  * Redistribution and use in source and binary forms, with or without
10  * modification, are permitted provided that the following conditions are met:
11  *
12  * * Redistributions of source code must retain the above copyright
13  * notice, this list of conditions and the following disclaimer.
14  * * Redistributions in binary form must reproduce the above copyright
15  * notice, this list of conditions and the following disclaimer in the
16  * documentation and/or other materials provided with the distribution.
17  * * Neither the name of the Fraunhofer IPA, nor the names
18  * of its contributors may be used to endorse or promote products derived
19  * from this software without specific prior written permission.
20  *
21  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
22  * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
23  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
24  * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
25  * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
26  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
27  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
28  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
29  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
30  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
31  * POSSIBILITY OF SUCH DAMAGE.
32  */
33 
34 #ifndef MOTOMAN_DRIVER_INDUSTRIAL_ROBOT_CLIENT_JOINT_TRAJECTORY_ACTION_H
35 #define MOTOMAN_DRIVER_INDUSTRIAL_ROBOT_CLIENT_JOINT_TRAJECTORY_ACTION_H
36 
37 #include <map>
38 #include <vector>
39 #include <string>
40 
41 #include <ros/ros.h>
43 
44 #include <trajectory_msgs/JointTrajectory.h>
45 #include <control_msgs/FollowJointTrajectoryAction.h>
46 #include <control_msgs/FollowJointTrajectoryFeedback.h>
47 #include <industrial_msgs/RobotStatus.h>
49 #include <motoman_msgs/DynamicJointTrajectory.h>
51 {
52 namespace joint_trajectory_action
53 {
54 
55 class JointTrajectoryAction
56 {
57 public:
63 
69 
73  bool init();
74  void run()
75  {
76  ros::spin();
77  }
78 
79 private:
81 
87 
91  JointTractoryActionServer action_server_;
92 
97 
98  std::map<int, ros::Publisher> pub_trajectories_;
99 
100  std::map<int, RobotGroup> robot_groups_;
101 
107 
108  std::map<int, ros::Subscriber> sub_trajectories_;
109 
115 
116  std::map<int, ros::Subscriber> sub_status_;
117 
118  std::map<int, JointTractoryActionServer*> act_servers_;
124 
125  std::map<int, ros::Timer>watchdog_timer_map_;
126 
130  bool has_active_goal_;
131 
132  std::map<int, bool> has_active_goal_map_;
133 
138 
139  std::map<int, JointTractoryActionServer::GoalHandle> active_goal_map_;
143  trajectory_msgs::JointTrajectory current_traj_;
144 
145  std::map<int, trajectory_msgs::JointTrajectory> current_traj_map_;
146 
147  std::vector<std::string> all_joint_names_;
148 
153  static const double DEFAULT_GOAL_THRESHOLD_; // = 0.01;
154 
162  double goal_threshold_;
163 
169  std::vector<std::string> joint_names_;
170 
174  control_msgs::FollowJointTrajectoryFeedbackConstPtr last_trajectory_state_;
175 
176  std::map<int, control_msgs::FollowJointTrajectoryFeedbackConstPtr> last_trajectory_state_map_;
177 
182  bool trajectory_state_recvd_;
183 
184  std::map<int, bool> trajectory_state_recvd_map_;
185 
189  industrial_msgs::RobotStatusConstPtr last_robot_status_;
190 
194  static const double WATCHD0G_PERIOD_; // = 1.0;
195 
202  void watchdog(const ros::TimerEvent &e);
203 
204  void watchdog(const ros::TimerEvent &e, int group_number);
205 
214 
231  void goalCB(JointTractoryActionServer::GoalHandle gh, int group_number);
232 
240  void cancelCB(JointTractoryActionServer::GoalHandle gh, int group_number);
248  void controllerStateCB(const control_msgs::FollowJointTrajectoryFeedbackConstPtr &msg);
249 
250  void controllerStateCB(const control_msgs::FollowJointTrajectoryFeedbackConstPtr &msg, int robot_id);
251 
252 
260  void robotStatusCB(const industrial_msgs::RobotStatusConstPtr &msg);
261 
268  void abortGoal();
269 
270  void abortGoal(int robot_id);
271 
282  bool withinGoalConstraints(const control_msgs::FollowJointTrajectoryFeedbackConstPtr &msg,
283  const trajectory_msgs::JointTrajectory & traj);
284 
285  bool withinGoalConstraints(const control_msgs::FollowJointTrajectoryFeedbackConstPtr &msg,
286  const trajectory_msgs::JointTrajectory & traj, int robot_id);
287 };
288 
289 } // namespace joint_trajectory_action
290 } // namespace industrial_robot_client
291 
292 #endif // MOTOMAN_DRIVER_INDUSTRIAL_ROBOT_CLIENT_JOINT_TRAJECTORY_ACTION_H
293 
void robotStatusCB(const industrial_msgs::RobotStatusConstPtr &msg)
ServerGoalHandle< control_msgs::FollowJointTrajectoryAction > GoalHandle
ROSCPP_DECL void spin(Spinner &spinner)
ros::Publisher pub_trajectory_command_
Publishes desired trajectory (typically to the robot driver)
control_msgs::FollowJointTrajectoryFeedbackConstPtr last_trajectory_state_
Cache of the last subscribed feedback message.
industrial_msgs::RobotStatusConstPtr last_robot_status_
Cache of the last subscribed status message.
double goal_threshold_
The goal joint threshold used for determining if a robot is near it final destination. A single value is used for all joints.
std::vector< std::string > joint_names_
The joint names associated with the robot the action is interfacing with. The joint names must be the...
static const double DEFAULT_GOAL_THRESHOLD_
The default goal joint threshold see(goal_threshold). Unit are joint specific (i.e. radians or meters).
actionlib::ActionServer< control_msgs::FollowJointTrajectoryAction > JointTractoryActionServer
ros::Subscriber sub_robot_status_
Subscribes to the robot status (typically published by the robot driver).
ros::Timer watchdog_timer_
Watchdog time used to fail the action request if the robot driver is not responding.
ros::Subscriber sub_trajectory_state_
Subscribes to trajectory feedback (typically published by the robot driver).
bool withinGoalConstraints(const control_msgs::FollowJointTrajectoryFeedbackConstPtr &msg, const trajectory_msgs::JointTrajectory &traj)
JointTractoryActionServer::GoalHandle active_goal_
Cache of the current active goal.
trajectory_msgs::JointTrajectory current_traj_
Cache of the current active trajectory.
void controllerStateCB(const control_msgs::FollowJointTrajectoryFeedbackConstPtr &msg)


motoman_driver
Author(s): Jeremy Zoss (Southwest Research Institute), Ted Miller (MotoROS) (Yaskawa Motoman), Eric Marcil (MotoROS) (Yaskawa Motoman)
autogenerated on Sat May 8 2021 02:27:43