Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Are action servers working? #89

Open
ppianpak opened this issue Apr 10, 2018 · 3 comments
Open

Are action servers working? #89

ppianpak opened this issue Apr 10, 2018 · 3 comments

Comments

@ppianpak
Copy link

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:
screenshot from 2018-04-09 18-12-58

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.

@rishabhgks
Copy link

Any update on this?
It doesn't seem to be working for me either.

@rishabhgks
Copy link

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;

@Makekihe
Copy link

@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?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants