ping_create_object_model_server.cpp
Go to the documentation of this file.
00001 #include <ros/ros.h>
00002 #include <actionlib/client/simple_action_client.h>
00003 #include <actionlib/client/terminal_state.h>
00004 #include "pr2_create_object_model/ModelObjectInHandAction.h"
00005 
00006 
00007 // Called once when the goal completes
00008 void doneCb(const actionlib::SimpleClientGoalState& state,
00009             const pr2_create_object_model::ModelObjectInHandResultConstPtr& result)
00010 {
00011   ROS_INFO("Finished in state [%s]", state.toString().c_str());
00012   ROS_INFO("Number of points in resulting cluster: %d", result->cluster.width);
00013   ROS_INFO("collision_name: %s", result->collision_name.c_str());
00014   ros::shutdown();
00015 }
00016 
00017 // Called once when the goal becomes active
00018 void activeCb()
00019 {
00020   ROS_INFO("Goal just went active");
00021 }
00022 
00023 // Called every time feedback is received for the goal
00024 void feedbackCb(const pr2_create_object_model::ModelObjectInHandFeedbackConstPtr& feedback)
00025 {
00026   ROS_INFO("Got Feedback, phase %d, rotate_ind %d", feedback->phase, feedback->rotate_ind);
00027 }
00028 
00029 
00030 int main (int argc, char **argv)
00031 {
00032   ros::init(argc, argv, "ping_create_object_model_server");
00033 
00034   // create the action client
00035   // true causes the client to spin it's own thread
00036   actionlib::SimpleActionClient<pr2_create_object_model::ModelObjectInHandAction> ac("create_object_model_server/model_object_in_hand_action", true);
00037 
00038   ROS_INFO("Waiting for action server to start.");
00039   // wait for the action server to start
00040   ac.waitForServer(); //will wait for infinite time
00041   ROS_INFO("Action server started, sending goal.");
00042 
00043   // send a goal to the action
00044   pr2_create_object_model::ModelObjectInHandGoal goal;
00045   goal.arm_name = "right_arm";
00046   goal.clear_move.header.frame_id = "base_link";
00047   goal.clear_move.vector.z = .5;
00048   goal.rotate_object = true;
00049   goal.add_to_collision_map = true;
00050   goal.keep_level = false;
00051 
00052   //gripper points (x-axis) towards base_link y, gripper y-axis towards base_link -x, z-axis towards base-link +z 
00053   goal.rotate_pose.header.frame_id = "torso_lift_link";
00054   goal.rotate_pose.pose.position.x = .7;
00055   goal.rotate_pose.pose.position.z = .4;
00056   goal.rotate_pose.pose.orientation.z = 0.707;
00057   goal.rotate_pose.pose.orientation.w = 0.707;
00058 
00059   ac.sendGoal(goal, &doneCb, &activeCb, &feedbackCb);
00060 
00061   ros::spin();
00062 
00063   //exit
00064   return 0;
00065 }


pr2_create_object_model
Author(s): Kaijen Hsiao
autogenerated on Fri Jan 3 2014 11:50:03