Go to the documentation of this file.00001 #include "iri_oa_client_alg_node.h"
00002
00003 IriOAClientAlgNode::IriOAClientAlgNode(void) :
00004 MoveBase_client_("MoveBase", true)
00005 {
00006
00007
00008
00009
00010
00011
00012 nav_goal_subscriber_ = public_node_handle_.subscribe("nav_goal", 100, &IriOAClientAlgNode::nav_goal_callback, this);
00013
00014
00015
00016
00017
00018
00019
00020
00021 }
00022
00023 IriOAClientAlgNode::~IriOAClientAlgNode(void)
00024 {
00025
00026 }
00027
00028 void IriOAClientAlgNode::mainNodeThread(void)
00029 {
00030
00031
00032
00033
00034
00035
00036
00037 }
00038
00039
00040 void IriOAClientAlgNode::nav_goal_callback(const geometry_msgs::PoseStamped::ConstPtr& msg)
00041 {
00042 ROS_INFO("NoCollisionAlgNode::nav_goal_callback: New Message Received");
00043
00044
00045 alg_.lock();
00046
00047 ROS_INFO("goal_reqs_=%d frame_id=%s pose=(%f,%f,%f)",
00048 msg->header.seq, msg->header.frame_id.c_str(),
00049 msg->pose.position.x, msg->pose.position.y, msg->pose.position.z);
00050
00051 MoveBaseMakeActionRequest(*msg);
00052
00053
00054 alg_.unlock();
00055 }
00056
00057
00058
00059
00060 void IriOAClientAlgNode::MoveBaseDone(const actionlib::SimpleClientGoalState& state, const move_base_msgs::MoveBaseResultConstPtr& result)
00061 {
00062 ROS_INFO("IriOAClientAlgNode::MoveBaseDone: Goal Achieved!");
00063 ROS_INFO("IriOAClientAlgNode::MoveBaseDone: %s", state.toString().c_str());
00064
00065
00066 }
00067
00068 void IriOAClientAlgNode::MoveBaseActive(void)
00069 {
00070 ROS_INFO("IriOAClientAlgNode::MoveBaseActive: Goal just went active!");
00071 }
00072
00073 void IriOAClientAlgNode::MoveBaseFeedback(const move_base_msgs::MoveBaseFeedbackConstPtr& feedback)
00074 {
00075
00076
00077
00078 ROS_INFO("IriOAClientAlgNode::MoveBaseFeedback: pose=(%f, %f)",
00079 feedback->base_position.pose.position.x,
00080 feedback->base_position.pose.position.y);
00081
00082
00083
00084
00085
00086
00087
00088 }
00089
00090
00091 void IriOAClientAlgNode::MoveBaseMakeActionRequest(const geometry_msgs::PoseStamped & new_goal)
00092 {
00093 ROS_INFO("IriOAClientAlgNode::MoveBaseMakeActionRequest: Starting New Request!");
00094
00095
00096
00097 ROS_INFO("IriOAClientAlgNode::MoveBaseMakeActionRequest: Waiting for Server...");
00098 MoveBase_client_.waitForServer();
00099 ROS_INFO("IriOAClientAlgNode::MoveBaseMakeActionRequest: Server is Available!");
00100
00101
00102 move_base_msgs::MoveBaseGoal goal;
00103
00104 goal.target_pose.header = new_goal.header;
00105 goal.target_pose.pose = new_goal.pose;
00106
00107 ROS_INFO("[%d] - NEW goal=(%f, %f, %f)", goal.target_pose.header.seq,
00108 goal.target_pose.pose.position.x,
00109 goal.target_pose.pose.position.y,
00110 goal.target_pose.pose.position.z);
00111
00112
00113 MoveBase_client_.sendGoal(goal,
00114 boost::bind(&IriOAClientAlgNode::MoveBaseDone, this, _1, _2),
00115 boost::bind(&IriOAClientAlgNode::MoveBaseActive, this),
00116 boost::bind(&IriOAClientAlgNode::MoveBaseFeedback, this, _1));
00117 ROS_INFO("IriOAClientAlgNode::MoveBaseMakeActionRequest: Goal Sent. Wait for Result!");
00118
00119
00120
00121
00122
00123
00124
00125
00126
00127
00128
00129
00130
00131
00132
00133
00134
00135 }
00136
00137 void IriOAClientAlgNode::node_config_update(Config &config, uint32_t level)
00138 {
00139 this->alg_.lock();
00140
00141 this->alg_.unlock();
00142 }
00143
00144 void IriOAClientAlgNode::addNodeDiagnostics(void)
00145 {
00146 }
00147
00148
00149 int main(int argc,char *argv[])
00150 {
00151 return algorithm_base::main<IriOAClientAlgNode>(argc, argv, "iri_oa_client_alg_node");
00152 }