From 969b5e6d7a5a6ecba007979183a6e18ca6b24e0a Mon Sep 17 00:00:00 2001 From: meeussen Date: Mon, 26 Oct 2009 19:51:25 +0000 Subject: [PATCH] fix optional-required field checking --- urdf/src/joint.cpp | 71 +- urdf/src/model.cpp | 3 + urdf/test/pr2_desc.xml | 1773 +++++++++++++++++++++++++++++----------- 3 files changed, 1353 insertions(+), 494 deletions(-) diff --git a/urdf/src/joint.cpp b/urdf/src/joint.cpp index 3f1cfce..345ad49 100644 --- a/urdf/src/joint.cpp +++ b/urdf/src/joint.cpp @@ -1,5 +1,5 @@ /********************************************************************* -* Software License Agreement (BSD License) +* Software Ligcense Agreement (BSD License) * * Copyright (c) 2008, Willow Garage, Inc. * All rights reserved. @@ -45,15 +45,19 @@ bool JointDynamics::initXml(TiXmlElement* config) // Get joint damping const char* damping_str = config->Attribute("damping"); - if (damping_str == NULL) - ROS_DEBUG("joint dynamics: no damping"); + if (damping_str == NULL){ + ROS_DEBUG("joint dynamics: no damping, defaults to 0"); + this->damping = 0; + } else this->damping = atof(damping_str); // Get joint friction const char* friction_str = config->Attribute("friction"); - if (friction_str == NULL) - ROS_DEBUG("joint dynamics: no friction"); + if (friction_str == NULL){ + ROS_DEBUG("joint dynamics: no friction, defaults to 0"); + this->friction = 0; + } else this->friction = atof(friction_str); @@ -74,39 +78,41 @@ bool JointLimits::initXml(TiXmlElement* config) // Get lower joint limit const char* lower_str = config->Attribute("lower"); - if (lower_str == NULL) - ROS_DEBUG("joint limit: no lower"); + if (lower_str == NULL){ + ROS_DEBUG("joint limit: no lower, defaults to 0"); + this->lower = 0; + } else this->lower = atof(lower_str); // Get upper joint limit const char* upper_str = config->Attribute("upper"); - if (upper_str == NULL) - ROS_DEBUG("joint limit: no upper"); + if (upper_str == NULL){ + ROS_DEBUG("joint limit: no upper, , defaults to 0"); + this->upper = 0; + } else this->upper = atof(upper_str); // Get joint effort limit const char* effort_str = config->Attribute("effort"); - if (effort_str == NULL) - ROS_DEBUG("joint limit: no effort"); + if (effort_str == NULL){ + ROS_ERROR("joint limit: no effort"); + return false; + } else this->effort = atof(effort_str); // Get joint velocity limit const char* velocity_str = config->Attribute("velocity"); - if (velocity_str == NULL) - ROS_DEBUG("joint limit: no velocity"); - else - this->velocity = atof(velocity_str); - - if (lower_str == NULL && upper_str == NULL && effort_str == NULL && velocity_str == NULL) - { - ROS_ERROR("joint limit element specified with no readable attributes"); + if (velocity_str == NULL){ + ROS_ERROR("joint limit: no velocity"); return false; } else - return true; + this->velocity = atof(velocity_str); + + return true; } bool JointSafety::initXml(TiXmlElement* config) @@ -146,8 +152,8 @@ bool JointSafety::initXml(TiXmlElement* config) const char* k_velocity_str = config->Attribute("k_velocity"); if (k_velocity_str == NULL) { - ROS_DEBUG("joint safety: no k_velocity, using default value"); - this->k_velocity = 0; + ROS_ERROR("joint safety: no k_velocity"); + return false; } else this->k_velocity = atof(k_velocity_str); @@ -180,8 +186,8 @@ bool JointMimic::initXml(TiXmlElement* config) const char* joint_name_str = config->Attribute("joint"); if (joint_name_str == NULL) { - ROS_WARN("joint mimic: no mimic joint specified"); - return false; + ROS_ERROR("joint mimic: no mimic joint specified"); + //return false; } else this->joint_name = joint_name_str; @@ -328,8 +334,19 @@ bool Joint::initXml(TiXmlElement* config) { ROS_ERROR("Could not parse limit element for joint '%s'", this->name.c_str()); limits.reset(); + return false; } } + else if (this->type == REVOLUTE) + { + ROS_ERROR("Joint '%s' is of type REVOLUTE but it does not specify limits", this->name.c_str()); + return false; + } + else if (this->type == REVOLUTE || this->type == PRISMATIC) + { + ROS_ERROR("Joint '%s' is of type REVOLUTE but it does not specify limits", this->name.c_str()); + limits.reset(); + } // Get safety TiXmlElement *safety_xml = config->FirstChildElement("safety_controller"); @@ -340,6 +357,7 @@ bool Joint::initXml(TiXmlElement* config) { ROS_ERROR("Could not parse safety element for joint '%s'", this->name.c_str()); safety.reset(); + return false; } } @@ -352,6 +370,7 @@ bool Joint::initXml(TiXmlElement* config) { ROS_ERROR("Could not parse calibration element for joint '%s'", this->name.c_str()); calibration.reset(); + return false; } } @@ -362,8 +381,9 @@ bool Joint::initXml(TiXmlElement* config) mimic.reset(new JointMimic); if (!mimic->initXml(mimic_xml)) { - ROS_WARN("Could not parse mimic element for joint '%s'", this->name.c_str()); + ROS_ERROR("Could not parse mimic element for joint '%s'", this->name.c_str()); mimic.reset(); + return false; } } @@ -376,6 +396,7 @@ bool Joint::initXml(TiXmlElement* config) { ROS_ERROR("Could not parse joint_dynamics element for joint '%s'", this->name.c_str()); dynamics.reset(); + return false; } } diff --git a/urdf/src/model.cpp b/urdf/src/model.cpp index 9b301a4..ee3fa9c 100644 --- a/urdf/src/model.cpp +++ b/urdf/src/model.cpp @@ -132,6 +132,7 @@ bool Model::initXml(TiXmlElement *robot_xml) { ROS_ERROR("material xml is not initialized correctly"); material.reset(); + return false; } } @@ -187,6 +188,7 @@ bool Model::initXml(TiXmlElement *robot_xml) { ROS_ERROR("link xml is not initialized correctly"); link.reset(); + return false; } } // Get all Joint elements @@ -213,6 +215,7 @@ bool Model::initXml(TiXmlElement *robot_xml) { ROS_ERROR("joint xml is not initialized correctly"); joint.reset(); + return false; } } diff --git a/urdf/test/pr2_desc.xml b/urdf/test/pr2_desc.xml index 46efbc9..de8f6ed 100644 --- a/urdf/test/pr2_desc.xml +++ b/urdf/test/pr2_desc.xml @@ -1,19 +1,28 @@ - + - - - - - - - - - + + + + + + + + + + + + + true + 1000.0 + + + true @@ -42,7 +51,36 @@ + + + + + + + + + + + + + + + + + + + + + + + @@ -55,22 +93,24 @@ - - - - + + + + + - - - - + + + + + - - + @@ -81,46 +121,19 @@ - - - - + + + + + + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + @@ -141,26 +154,26 @@ - + - - + + + + - + - + - -75.05 - - - + -75.0676691729 + @@ -174,22 +187,23 @@ - + - - + + + - + - + - fl_caster_l_wheel_collision + fl_caster_l_wheel_link_geom 100.0 true @@ -198,17 +212,15 @@ + - - - - + - 75.05 + 75.0676691729 @@ -223,22 +235,23 @@ - + - - + + + - + - + - fl_caster_r_wheel_collision + fl_caster_r_wheel_link_geom 100.0 true @@ -247,17 +260,15 @@ + - - - - + - -75.05 + -75.0676691729 @@ -275,26 +286,26 @@ - + - - + + + + - + - + - -75.05 - - - + -75.0676691729 + @@ -308,22 +319,23 @@ - + - - + + + - + - + - fr_caster_l_wheel_collision + fr_caster_l_wheel_link_geom 100.0 true @@ -332,17 +344,15 @@ + - - - - + - 75.05 + 75.0676691729 @@ -357,22 +367,23 @@ - + - - + + + - + - + - fr_caster_r_wheel_collision + fr_caster_r_wheel_link_geom 100.0 true @@ -381,17 +392,15 @@ + - - - - + - -75.05 + -75.0676691729 @@ -409,26 +418,26 @@ - + - - + + + + - + - + - -75.05 - - - + -75.0676691729 + @@ -442,22 +451,23 @@ - + - - + + + - + - + - bl_caster_l_wheel_collision + bl_caster_l_wheel_link_geom 100.0 true @@ -466,17 +476,15 @@ + - - - - + - 75.05 + 75.0676691729 @@ -491,22 +499,23 @@ - + - - + + + - + - + - bl_caster_r_wheel_collision + bl_caster_r_wheel_link_geom 100.0 true @@ -515,17 +524,15 @@ + - - - - + - -75.05 + -75.0676691729 @@ -543,26 +550,26 @@ - + - - + + + + - + - + - -75.05 - - - + -75.0676691729 + @@ -576,22 +583,23 @@ - + - - + + + - + - + - br_caster_l_wheel_collision + br_caster_l_wheel_link_geom 100.0 true @@ -600,17 +608,15 @@ + - - - - + - 75.05 + 75.0676691729 @@ -625,22 +631,23 @@ - + - - + + + - + - + - br_caster_r_wheel_collision + br_caster_r_wheel_link_geom 100.0 true @@ -649,20 +656,19 @@ + - - - - + - -75.05 + -75.0676691729 + - base_collision + base_link_geom 100.0 true @@ -671,11 +677,13 @@ - - - + + + + + base_link true 100.0 @@ -687,6 +695,17 @@ 0 0 0 + + true + 100.0 + plug_holder + plug_holder_pose_ground_truth + 0.01 + map + 0 0 0 + 0 0 0 + + 640 @@ -695,8 +714,8 @@ 0.0 0.0 0.0 false - -100 - 100 + -135 + 135 0.05 10.0 @@ -712,24 +731,37 @@ - + - - true - 100.0 - plug_magnet - plug_magnet_pose_ground_truth - 0.01 - map - 0 0 0 - 0 0 0 - - - - - + - + + + + + + + + + + + + + + + + + + + + + + + + + + + @@ -745,6 +777,7 @@ + @@ -753,24 +786,50 @@ - + + - + - + + - + + + torso_lift_link_geom + 100.0 + + true + 100.0 + torso_lift_bumper + + + + + + + true + 100.0 + torso_lift_link + imu_data + 0.01 + map + 0 0 0 + 0 0 0 + + + -52143.33 - - - + + @@ -792,8 +851,10 @@ - + + + @@ -809,14 +870,12 @@ 6.0 - - - + - + @@ -832,8 +891,10 @@ - + + + @@ -844,9 +905,7 @@ - - - + 6.0 @@ -867,6 +926,8 @@ + + @@ -877,19 +938,593 @@ - - - + - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + R8G8B8 + 2448 2050 + 45 + 0.1 + 100 + 20.0 + + true + 20.0 + prosilica/cam_info + prosilica/image + prosilica/image_rect + prosilica/cam_info_service + prosilica/poll + hight_def_optical_frame + 1224.5 + 1224.5 + 1025.5 + 2955 + 0 + 0 + 0 + 0 + 0 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 640 480 + L8 + 90 + 0.1 + 100 + 20.0 + + true + 20.0 + wide_stereo/left_image + wide_stereo_l_stereo_camera_frame + + + + + + + 640 480 + L8 + 90 + 0.1 + 100 + 20.0 + + true + 20.0 + wide_stereo/right_image + wide_stereo_r_stereo_camera_frame + + + + + + + true + 20.0 + wide_stereo_l_sensor + wide_stereo_r_sensor + wide_stereo/raw_stereo + wide_stereo_optical_frame + 320 + 320 + 240 + 320 + 0 + 0 + 0 + 0 + 0 + -0.09 + + + + + + + + + 640 480 + L8 + 45 + 0.1 + 100 + 20.0 + + true + 20.0 + narrow_stereo/left_image + narrow_stereo_l_stereo_camera_frame + + + + + + + 640 480 + L8 + 45 + 0.1 + 100 + 20.0 + + true + 20.0 + narrow_stereo/right_image + narrow_stereo_r_stereo_camera_frame + + + + + + + true + 20.0 + narrow_stereo_l_sensor + narrow_stereo_r_sensor + narrow_stereo/raw_stereo + narrow_stereo_optical_frame + 320 + 320 + 240 + 772.55 + 0 + 0 + 0 + 0 + 0 + -0.09 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 640 + 640 + 1 + + 0.0 0.0 0.0 + false + + -80 + 80 + + 0.05 + 10.0 + 0.01 + 40.0 + + 0.005 + true + 40.0 + tilt_scan + laser_tilt_link + + + + + + + 6.0 + @@ -917,15 +1552,15 @@ - + - + - + @@ -934,7 +1569,7 @@ - + @@ -951,15 +1586,15 @@ - + - + - + @@ -984,8 +1619,10 @@ - + + + @@ -1010,14 +1647,16 @@ - + + + - + @@ -1042,14 +1681,16 @@ - + + + - + @@ -1074,8 +1715,10 @@ - + + + @@ -1098,14 +1741,16 @@ - + + + - + @@ -1128,19 +1773,22 @@ - + + + - + - + + @@ -1156,8 +1804,10 @@ - + + + @@ -1168,7 +1818,7 @@ - r_shoulder_pan_collision + r_shoulder_pan_link_geom 100.0 true @@ -1179,11 +1829,12 @@ true + - r_shoulder_lift_collision_geom + r_shoulder_lift_link_geom 100.0 true @@ -1193,18 +1844,19 @@ true + - true + - r_upper_arm_collision_geom + r_upper_arm_link_geom 100.0 true @@ -1217,7 +1869,7 @@ - r_elbow_flex_collision_geom + r_elbow_flex_link_geom 100.0 true @@ -1227,17 +1879,19 @@ + true + - true - true + + true - r_forearm_collision + r_forearm_link_geom 100.0 true @@ -1250,7 +1904,7 @@ true - r_wrist_flex_collision + r_wrist_flex_link_geom 100.0 true @@ -1260,12 +1914,13 @@ + true - r_wrist_roll_collision + r_wrist_roll_link_geom 100.0 true @@ -1275,6 +1930,7 @@ + @@ -1301,25 +1957,7 @@ - - - - - - - - - - - - - - - - - - - + @@ -1334,19 +1972,43 @@ - + + + - + + + + + + + + + + + + + + + + + + + + + + + - - + + @@ -1364,6 +2026,8 @@ + + @@ -1377,20 +2041,20 @@ - - + - + - + + - + @@ -1416,23 +2080,24 @@ - + + + - + - + - - + @@ -1446,23 +2111,24 @@ - + + + - + - + - - + @@ -1476,23 +2142,24 @@ - + + + - + - + - - + @@ -1506,20 +2173,22 @@ - + + + - + true - r_gripper_l_finger_collision + r_gripper_l_finger_link_geom 100.0 true @@ -1534,14 +2203,15 @@ + - + true - r_gripper_r_finger_collision + r_gripper_r_finger_link_geom 100.0 true @@ -1555,19 +2225,16 @@ + - + - - - - true - r_gripper_l_finger_tip_collision + r_gripper_l_finger_tip_link_geom 100.0 true @@ -1578,21 +2245,19 @@ - + - + + - + - - - true - r_gripper_r_finger_tip_collision + r_gripper_r_finger_tip_link_geom 100.0 true @@ -1603,16 +2268,10 @@ - + - - - - - - - - + + true 100.0 @@ -1630,22 +2289,19 @@ r_gripper_l_finger_link - - - - - - - - - + + + + + + - + true - r_gripper_palm_collision + r_gripper_palm_link_geom 100.0 true @@ -1658,6 +2314,7 @@ true + r_gripper_l_finger_tip_link r_gripper_float_link @@ -1683,7 +2340,7 @@ 0.08 --> - + true 100.0 @@ -1695,16 +2352,21 @@ map - + + true + 100.0 + r_gripper_tool_frame + r_gripper_tool_frame_pose_ground_truth + 0 0 0 + 0 0 0 + 0.0 + /map + + + true - - - - - - - + @@ -1739,15 +2401,15 @@ - + - + - + @@ -1756,7 +2418,7 @@ - + @@ -1773,15 +2435,15 @@ - + - + - + @@ -1806,8 +2468,10 @@ - + + + @@ -1832,14 +2496,16 @@ - + + + - + @@ -1864,14 +2530,16 @@ - + + + - + @@ -1896,8 +2564,10 @@ - + + + @@ -1920,14 +2590,16 @@ - + + + - + @@ -1950,19 +2622,22 @@ - + + + - + - + + @@ -1978,8 +2653,10 @@ - + + + @@ -1990,7 +2667,7 @@ - l_shoulder_pan_collision + l_shoulder_pan_link_geom 100.0 true @@ -2001,11 +2678,12 @@ true + - l_shoulder_lift_collision_geom + l_shoulder_lift_link_geom 100.0 true @@ -2015,18 +2693,19 @@ true + - true + - l_upper_arm_collision_geom + l_upper_arm_link_geom 100.0 true @@ -2039,7 +2718,7 @@ - l_elbow_flex_collision_geom + l_elbow_flex_link_geom 100.0 true @@ -2049,17 +2728,19 @@ + true + - true - true + + true - l_forearm_collision + l_forearm_link_geom 100.0 true @@ -2072,7 +2753,7 @@ true - l_wrist_flex_collision + l_wrist_flex_link_geom 100.0 true @@ -2082,12 +2763,13 @@ + true - l_wrist_roll_collision + l_wrist_roll_link_geom 100.0 true @@ -2097,6 +2779,7 @@ + @@ -2123,25 +2806,7 @@ - - - - - - - - - - - - - - - - - - - + @@ -2156,19 +2821,43 @@ - + + + - + + + + + + + + + + + + + + + + + + + + + + + - - + + @@ -2186,6 +2875,8 @@ + + @@ -2199,20 +2890,20 @@ - - + - + - + + - + @@ -2238,23 +2929,24 @@ - + + + - + - + - - + @@ -2268,23 +2960,24 @@ - + + + - + - + - - + @@ -2298,23 +2991,24 @@ - + + + - + - + - - + @@ -2328,20 +3022,22 @@ - + + + - + true - l_gripper_l_finger_collision + l_gripper_l_finger_link_geom 100.0 true @@ -2356,14 +3052,15 @@ + - + true - l_gripper_r_finger_collision + l_gripper_r_finger_link_geom 100.0 true @@ -2377,19 +3074,16 @@ + - + - - - - true - l_gripper_l_finger_tip_collision + l_gripper_l_finger_tip_link_geom 100.0 true @@ -2400,21 +3094,19 @@ - + - + + - + - - - true - l_gripper_r_finger_tip_collision + l_gripper_r_finger_tip_link_geom 100.0 true @@ -2425,16 +3117,10 @@ - + - - - - - - - - + + true 100.0 @@ -2452,22 +3138,19 @@ l_gripper_l_finger_link - - - - - - - - - + + + + + + - + true - l_gripper_palm_collision + l_gripper_palm_link_geom 100.0 true @@ -2480,6 +3163,7 @@ true + l_gripper_l_finger_tip_link l_gripper_float_link @@ -2505,7 +3189,7 @@ 0.08 --> - + true 100.0 @@ -2517,16 +3201,21 @@ map - + + true + 100.0 + l_gripper_tool_frame + l_gripper_tool_frame_pose_ground_truth + 0 0 0 + 0 0 0 + 0.0 + /map + + + true - - - - - - - + @@ -2535,7 +3224,153 @@ - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 640 480 + L8 + 90 + 0.1 + 100 + 20.0 + + true + 20.0 + l_forearm_cam/image + l_forearm_cam_frame + + + + true + PR2/Blue + + true + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 640 480 + L8 + 90 + 0.1 + 100 + 20.0 + + true + 20.0 + r_forearm_cam/image + r_forearm_cam_frame + + + + true + PR2/Blue + + true + + +