30 #include <std_msgs/Float64.h> 31 #include <boost/algorithm/string.hpp> 40 new JTAS(
"/r_arm_controller/joint_trajectory_action",
48 std::string hand_names[] =
50 "ffj0",
"ffj3",
"ffj4",
51 "lfj0",
"lfj3",
"lfj4",
"lfj5",
52 "mfj0",
"mfj3",
"mfj4",
53 "rfj0",
"rfj3",
"rfj4",
54 "thj1",
"thj2",
"thj3",
"thj4",
"thj5",
57 for (
size_t i = 0; i < 20; i++)
60 "/sh_" + hand_names[i] +
"_mixed_position_velocity_controller/command", 2);
63 "/sh_" + hand_names[i] +
"_mixed_position_velocity_controller/command", 2);
67 std::string arm_names[] = {
"sr",
"ss",
"es",
"er"};
68 for (
size_t i = 0; i < 4; i++)
71 "/sa_" + arm_names[i] +
"_position_controller/command", 2);
75 std::string arm_names_2[] = {
"ShoulderJRotate",
"ShoulderJSwing",
"ElbowJSwing",
"ElbowJRotate"};
76 for (
size_t i = 0; i < 4; i++)
79 "/sa_" + arm_names[i] +
"_position_controller/command", 2);
82 ROS_DEBUG(
"Starting JointTrajectoryActionController server");
87 const control_msgs::FollowJointTrajectoryGoalConstPtr &goal
91 std::vector<std::string>
joint_names = goal->trajectory.joint_names;
93 trajectory_msgs::JointTrajectoryPoint trajectory_step;
101 for (
size_t index_step = 0; index_step < trajectory_points.size(); ++index_step)
103 trajectory_step = trajectory_points[index_step];
108 ROS_INFO(
"Joint Trajectory Action Preempted");
115 for (
size_t i = 0; i < joint_names.size(); i++)
117 ROS_DEBUG_STREAM(
"trajectory: " << joint_names[i] <<
" " << trajectory_step.positions[i] <<
" / sleep: " <<
118 sleeping_time.toSec());
120 std_msgs::Float64 msg;
121 msg.data = trajectory_step.positions[i];
127 sleeping_time = trajectory_step.time_from_start - last_time;
128 sleeping_time.sleep();
129 last_time = trajectory_step.time_from_start;
133 control_msgs::FollowJointTrajectoryResult joint_trajectory_result;
146 int main(
int argc,
char **argv)
148 ros::init(argc, argv,
"sr_joint_trajectory_action_controller");
std::vector< trajectory_msgs::JointTrajectoryPoint > JointTrajectoryPointVec
ROSCPP_DECL void init(int &argc, char **argv, const std::string &name, uint32_t options=0)
actionlib::SimpleActionServer< control_msgs::FollowJointTrajectoryAction > JTAS
JointTrajectoryActionController()
Implement an actionlib server to execute a control_msgs::JointTrajectoryAction. Follows the given tra...
boost::shared_ptr< JTAS > action_server
int main(int argc, char **argv)
Publisher advertise(const std::string &topic, uint32_t queue_size, bool latch=false)
#define ROS_DEBUG_STREAM(args)
void execute_trajectory(const control_msgs::FollowJointTrajectoryGoalConstPtr &goal)