choreo_execution_gatekeeper_service.cpp
Go to the documentation of this file.
1 //
2 // Created by yijiangh on 7/10/17.
3 //
4 
6 
7 #include <choreo_msgs/TrajectoryExecution.h>
8 
9 #include "execution_utils.h"
10 #include <boost/thread.hpp>
11 
12 #include <ros/topic.h>
13 
14 const static std::string SIMULATION_SERVICE_NAME = "simulation_execution";
15 const static std::string PROCESS_EXE_ACTION_SERVER_NAME = "choreo_execution_as";
16 
18  : nh_(nh),
19  process_exe_action_server_(nh_,
21  boost::bind(&choreo_execution_gatekeeper::ExecutionGatekeeper::executionCallback, this, _1),
22  false)
23 {
24  // Trajectory Simulation Service
25  sim_client_ = nh_.serviceClient<choreo_msgs::TrajectoryExecution>(SIMULATION_SERVICE_NAME);
26 
27  // The generic process execution service
29 }
30 
32  const choreo_msgs::ProcessExecutionGoalConstPtr &goal)
33 {
34  choreo_msgs::ProcessExecutionResult res;
35  if (goal->simulate)
36  {
37  res.success = simulateProcess(goal);
38  }
39 
41 }
42 
44  const choreo_msgs::ProcessExecutionGoalConstPtr &goal)
45 {
46  choreo_msgs::TrajectoryExecution exe_srv;
47  exe_srv.request.wait_for_execution = true;
48 
49  for(auto jts : goal->joint_traj_array)
50  {
51  if (exe_srv.request.trajectory.points.empty())
52  {
53  exe_srv.request.trajectory = jts;
54  }
55  else
56  {
57  appendTrajectory(exe_srv.request.trajectory, jts);
58  }
59  }
60 
61  // this action call is directed to choreo_simulation_execution
62  if (!sim_client_.call(exe_srv))
63  {
64  ROS_ERROR("[Execution GateKeeper] Execution client unavailable or unable to execute trajectory.");
65  return false;
66  }
67 
68  return true;
69 }
ServiceClient serviceClient(const std::string &service_name, bool persistent=false, const M_string &header_values=M_string())
bool simulateProcess(const choreo_msgs::ProcessExecutionGoalConstPtr &goal)
actionlib::SimpleActionServer< choreo_msgs::ProcessExecutionAction > process_exe_action_server_
bool call(MReq &req, MRes &res)
void appendTrajectory(trajectory_msgs::JointTrajectory &original, const trajectory_msgs::JointTrajectory &next)
void setSucceeded(const Result &result=Result(), const std::string &text=std::string(""))
void executionCallback(const choreo_msgs::ProcessExecutionGoalConstPtr &goal)
static const std::string PROCESS_EXE_ACTION_SERVER_NAME
static const std::string SIMULATION_SERVICE_NAME
#define ROS_ERROR(...)


choreo_execution_gatekeeper
Author(s):
autogenerated on Thu Jul 18 2019 03:59:24