hector_quadrotor
hector_quadrotor copied to clipboard
Are action servers working?
I saw there are implementations of landing_action
, pose_action
, and takeoff_action
in hector_quadrotor/hector_quadrotor_actions
.
I tried to use it by mimicking the code in hector_quadrotor_teleop/quadrotor_teleop.cpp
but there is no reaction on Gazebo at all.
I just want to ask whether the the action server implementations work for you guys?
Detail here:
In terminal 1 I run: roslaunch hector_quadrotor_gazebo quadrotor_empty_world.launch
In terminal 2 I run a piece of code:
ros::ServiceClient serviceClient = nh.serviceClient<hector_uav_msgs::EnableMotors>("enable_motors");
hector_uav_msgs::EnableMotors enable_motors_srv;
enable_motors_srv.request.enable = true;
serviceClient.call(enable_motors_srv);
ROS_INFO("%s - %s", nh.resolveName("enable_motors").c_str(), enable_motors_srv.response.success ? "successful" : "failed");
typedef actionlib::SimpleActionClient<hector_uav_msgs::TakeoffAction> TekeoffClient;
TekeoffClient takeoff_client_("action/takeoff");
ROS_INFO("Waiting for action server action/takeoff to start");
takeoff_client_.waitForServer();
ROS_INFO("Action server action/takeoff: %s", takeoff_client_.isServerConnected()? "Connected" : "NOT Connected");
takeoff_client_.sendGoal(hector_uav_msgs::TakeoffGoal());
ROS_INFO("Takeoff goal sent!");
takeoff_client_.waitForResult(ros::Duration(5));
std::cout << "State: " << takeoff_client_.getState().toString() << std::endl;
output:
I also set takeoff_height
in hector_quadrotor/hector_quadrotor_actions/takeoff_action.cpp
to 10.0 (originally set to 0.3) to make sure I see it clearly, but there is no movement of the drone in Gazebo at all.
Any update on this? It doesn't seem to be working for me either.
Got it to work using the code below:
actionlib::SimpleActionClient<hector_uav_msgs::PoseAction> pose_("action/pose", true);
hector_uav_msgs::PoseActionFeedback pose_feedback;
ROS_INFO("Waiting for action server to start.");
// wait for the action server to start
pose_.waitForServer();
ROS_INFO("Action server started, sending goal.");
// send a goal to the action
hector_uav_msgs::PoseGoal pose_goal;
ROS_INFO("Current pose %f", pose_feedback.feedback.current_pose.pose.position.z);
pose_goal.target_pose = pose_feedback.feedback.current_pose;
pose_goal.target_pose.pose.position.z = 3.0;
pose_goal.target_pose.header.frame_id = "world";
pose_.sendGoal(pose_goal, &doneCb, &activeCb, &feedbackCb);
pose_.waitForResult(ros::Duration(30.0));
if (pose_.getState() == actionlib::SimpleClientGoalState::SUCCEEDED)
{
actionlib::SimpleClientGoalState state = pose_.getState();
ROS_INFO("Action finished: %s",state.toString().c_str());
}
else
ROS_INFO("Action did not finish before the time out.");
return 0;
@rishabhgks I just want to make sure that I understand this correctly. The code that you present is using the action server for sending goals to a ROS Navigation Stack launched somewhere else? This code does NOT give 3D go-to-goal navigation functionality of the hector drone?