SMACC
Loading...
Searching...
No Matches
odom_tracker_node.cpp
Go to the documentation of this file.
1/*****************************************************************************************************************
2 * ReelRobotix Inc. - Software License Agreement Copyright (c) 2018
3 * Authors: Pablo Inigo Blasco, Brett Aldrich
4 *
5 ******************************************************************************************************************/
6#include <move_base_z_client_plugin/components/move_base_z_plugin/components/odom_tracker/odom_tracker.h>
7#include <odom_tracker/OdomTrackerAction.h>
8#include <actionlib/server/simple_action_server.h>
9#include <memory>
10
11typedef actionlib::SimpleActionServer<odom_tracker::OdomTrackerAction> Server;
12
13using namespace odom_tracker;
14using namespace cl_move_base_z::odom_tracker;
15
17{
18public:
19 std::shared_ptr<Server> as_;
21
23 : odomTracker("move_base")
24 {
25 }
26
32 void execute(const OdomTrackerGoalConstPtr &goal) // Note: "Action" is not appended to DoDishes here
33 {
34 try
35 {
36 switch (goal->command)
37 {
38 case OdomTrackerGoal::RECORD_PATH:
39 odomTracker.setWorkingMode(WorkingMode::RECORD_PATH);
40 break;
41
42 case OdomTrackerGoal::CLEAR_PATH:
43 odomTracker.setWorkingMode(WorkingMode::CLEAR_PATH);
44 break;
45
46 case OdomTrackerGoal::IDLE:
47 odomTracker.setWorkingMode(WorkingMode::IDLE);
48 break;
49
50 case OdomTrackerGoal::START_BROADCAST_PATH:
52 break;
53
54 case OdomTrackerGoal::STOP_BROADCAST_PATH:
56 break;
57
58 case OdomTrackerGoal::PUSH_PATH:
60 break;
61
62 case OdomTrackerGoal::POP_PATH:
64 break;
65
66 default:
67
68 ROS_ERROR("Odom Tracker Node - Action Server execute error: incorrect command - %d", goal->command);
69 as_->setAborted();
70 }
71
72 // never reach succeeded because were are interested in keeping the feedback alive
73 as_->setSucceeded();
74 }
75 catch (std::exception &ex)
76 {
77 ROS_ERROR("Odom Tracker Node - Action Server execute error: %s", ex.what());
78 as_->setAborted();
79 }
80 }
81
87 void run()
88 {
89 ros::NodeHandle n;
90 ROS_INFO("Creating odom tracker action server");
91
92 as_ = std::make_shared<Server>(n, "odom_tracker", boost::bind(&OdomTrackerActionServer::execute, this, _1), false);
93 ROS_INFO("Starting OdomTracker Action Server");
94
95 as_->start();
96
97 ros::spin();
98 }
99};
100
101int main(int argc, char **argv)
102{
103 ros::init(argc, argv, "odom_tracker_node");
105
106 as.run();
107}
std::shared_ptr< Server > as_
void execute(const OdomTrackerGoalConstPtr &goal)
This class track the required distance of the cord based on the external localization system.
Definition: odom_tracker.h:47
void popPath(int pathCount=1, bool keepPreviousPath=false)
void pushPath(std::string newPathTagName="")
void setWorkingMode(WorkingMode workingMode)
int main(int argc, char **argv)
actionlib::SimpleActionServer< odom_tracker::OdomTrackerAction > Server