movebase_node.cpp
Go to the documentation of this file.
00001 #include "movebase_node.h"
00002 #include "behaviortree_cpp/bt_factory.h"
00003 
00004 // This function must be implemented in the .cpp file to create
00005 // a plugin that can be loaded at run-time
00006 BT_REGISTER_NODES(factory)
00007 {
00008     factory.registerNodeType<MoveBaseAction>("MoveBase");
00009 }
00010 
00011 BT::NodeStatus MoveBaseAction::tick()
00012 {
00013     Pose2D goal;
00014     if (getParam<Pose2D>("goal", goal) == false)
00015     {
00016         auto default_goal_value = requiredNodeParameters().at("goal");
00017         // use the convertFromString function
00018         goal = BT::convertFromString<Pose2D>(default_goal_value);
00019     }
00020 
00021     printf("[ MoveBase: STARTED ]. goal: x=%.f y=%.1f theta=%.2f\n", goal.x, goal.y, goal.theta);
00022 
00023     _halt_requested.store(false);
00024     int count = 0;
00025 
00026     // "compute" for 250 milliseconds or until _halt_requested is true
00027     while (!_halt_requested && count++ < 25)
00028     {
00029         SleepMS(10);
00030     }
00031 
00032     std::cout << "[ MoveBase: FINISHED ]" << std::endl;
00033     return _halt_requested ? BT::NodeStatus::SUCCESS : BT::NodeStatus::SUCCESS;
00034 }
00035 
00036 void MoveBaseAction::halt()
00037 {
00038     _halt_requested.store(true);
00039 }


behaviortree_cpp
Author(s): Michele Colledanchise, Davide Faconti
autogenerated on Sat Feb 2 2019 03:50:10