-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathexecutive.cpp
More file actions
67 lines (56 loc) · 1.81 KB
/
Copy pathexecutive.cpp
File metadata and controls
67 lines (56 loc) · 1.81 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
#include <iostream>
#include <ros/ros.h>
#include "point.h"
#include "geometry_msgs/Polygon.h"
#include "actionlib_msgs/GoalStatus.h"
#include "geometry_msgs/Point.h"
using namespace std;
using namespace ros;
void path_goalStatus(const actionlib_msgs::GoalStatus::ConstPtr& msg);
int flag = 0;
int halt = 0;
int main(int argc, char** argv) {
init(argc, argv, "exec");
geometry_msgs::Point goal;
actionlib_msgs::GoalStatus h;
NodeHandle n;
Publisher npath = n.advertise<geometry_msgs::Point>("next_goal", 1000);
Publisher reqPath = n.advertise<actionlib_msgs::GoalStatus>("plannerFlag",1000, true);
Subscriber reqGoal = n.subscribe("next_pathFlag", 1000, path_goalStatus);
ros::Rate loop_rate(10);
vector<Point> goals;
goals.push_back(Point(0.5, 0.0));
goals.push_back(Point(1.5, 0.0));
goals.push_back(Point(2.5, 0.0));
goals.push_back(Point(4.0, 0.0));
goals.push_back(Point(5.5, 0.0));
goals.push_back(Point(6.5, 0.0));
goals.push_back(Point(7.5, 0.0));
goals.push_back(Point(6.5, 0.0));
goals.push_back(Point(5.5, 0.0));
goals.push_back(Point(4.0, 0.0));
goals.push_back(Point(2.5, 0.0));
goals.push_back(Point(1.5, 0.0));
while (ros::ok()) {
h.status = 1;
if (flag && !goals.empty()) {
cout << "Goal : " << endl;
goal.x = goals.back().x;
goal.y = goals.back().y;
cout << "Goal x-y: " << goal.x << " " << goal.y << endl;
goals.pop_back();
h.status = 3;
flag = 0;
}
ros::spinOnce();
npath.publish(goal);
reqPath.publish(h);
loop_rate.sleep();
}
}
void path_goalStatus(const actionlib_msgs::GoalStatus::ConstPtr& msg) {
if (msg->status == 3) {
cout << "Goal status" << endl;
flag = 1;
}
}