Go to the documentation of this file.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 #include "motoman_driver/industrial_robot_client/motoman_utils.h"
00035 #include "ros/ros.h"
00036
00037 namespace industrial_robot_client
00038 {
00039 namespace motoman_utils
00040 {
00041
00042 bool getJointGroups(const std::string topic_param, std::map<int, RobotGroup> & robot_groups)
00043 {
00044 if(ros::param::has(topic_param))
00045 {
00046 XmlRpc::XmlRpcValue topics_list_rpc;
00047 ros::param::get(topic_param, topics_list_rpc);
00048
00049
00050 std::vector<XmlRpc::XmlRpcValue> topics_list;
00051
00052 ROS_INFO_STREAM("Loading topic list");
00053 ROS_INFO_STREAM("Found " << topics_list_rpc.size() << " topics");
00054
00055 for (int i = 0; i < topics_list_rpc.size(); i++)
00056 {
00057 XmlRpc::XmlRpcValue state_value;
00058 state_value = topics_list_rpc[i];
00059 ROS_INFO_STREAM("Topic(state_value): " << state_value);
00060 topics_list.push_back(state_value);
00061 }
00062
00063
00064 for (int i = 0; i < topics_list.size(); i++)
00065 {
00066 ROS_INFO_STREAM("Loading group: " << topics_list[i]);
00067 RobotGroup rg;
00068 std::vector<std::string> rg_joint_names;
00069
00070 XmlRpc::XmlRpcValue joints;
00071
00072 joints = topics_list[i]["joints"];
00073 for (int jt = 0; jt < joints.size(); jt++)
00074 {
00075 rg_joint_names.push_back(static_cast<std::string>(joints[jt]));
00076 }
00077
00078 XmlRpc::XmlRpcValue group_number;
00079
00080
00081 group_number = topics_list[i]["group"];
00082 int group_number_int = static_cast<int>(group_number);
00083
00084 XmlRpc::XmlRpcValue name;
00085 std::string name_string;
00086
00087 name = topics_list[i]["name"];
00088 name_string = static_cast<std::string>(name);
00089
00090 XmlRpc::XmlRpcValue ns;
00091 std::string ns_string;
00092
00093 ns = topics_list[i]["ns"];
00094
00095 ns_string = static_cast<std::string>(ns);
00096
00097 ROS_DEBUG_STREAM("Setting group: " );
00098 ROS_DEBUG_STREAM(" group number: " << group_number );
00099 ROS_DEBUG_STREAM(" group number(int): " << group_number_int );
00100 ROS_DEBUG_STREAM(" joints_names(size): " << rg_joint_names.size() );
00101 ROS_DEBUG_STREAM(" name: " << name_string );
00102 ROS_DEBUG_STREAM(" ns: " << ns_string );
00103 rg.set_group_id(group_number_int);
00104 rg.set_joint_names(rg_joint_names);
00105 rg.set_name(name_string);
00106 rg.set_ns(ns_string);
00107
00108 robot_groups[group_number] = rg;
00109 }
00110
00111 ROS_INFO_STREAM("Loaded " << robot_groups.size() << " groups");
00112 return true;
00113 }
00114 else
00115 {
00116 ROS_ERROR_STREAM("Failed to find " << topic_param << " parameter");
00117 return false;
00118 }
00119 }
00120
00121 }
00122 }
00123