File tree 3 files changed +27
-6
lines changed
3 files changed +27
-6
lines changed Original file line number Diff line number Diff line change @@ -192,6 +192,16 @@ namespace sdf
192
192
// / \sa const ignition::math::Inertiald &Inertial() const
193
193
public: bool SetInertial (const ignition::math::Inertiald &_inertial);
194
194
195
+ // / \brief Resolve the Inertial to a specified frame.
196
+ // / If there are any errors resolving the Inertial, the output will not
197
+ // / be modified.
198
+ // / \param[out] _inertial The resolved Inertial.
199
+ // / \param[in] _resolveTo The Inertial will be resolved with respect to this
200
+ // / frame. If unset or empty, the default resolve-to frame will be used.
201
+ // / \return Errors in resolving pose.
202
+ public: Errors ResolveInertial (ignition::math::Inertiald &_inertial,
203
+ const std::string &_resolveTo = " " ) const ;
204
+
195
205
// / \brief Get the pose of the link. This is the pose of the link
196
206
// / as specified in SDF (<link> <pose> ... </pose></link>).
197
207
// / \return The pose of the link.
Original file line number Diff line number Diff line change @@ -349,6 +349,21 @@ bool Link::SetInertial(const ignition::math::Inertiald &_inertial)
349
349
return _inertial.MassMatrix ().IsValid ();
350
350
}
351
351
352
+ // ///////////////////////////////////////////////
353
+ Errors Link::ResolveInertial (
354
+ ignition::math::Inertiald &_inertial,
355
+ const std::string &_resolveTo) const
356
+ {
357
+ ignition::math::Pose3d linkPose;
358
+ auto errors = this ->SemanticPose ().Resolve (linkPose, _resolveTo);
359
+ if (errors.empty ())
360
+ {
361
+ _inertial = this ->dataPtr ->inertial ;
362
+ _inertial.SetPose (linkPose * _inertial.Pose ());
363
+ }
364
+ return errors;
365
+ }
366
+
352
367
// ///////////////////////////////////////////////
353
368
const ignition::math::Pose3d &Link::Pose () const
354
369
{
Original file line number Diff line number Diff line change @@ -204,13 +204,9 @@ extern "C" SDFORMAT_VISIBLE int cmdInertialStats(
204
204
205
205
for (uint64_t i = 0 ; i < model->LinkCount (); i++)
206
206
{
207
- ignition::math::Pose3d linkPoseRelativeToModel;
208
- errors = model->LinkByIndex (i)->SemanticPose ().
209
- Resolve (linkPoseRelativeToModel, " __model__" );
207
+ ignition::math::Inertiald currentLinkInertial;
208
+ model->LinkByIndex (i)->ResolveInertial (currentLinkInertial, " __model__" );
210
209
211
- auto currentLinkInertial = model->LinkByIndex (i)->Inertial ();
212
- currentLinkInertial.SetPose (linkPoseRelativeToModel *
213
- currentLinkInertial.Pose ());
214
210
totalInertial += currentLinkInertial;
215
211
}
216
212
You can’t perform that action at this time.
0 commit comments