2 #include <trajectory_msgs/JointTrajectory.h> 3 #include <std_msgs/Float64MultiArray.h> 10 trajectory_msgs::JointTrajectory traj;
12 traj.joint_names.push_back(
"head_pan_joint");
13 traj.joint_names.push_back(
"head_tilt_joint");
14 traj.points.resize(1);
16 std::vector<double> q_goal(2);
17 q_goal[0]=head_goal[0];
18 q_goal[1]=head_goal[1];
19 traj.points[0].positions=q_goal;
20 traj.points[0].velocities.push_back(0.1);
21 traj.points[0].velocities.push_back(0.1);
28 std_msgs::Float64MultiArray grp_pos_msg;
29 grp_pos_msg.data.push_back((
float)head_goal[0]);
30 grp_pos_msg.data.push_back((
float)head_goal[1]);
31 grp_pos_pub.
publish(grp_pos_msg);
34 int main(
int argc,
char **argv) {
37 traj_pub = nh.
advertise<trajectory_msgs::JointTrajectory>(
"/pan_tilt_trajectory_controller/command", 5);
41 std::vector<double> head_goal(2);
42 float pan_angle = 0, tilt_angle = 0;
44 bool gen_random_angles =
false;
52 if (gen_random_angles)
54 ROS_INFO(
"[move_pan_tilt_node]: generating random goal...");
56 pan_angle = (float)((rand()%91)-45);
57 tilt_angle = (float)((rand()%81)-50);
58 head_goal[0] = pan_angle * (M_PI / 180.0);
59 head_goal[1] = tilt_angle * (M_PI / 180.0);
63 head_goal[0] = pan_angle * (M_PI / 180);
64 head_goal[1] = tilt_angle * (M_PI / 180);
73 ROS_INFO(
"[move_pan_tilt_node]: waiting for subscriber");
83 ROS_INFO(
"[move_pan_tilt_node]: sending pan-tilt goal [%f,%f](degrees)", pan_angle, tilt_angle);
92 ROS_INFO(
"[move_pan_tilt_node]: done");
void publishTrajectoryMsg(std::vector< double > &head_goal)
int main(int argc, char **argv)
void publish(const boost::shared_ptr< M > &message) const
ROSCPP_DECL void init(int &argc, char **argv, const std::string &name, uint32_t options=0)
void publishGroupPosMsg(std::vector< double > &head_goal)
ROSCPP_DECL bool get(const std::string &key, std::string &s)
Publisher advertise(const std::string &topic, uint32_t queue_size, bool latch=false)
ros::Publisher grp_pos_pub
uint32_t getNumSubscribers() const
ROSCPP_DECL void shutdown()
ROSCPP_DECL void spinOnce()