Class PathPlanner has methods send goal points and initial pose of the turtlebot to move_base package. Once the packages are identified, this class prints the package IDs and locations.
More...
#include <PathPlanner.hpp>
Class PathPlanner has methods send goal points and initial pose of the turtlebot to move_base package. Once the packages are identified, this class prints the package IDs and locations.
PathPlanner::PathPlanner |
( |
std::vector< std::vector< double >> |
| ) |
|
|
explicit |
Constructor of the PathPlanner class.
- Parameters
-
points | of type std::vector<std::vector<double>> |
- Returns
- none
50 initPosePub = nh.advertise<geometry_msgs::PoseWithCovarianceStamped>(
51 "/initialpose", 1000);
52 move_base_msgs::MoveBaseGoal targetPose;
54 initialPose.header.frame_id =
"map";
55 initialPose.pose.pose.position.x = 0.0;
56 initialPose.pose.pose.position.y = 0.0;
57 initialPose.pose.pose.orientation.w = 1.0;
61 targetPose.target_pose.header.frame_id =
"map";
62 targetPose.target_pose.header.stamp = ros::Time::now();
63 for (
auto i = points.begin(); i != points.end() && counter < points.size();
65 targetPose.target_pose.pose.position.x = (*i).at(0);
66 targetPose.target_pose.pose.position.y = (*i).at(1);
67 targetPose.target_pose.pose.orientation.z = (*i).at(2);
68 targetPose.target_pose.pose.orientation.w = (*i).at(3);
69 goal.push_back(targetPose);
PathPlanner::~PathPlanner |
( |
| ) |
|
Destructor of the PathPlanner class.
- Parameters
-
- Returns
- none
std::vector< double > PathPlanner::callPublisher |
( |
double |
x, |
|
|
double |
y, |
|
|
double |
w |
|
) |
| |
Method to call publishInitPose.
- Parameters
-
x | of type double |
y | of type double |
w | of type double |
- Returns
- initPose of type std::vector<double>
95 return publishInitPose(x, y, w);
std::vector< std::string > PathPlanner::callVision |
( |
std::vector< std::string > |
packID | ) |
|
Method to call callback function from QReader class.
- Parameters
-
object | of QReader class |
packID | of type std::vector<std::string> |
- Returns
- packID of type std::vector<std::string>
119 std::vector<uint8_t> result = reader.
returnBytes();
121 str.assign(result.begin(), result.end());
122 ROS_INFO(
"Package ID is: %s \n", str.c_str());
std::string waitPackageDetection(std::string)
Method to try again if the package detection is faulty.
Definition: PathPlanner.cpp:98
std::vector< uint8_t > returnBytes()
Function to get the extracted data array.
Definition: QReader.cpp:65
int PathPlanner::findPackage |
( |
std::vector< std::string > |
packID | ) |
|
Method to print the packIDs and their location where to find them.
- Parameters
-
packID | of type std::vector<std::string> |
- Returns
- exit status of type int
163 auto j = goal.begin();
165 "\n*****************************\n******Package " 166 "Locations******\n*****************************\n";
167 for (
auto i = packID.begin(); i != packID.end() && j != goal.end();
169 result += (*i) +
" is in position x=" +
170 std::to_string((*j).target_pose.pose.position.x) +
171 " y = " + std::to_string((*j).target_pose.pose.position.y) +
"\n";
173 ROS_INFO_STREAM(result);
174 ros::Duration(10).sleep();
ros::Publisher PathPlanner::returnPublisher |
( |
| ) |
|
Method that returns publisher object.
- Parameters
-
- Returns
- initPosePub of type ros::Publisher
75 {
return initPosePub; }
std::vector< std::string > PathPlanner::sendGoals |
( |
| ) |
|
Method to send goals to move_base action server.
- Parameters
-
- Returns
- packID of type std::vector<std::string>
130 actionlib::SimpleActionClient<move_base_msgs::MoveBaseAction> ac(
"move_base",
133 std::vector<std::string> packID;
135 while (!ac.waitForServer(ros::Duration(5.0))) {
136 ROS_INFO(
"Waiting for the move_base action server to come up");
141 publishInitPose(-3.0, -3.0, 1.0);
142 for (
auto i = goal.begin(); i != goal.end() && counter < goal.size(); i++) {
143 ROS_INFO(
"Moving to goal %d \n", counter + 1);
147 if (ac.getState() == actionlib::SimpleClientGoalState::SUCCEEDED) {
148 counter = counter + 1;
149 ROS_INFO_STREAM(
"Reached goal %d \n" << counter);
150 if (counter == goal.size()) {
156 ROS_WARN_STREAM(
"Failed to reach goal");
std::vector< std::string > callVision(std::vector< std::string >)
Method to call callback function from QReader class.
Definition: PathPlanner.cpp:114
std::string PathPlanner::waitPackageDetection |
( |
std::string |
str | ) |
|
Method to try again if the package detection is faulty.
- Parameters
-
- Returns
- none
100 while (str.substr(0, 4) !=
"pack") {
102 std::vector<uint8_t> result = reader.
returnBytes();
103 str.assign(result.begin(), result.end());
105 if (str.substr(0, 4) ==
"pack") {
106 ROS_INFO(
"QR code detected! \n");
107 ROS_INFO(
"Package ID is: %s \n", str.c_str());
std::vector< uint8_t > returnBytes()
Function to get the extracted data array.
Definition: QReader.cpp:65
The documentation for this class was generated from the following files: