@@ -94,7 +94,8 @@ bool parseJointDynamics(JointDynamics &jd, tinyxml2::XMLElement* config)
9494 }
9595}
9696
97- bool parseJointLimits (JointLimits &jl, tinyxml2::XMLElement* config)
97+ bool parseJointLimits (JointLimits &jl, tinyxml2::XMLElement* config,
98+ const urdf_export_helpers::URDFVersion version)
9899{
99100 jl.clear ();
100101
@@ -174,64 +175,79 @@ bool parseJointLimits(JointLimits &jl, tinyxml2::XMLElement* config)
174175
175176 // Get joint acceleration limit
176177 const char * acceleration_str = config->Attribute (" acceleration" );
177- if (acceleration_str == NULL ){
178- CONSOLE_BRIDGE_logDebug (" urdfdom.joint_limit: no acceleration, using default value" );
179- jl.acceleration = std::numeric_limits<double >::infinity ();
180- }
181- else
182- {
183- try {
184- jl.acceleration = strToDouble (acceleration_str);
185- if (jl.acceleration < 0.0 )
186- {
187- CONSOLE_BRIDGE_logError (" acceleration value (%s) is negative" , velocity_str);
178+ if (version.less_than (1 , 2 ) && acceleration_str != NULL ) {
179+ CONSOLE_BRIDGE_logWarn (" Ignoring acceleration attribute requiring URDF version 1.2 since specified version is 1.0." );
180+ }
181+ else {
182+ if (acceleration_str == NULL ){
183+ CONSOLE_BRIDGE_logDebug (" urdfdom.joint_limit: no acceleration, using default value" );
184+ jl.acceleration = std::numeric_limits<double >::infinity ();
185+ }
186+ else
187+ {
188+ try {
189+ jl.acceleration = strToDouble (acceleration_str);
190+ if (jl.acceleration < 0.0 )
191+ {
192+ CONSOLE_BRIDGE_logError (" acceleration value (%s) is negative" , acceleration_str);
193+ return false ;
194+ }
195+ } catch (std::runtime_error &) {
196+ CONSOLE_BRIDGE_logError (" acceleration value (%s) is not a valid float" , acceleration_str);
188197 return false ;
189198 }
190- } catch (std::runtime_error &) {
191- CONSOLE_BRIDGE_logError (" acceleration value (%s) is not a valid float" , acceleration_str);
192- return false ;
193199 }
194200 }
195201
196202 // Get joint deceleration limit
197203 const char * deceleration_str = config->Attribute (" deceleration" );
198- if (deceleration_str == NULL ){
199- CONSOLE_BRIDGE_logDebug (" urdfdom.joint_limit: no deceleration, using acceleration limit" );
200- jl.deceleration = jl.acceleration ;
201- }
202- else
203- {
204- try {
205- jl.deceleration = strToDouble (deceleration_str);
206- if (jl.deceleration < 0.0 )
207- {
208- CONSOLE_BRIDGE_logError (" deceleration value (%s) is negative" , deceleration_str);
204+ if (version.less_than (1 , 2 ) && deceleration_str != NULL ) {
205+ CONSOLE_BRIDGE_logWarn (" Ignoring deceleration attribute requiring URDF version 1.2 since specified version is 1.0." );
206+ }
207+ else {
208+ if (deceleration_str == NULL ){
209+ CONSOLE_BRIDGE_logDebug (" urdfdom.joint_limit: no deceleration, using acceleration limit" );
210+ jl.deceleration = jl.acceleration ;
211+ }
212+ else
213+ {
214+ try {
215+ jl.deceleration = strToDouble (deceleration_str);
216+ if (jl.deceleration < 0.0 )
217+ {
218+ CONSOLE_BRIDGE_logError (" deceleration value (%s) is negative" , deceleration_str);
219+ return false ;
220+ }
221+ } catch (std::runtime_error &) {
222+ CONSOLE_BRIDGE_logError (" deceleration value (%s) is not a valid float" , deceleration_str);
209223 return false ;
210224 }
211- } catch (std::runtime_error &) {
212- CONSOLE_BRIDGE_logError (" deceleration value (%s) is not a valid float" , deceleration_str);
213- return false ;
214225 }
215226 }
216227
217228 // Get joint jerk limit
218229 const char * jerk_str = config->Attribute (" jerk" );
219- if (jerk_str == NULL ){
220- CONSOLE_BRIDGE_logDebug (" urdfdom.joint_limit: no jerk, using default value" );
221- jl.jerk = std::numeric_limits<double >::infinity ();
222- }
223- else
224- {
225- try {
226- jl.jerk = strToDouble (jerk_str);
227- if (jl.jerk < 0.0 )
228- {
229- CONSOLE_BRIDGE_logError (" jerk value (%s) is negative" , jerk_str);
230+ if (version.less_than (1 , 2 ) && jerk_str != NULL ) {
231+ CONSOLE_BRIDGE_logWarn (" Ignoring jerk attribute requiring URDF version 1.2 since specified version is 1.0." );
232+ }
233+ else {
234+ if (jerk_str == NULL ){
235+ CONSOLE_BRIDGE_logDebug (" urdfdom.joint_limit: no jerk, using default value" );
236+ jl.jerk = std::numeric_limits<double >::infinity ();
237+ }
238+ else
239+ {
240+ try {
241+ jl.jerk = strToDouble (jerk_str);
242+ if (jl.jerk < 0.0 )
243+ {
244+ CONSOLE_BRIDGE_logError (" jerk value (%s) is negative" , jerk_str);
245+ return false ;
246+ }
247+ } catch (std::runtime_error &) {
248+ CONSOLE_BRIDGE_logError (" jerk value (%s) is not a valid float" , jerk_str);
230249 return false ;
231250 }
232- } catch (std::runtime_error &) {
233- CONSOLE_BRIDGE_logError (" jerk value (%s) is not a valid float" , jerk_str);
234- return false ;
235251 }
236252 }
237253
@@ -523,7 +539,7 @@ bool parseJoint(Joint &joint, tinyxml2::XMLElement* config,
523539 if (limit_xml)
524540 {
525541 joint.limits .reset (new JointLimits ());
526- if (!parseJointLimits (*joint.limits , limit_xml))
542+ if (!parseJointLimits (*joint.limits , limit_xml, version ))
527543 {
528544 CONSOLE_BRIDGE_logError (" Could not parse limit element for joint [%s]" , joint.name .c_str ());
529545 joint.limits .reset ();
0 commit comments