Commit d516e862 authored by abhagwan's avatar abhagwan
Browse files

Removed auxiliary functions and added reset_goal_variables action.

parent 16331cee
......@@ -43,46 +43,6 @@ class CIriAnaNavModuleBT
*
*/
void init(IriBehaviorTreeFactory &factory);
/**
* \brief Stops the current goal synchronously
*
* This is a auxiliary function in order to provide an easy way to stop the
* robot through the client node if needed.
*
* This function stops the motion of the robot, whatever the type of goal
* that has been given. This function signals the stop to the navigation
* module, but the is_finished_bool() function must be used to know when the
* navigation is actually stopped as it is a synchronous action.
*
*/
void stop();
/**
* \brief Checks if the last goal has finished or not
*
* This is a auxiliary function in order to provide an easy way to check if
* the robot has finished its motion through the client node if needed.
*
* This function must be used to know when the last navigation goal has
* ended in the case of synchronous actions, either successfully or by any
* error. In the case of asynchronous actions it is already called by
* these.
*
* \return a bool indicating whether the last navigation goal has ended
* (True) or not (False), regardless of its success or not.
*
*/
bool is_finished_bool();
/**
* \brief Sets goal sent variables to false
*
* This is a auxiliary function in order to provide an easy way to reset
* the values of goal sent variables through the client node if needed.
*
* It will be needed in case of restart of the same tree or if a new tree
* is created.
*
*/
void init_goal_variables();
/**
* \brief Destructor
......@@ -278,6 +238,17 @@ class CIriAnaNavModuleBT
*
*/
BT::NodeStatus sync_stop();
/**
* \brief Sets goal sent variables to false
*
* This is a auxiliary function in order to provide an easy way to reset
* the values of goal sent variables through the client node if needed.
*
* It will be needed in case of restart of the same tree or if a new tree
* is created.
*
*/
BT::NodeStatus reset_goal_variables();
// Conditions to check if the last goal has finished or not and how
/**
* \brief Checks if the last goal has finished or not.
......
......@@ -7,7 +7,9 @@
CIriAnaNavModuleBT::CIriAnaNavModuleBT() :
nav("nav_module",ros::this_node::getName())
{
init_goal_variables();
orientation_goal_sent = false;
position_goal_sent = false;
pose_goal_sent = false;
}
void CIriAnaNavModuleBT::init(IriBehaviorTreeFactory &factory)
......@@ -48,6 +50,7 @@ void CIriAnaNavModuleBT::init(IriBehaviorTreeFactory &factory)
factory.registerSimpleAction("costmaps_clear", std::bind(&CIriAnaNavModuleBT::costmaps_clear, this));
factory.registerSimpleAction("costmaps_enable_auto_clear", std::bind(&CIriAnaNavModuleBT::costmaps_enable_auto_clear, this, std::placeholders::_1), costmap_port);
factory.registerSimpleAction("costmaps_disable_auto_clear", std::bind(&CIriAnaNavModuleBT::costmaps_disable_auto_clear, this));
factory.registerSimpleAction("reset_goal_variables", std::bind(&CIriAnaNavModuleBT::reset_goal_variables, this));
// registry of asynchronous actions
factory.registerIriAsyncAction("async_go_to_orientation", std::bind(&CIriAnaNavModuleBT::async_go_to_orientation, this, std::placeholders::_1), async_orientation_port);
factory.registerIriAsyncAction("async_go_to_position", std::bind(&CIriAnaNavModuleBT::async_go_to_position, this, std::placeholders::_1), async_position_port);
......@@ -376,7 +379,17 @@ BT::NodeStatus CIriAnaNavModuleBT::async_go_to_pose(BT::TreeNode& self)
BT::NodeStatus CIriAnaNavModuleBT::sync_stop()
{
stop();
ROS_INFO("-------STOP-------");
nav.stop();
return BT::NodeStatus::SUCCESS;
}
BT::NodeStatus CIriAnaNavModuleBT::reset_goal_variables()
{
// goal sent variables
orientation_goal_sent = false;
position_goal_sent = false;
pose_goal_sent = false;
return BT::NodeStatus::SUCCESS;
}
......@@ -617,22 +630,3 @@ BT::NodeStatus CIriAnaNavModuleBT::costmap_is_auto_clear_enabled()
}
return BT::NodeStatus::SUCCESS;
}
void CIriAnaNavModuleBT::stop()
{
ROS_INFO("-------STOP-------");
nav.stop();
}
bool CIriAnaNavModuleBT::is_finished_bool()
{
return nav.is_finished();
}
void CIriAnaNavModuleBT::init_goal_variables()
{
// goal sent variables
orientation_goal_sent = false;
position_goal_sent = false;
pose_goal_sent = false;
}
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment