set_goal_client.cpp
Go to the documentation of this file.
1 #include <ros/ros.h>
3 #include <nav2d_navigator/MoveToPosition2DAction.h>
4 #include <geometry_msgs/PoseStamped.h>
6 
8 
10 
12 
13 void receiveGoal(const geometry_msgs::PoseStamped::ConstPtr& msg)
14 {
15  nav2d_navigator::MoveToPosition2DGoal goal;
16  goal.target_pose.x = msg->pose.position.x;
17  goal.target_pose.y = msg->pose.position.y;
18  goal.target_pose.theta = tf::getYaw(msg->pose.orientation);
19  goal.target_distance = 0.25;
20  goal.target_angle = 0.1;
21 
22  gMoveClient->sendGoal(goal);
23 }
24 
25 int main(int argc, char **argv)
26 {
27  ros::init(argc, argv, "SetGoal");
29 
30  ros::Subscriber goalSubscriber = n.subscribe("goal", 1, &receiveGoal);
31  gMoveClient = new MoveClient(NAV_MOVE_ACTION, true);
32  gMoveClient->waitForServer();
33 
34  ros::spin();
35 
36  delete gMoveClient;
37  return 0;
38 }
bool waitForServer(const ros::Duration &timeout=ros::Duration(0, 0)) const
Subscriber subscribe(const std::string &topic, uint32_t queue_size, void(T::*fp)(M), T *obj, const TransportHints &transport_hints=TransportHints())
static double getYaw(const Quaternion &bt_q)
ROSCPP_DECL void init(int &argc, char **argv, const std::string &name, uint32_t options=0)
MoveClient * gMoveClient
#define NAV_MOVE_ACTION
Definition: commands.h:12
ROSCPP_DECL void spin(Spinner &spinner)
int main(int argc, char **argv)
void receiveGoal(const geometry_msgs::PoseStamped::ConstPtr &msg)
void sendGoal(const Goal &goal, SimpleDoneCallback done_cb=SimpleDoneCallback(), SimpleActiveCallback active_cb=SimpleActiveCallback(), SimpleFeedbackCallback feedback_cb=SimpleFeedbackCallback())
actionlib::SimpleActionClient< nav2d_navigator::MoveToPosition2DAction > MoveClient


nav2d_navigator
Author(s): Sebastian Kasperski
autogenerated on Thu Jun 6 2019 19:20:43