get_state_validity.cpp
Go to the documentation of this file.
00001 
00002 
00003 #include <ros/ros.h>
00004 #include <planning_environment_msgs/GetStateValidity.h>
00005 
00006 int main(int argc, char **argv){
00007   ros::init (argc, argv, "get_state_validity_test");
00008   ros::NodeHandle rh;
00009 
00010   ros::service::waitForService("environment_server_right_arm/get_state_validity");
00011   ros::ServiceClient check_state_validity_client_ = rh.serviceClient<planning_environment_msgs::GetStateValidity>("environment_server_right_arm/get_state_validity");
00012 
00013   planning_environment_msgs::GetStateValidity::Request req;
00014   planning_environment_msgs::GetStateValidity::Response res;
00015 
00016   req.robot_state.joint_state.name.push_back("r_shoulder_pan_joint");
00017   req.robot_state.joint_state.name.push_back("r_shoulder_lift_joint");
00018   req.robot_state.joint_state.name.push_back("r_upper_arm_roll_joint");
00019   req.robot_state.joint_state.name.push_back("r_elbow_flex_joint");
00020   req.robot_state.joint_state.name.push_back("r_forearm_roll_joint");
00021   req.robot_state.joint_state.name.push_back("r_wrist_flex_joint");
00022   req.robot_state.joint_state.name.push_back("r_wrist_roll_joint");
00023   req.robot_state.joint_state.position.resize(7,0.0);
00024 
00025   //these set whatever non-zero joint angle values are desired
00026   //req.robot_state.joint_state.position[0] = 0.0;
00027   //req.robot_state.joint_state.position[0] = -.55;
00028   req.robot_state.joint_state.position[0] = 0.40;
00029   req.robot_state.joint_state.position[3] = -0.40;
00030  
00031   req.robot_state.joint_state.header.stamp = ros::Time::now();
00032   req.check_collisions = true;
00033   if(check_state_validity_client_.call(req,res))
00034   {
00035     if(res.error_code.val == res.error_code.SUCCESS)
00036       ROS_INFO("Requested state is not in collision");
00037     else
00038       ROS_INFO("Requested state is in collision. Error code: %d",res.error_code.val);
00039   }
00040   else
00041   {
00042     ROS_ERROR("Service call to check state validity failed %s",check_state_validity_client_.getService().c_str());
00043     return false;
00044   }
00045   ros::shutdown();
00046 }
00047 
00048 
00049 
00050 
00051 
00052 


arm_navigation_tutorials
Author(s): Advait Jain
autogenerated on Wed Nov 27 2013 12:09:02