Gazebo Physics

API Reference

8.0.0
RelativeQuantity< Q, Dim, CoordinateSpace > Class Template Reference

The RelativeQuantity class is a wrapper for classes that represent mathematical quantities (e.g. points, vectors, matrices, transforms). The purpose of this wrapper is to endow raw mathematical quantities with frame semantics, so that they can express the frame of reference of their values. More...

#include <RelativeQuantity.hh>

Public Types

enum  { Dimension = Dim }
 The number of physical (spatial) dimensions that this quantity exists in. Only values of 2 or 3 are supported. More...
 
using Quantity = Q
 The underlying type of the quantity that is being expressed.
 
using Space = CoordinateSpace
 The mathematical space which defines how this quantity is transformed between reference frames.
 

Public Member Functions

template<typename... Args>
 RelativeQuantity (const FrameID &_parentID, Args &&... _args)
 This constructor will specify the parent frame and then forward the remaining arguments to the constructor of the underlying quantity.
 
 RelativeQuantity (const Q &_rawValue)
 Implicit conversion constructor.
 
void MoveToNewParentFrame (const FrameID &_newParentFrame)
 This function will change the parent frame of your RelativeQuantity.
 
const FrameIDParentFrame () const
 Get the ID of this RelativeQuantity's parent frame.
 
Q & RelativeToParent ()
 Get the value of this RelativeQuantity relative to its parent frame. To get the value of this RelativeQuantity with respect to the world frame, use the FrameSemantics::Resolve(~) function of your physics engine like so:
 
const Q & RelativeToParent () const
 const-qualified version of RelativeToParent.
 

Detailed Description

template<typename Q, std::size_t Dim, typename CoordinateSpace>
class gz::physics::RelativeQuantity< Q, Dim, CoordinateSpace >

The RelativeQuantity class is a wrapper for classes that represent mathematical quantities (e.g. points, vectors, matrices, transforms). The purpose of this wrapper is to endow raw mathematical quantities with frame semantics, so that they can express the frame of reference of their values.

Note that the raw value of the quantity being held can only be retrieved through the member function RelativeToParent(). We choose to contain the quantity like this instead of inheriting it to avoid a situation where a user might add two relative quantities like

u = v + w

where v and w belong to different frames. That would be an ill-formed expression, since values that are being expressed in different reference frames are not directly compatible. Use the Resolve(~) or Reframe(~) function in the FrameSemantics interface of your physics engine plugin to transform a RelativeQuantity into a different reference frame.

Member Typedef Documentation

◆ Quantity

template<typename Q , std::size_t Dim, typename CoordinateSpace >
using Quantity = Q

The underlying type of the quantity that is being expressed.

◆ Space

template<typename Q , std::size_t Dim, typename CoordinateSpace >
using Space = CoordinateSpace

The mathematical space which defines how this quantity is transformed between reference frames.

Member Enumeration Documentation

◆ anonymous enum

template<typename Q , std::size_t Dim, typename CoordinateSpace >
anonymous enum

The number of physical (spatial) dimensions that this quantity exists in. Only values of 2 or 3 are supported.

Enumerator
Dimension 

Constructor & Destructor Documentation

◆ RelativeQuantity() [1/2]

template<typename Q , std::size_t Dim, typename CoordinateSpace >
template<typename... Args>
RelativeQuantity ( const FrameID _parentID,
Args &&...  _args 
)
explicit

This constructor will specify the parent frame and then forward the remaining arguments to the constructor of the underlying quantity.

◆ RelativeQuantity() [2/2]

template<typename Q , std::size_t Dim, typename CoordinateSpace >
RelativeQuantity ( const Q &  _rawValue)

Implicit conversion constructor.

Member Function Documentation

◆ MoveToNewParentFrame()

template<typename Q , std::size_t Dim, typename CoordinateSpace >
void MoveToNewParentFrame ( const FrameID _newParentFrame)

This function will change the parent frame of your RelativeQuantity.

◆ ParentFrame()

template<typename Q , std::size_t Dim, typename CoordinateSpace >
const FrameID & ParentFrame ( ) const

Get the ID of this RelativeQuantity's parent frame.

To change the parent frame of this RelativeQuantity, use the Reframe(~) function of your physics engine's FrameSemantics interface like this:

fq = engine->GetInterface<FrameSemantics>()->Reframe(fq, A);

where A is the FrameID of the new frame. The Reframe function will keep the values of your RelativeQuantity consistent (with respect to the World Frame) as it reassigns the parent frame.

Alternatively, to change the parent frame of this RelativeQuantity while making its values relative to the new frame equal to what its values were relative to the old frame, you can use the MoveToNewParentFrame(~) function below.

Referenced by gz::physics::operator<<().

◆ RelativeToParent() [1/2]

template<typename Q , std::size_t Dim, typename CoordinateSpace >
Q & RelativeToParent ( )

Get the value of this RelativeQuantity relative to its parent frame. To get the value of this RelativeQuantity with respect to the world frame, use the FrameSemantics::Resolve(~) function of your physics engine like so:

Q quantity = engine->GetInterface<FrameSemantics>()->Resolve(fq)

where Q is your quantity type, and fq is your RelativeQuantity instance.

To get the value of this RelativeQuantity with respect to an arbitrary reference frame, again use the Resolve function:

Q quantity = engine->GetInterface<FrameSemantics>()->Resolve(fq, F);

where F is the FrameID of the desired reference frame.

Referenced by gz::physics::operator<<().

◆ RelativeToParent() [2/2]

template<typename Q , std::size_t Dim, typename CoordinateSpace >
const Q & RelativeToParent ( ) const

const-qualified version of RelativeToParent.


The documentation for this class was generated from the following file: