21 #include <boost/lexical_cast.hpp> 24 #include <std_srvs/Trigger.h> 25 #include <cob_srvs/SetString.h> 35 ROS_ERROR(
"Parameter 'chain_tip_link' not set");
41 ROS_ERROR(
"Parameter 'reference_frame' not set");
53 ROS_WARN(
"Parameter 'target_frame' not set. Using default 'cartesian_target'");
61 stop_tracking_.waitForExistence();
72 ROS_INFO(
"Cartesian Controller running");
80 cob_srvs::SetString start;
88 success = start.response.success;
91 ROS_INFO(
"Response 'start_tracking': succeded");
96 ROS_ERROR(
"Response 'start_tracking': failed");
101 ROS_ERROR(
"Failed to call service 'start_tracking'");
116 std_srvs::Trigger stop;
123 ROS_INFO(
"Service 'stop' succeded!");
128 ROS_ERROR(
"Failed to call service 'stop_tracking'");
146 for (
unsigned int i = 0; i < cartesian_path.poses.size(); i++)
148 if (!
as_->isActive())
156 cartesian_path.poses.at(i).position.y,
157 cartesian_path.poses.at(i).position.z));
159 cartesian_path.poses.at(i).orientation.y,
160 cartesian_path.poses.at(i).orientation.z,
161 cartesian_path.poses.at(i).orientation.w));
175 geometry_msgs::PoseArray cartesian_path;
180 if (action_struct.
move_type == cob_cartesian_controller::CartesianControllerGoal::LIN)
185 actionAbort(
false,
"Failed to do interpolation for 'move_lin'");
207 actionAbort(
false,
"Failed to execute path for 'move_lin'");
220 else if (action_struct.
move_type == cob_cartesian_controller::CartesianControllerGoal::CIRC)
224 actionAbort(
false,
"Failed to do interpolation for 'move_circ'");
241 actionAbort(
false,
"Failed to execute path for 'move_circ'");
263 geometry_msgs::Pose start, end;
269 move_lin.
start = start;
277 geometry_msgs::Pose center;
282 move_circ.
end_angle = move_circ_msg.end_angle;
283 move_circ.
radius = move_circ_msg.radius;
293 action_struct.
move_type = goal->move_type;
295 action_struct.
profile.
vel = goal->profile.vel;
301 if (action_struct.
move_type == cob_cartesian_controller::CartesianControllerGoal::LIN)
305 else if (action_struct.
move_type == cob_cartesian_controller::CartesianControllerGoal::CIRC)
311 actionAbort(
false,
"Unknown trajectory action " + boost::lexical_cast<std::string>(action_struct.
move_type));
314 return action_struct;
ServiceClient serviceClient(const std::string &service_name, bool persistent=false, const M_string &header_values=M_string())
boost::shared_ptr< TrajectoryInterpolator > trajectory_interpolator_
ros::ServiceClient start_tracking_
std::string action_name_
Action interface.
void previewPath(const geometry_msgs::PoseArray pose_array)
unsigned int profile_type
cob_cartesian_controller::CartesianActionStruct acceptGoal(boost::shared_ptr< const cob_cartesian_controller::CartesianControllerGoal > goal)
bool call(MReq &req, MRes &res)
geometry_msgs::Pose start
actionlib::SimpleActionServer< cob_cartesian_controller::CartesianControllerAction > SAS_CartesianControllerAction_t
void actionPreempt(const bool success, const std::string &message)
cob_cartesian_controller::MoveLinStruct convertMoveLin(const cob_cartesian_controller::MoveLin &move_lin_msg)
CartesianControllerUtils utils_
std::string chain_tip_link_
tf::TransformBroadcaster tf_broadcaster_
def move_circ(pose_center, frame_id, start_angle, end_angle, radius, profile)
bool waitForExistence(ros::Duration timeout=ros::Duration(-1))
#define ROS_WARN_STREAM(args)
geometry_msgs::Pose pose_center
#define DEFAULT_CARTESIAN_TARGET
void transformPose(const std::string source_frame, const std::string target_frame, const geometry_msgs::Pose pose_in, geometry_msgs::Pose &pose_out)
geometry_msgs::Pose getPose(const std::string &target_frame, const std::string &source_frame)
bool posePathBroadcaster(const geometry_msgs::PoseArray &cartesian_path)
#define ROS_INFO_STREAM(args)
def move_lin(pose_goal, frame_id, profile)
bool getParam(const std::string &key, std::string &s) const
ros::ServiceClient stop_tracking_
boost::shared_ptr< SAS_CartesianControllerAction_t > as_
void goalCallback()
Action interface.
#define ROS_ERROR_STREAM(args)
cob_cartesian_controller::CartesianControllerResult action_result_
ROSCPP_DECL void spinOnce()
cob_cartesian_controller::MoveCircStruct convertMoveCirc(const cob_cartesian_controller::MoveCirc &move_circ_msg)
void actionSuccess(const bool success, const std::string &message)
std::string target_frame_
void actionAbort(const bool success, const std::string &message)