00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00045 #include <LinearMath/btTransform.h>
00046 #include <ros/ros.h>
00047 #include <geometry_msgs/PoseStamped.h>
00048
00049 #include "manipulation_transforms/manipulation_transforms_ros.h"
00050
00051 #include <argp.h>
00052
00053 const char *argp_program_version = "manipulation_transforms_server 0.1";
00054 const char *argp_program_bug_address = "<jscholz@willowgarage.com>";
00055
00056
00057 static char doc[] =
00058 "Provides a rose service node for mapping between object and gripper poses. \n\n"
00059 "This node must be initialized with transforms in a common reference frame for the target "
00060 "object and each gripper in contact with it. "
00061 "After initialization, manipulation_transforms_server provides service calls for querying poses, "
00062 "twists, and trajectories from object to grippers, or grippers to object. \n"
00063 "If not called with the \"-l\" option, the node must be initialized by a call to the service"
00064 "\'SetGraspTransforms\' before issuing queries. ";
00065
00066
00067 static char args_doc[] = "[--load=NAMESPACE]";
00068
00069
00070 static struct argp_option options[] = {
00071 {"load", 'l', 0, 0, "Attempt to load the rigid transforms from parameter server (see doxy for naming convention)", 0},
00072 {"namespace", 'n', "NAMESPACE", 0, "Use NAMESPACE as the top-level namespace when loading rigid transforms" , 0},
00073 {"frame", 'f', "FRAME", 0, "Set the reference frame in which all initial and query transforms must be defined" , 0},
00074 {0,0,0,0,0,0}
00075 };
00076
00077
00078 struct arguments
00079 {
00080 char *args[2];
00081 bool load_params;
00082 char *ns;
00083 char *reference_frame;
00084 };
00085
00086 unsigned int nargs_required = 0;
00087 unsigned int nargs_max = 3;
00088
00089
00090 static error_t parse_opt (int key, char *arg, struct argp_state *state)
00091 {
00092
00093
00094 struct arguments *arguments;
00095 arguments = (struct arguments*) state->input;
00096
00097 switch (key) {
00098 case 'l':
00099 arguments->load_params = true;
00100 break;
00101
00102 case 'n':
00103 arguments->ns = arg;
00104 break;
00105
00106 case 'f':
00107 arguments->reference_frame = arg;
00108 break;
00109
00110 case ARGP_KEY_ARG:
00111 if (state->arg_num >= nargs_max)
00112
00113 argp_usage(state);
00114 arguments->args[state->arg_num] = arg;
00115 break;
00116
00117 case ARGP_KEY_END:
00118 if (state->arg_num < nargs_required)
00119
00120 argp_usage(state);
00121 break;
00122
00123 default:
00124
00125 return ARGP_ERR_UNKNOWN;
00126 }
00127 return 0;
00128 }
00129
00130
00131 static struct argp argp = { options, parse_opt, args_doc, doc, NULL, NULL, NULL };
00132
00133
00134
00135
00136 int main( int argc, char **argv ) {
00137
00138 ros::init(argc, argv, "manipulation_transforms_server");
00139
00140
00141
00142
00143
00144
00145
00146 struct arguments arguments;
00147
00148
00149 arguments.load_params = false;
00150 arguments.ns = (char*)"";
00151 arguments.reference_frame = (char*)"base_footprint";
00152
00153 argp_parse (&argp, argc, argv, 0, 0, &arguments);
00154
00155 ROS_INFO("Starting manipulation_transforms_server node with FRAME = %s, NAMESPACE = %s, load params = %s",
00156 arguments.reference_frame,
00157 arguments.ns,
00158 arguments.load_params ? "false" : "false");
00159
00160 if (ros::isInitialized()) {
00161 if (arguments.load_params) {
00162 ManipulationTransformsROS server(arguments.reference_frame, arguments.ns);
00163 ros::spin();
00164 }
00165 else {
00166 ManipulationTransformsROS server(arguments.reference_frame);
00167 ros::spin();
00168 }
00169 }
00170 return 0;
00171 }
00172