Robowflex  v0.1
Making MoveIt Easy
robowflex::darts::SO2Joint Class Reference

A SO(2) joint. Bounds are from -pi to pi, and wraps. More...

#include <joints.h>

+ Inheritance diagram for robowflex::darts::SO2Joint:

Public Member Functions

 SO2Joint (StateSpace *space, dart::dynamics::Joint *joint, unsigned int index=0)
 Constructor. More...
 
double distance (const Eigen::Ref< const Eigen::VectorXd > &a, const Eigen::Ref< const Eigen::VectorXd > &b) const override
 Compute the distance between two joint configurations. More...
 
double getMaximumExtent () const override
 Get the maximum extent of this joint (maximum distance). More...
 
void interpolate (const Eigen::Ref< const Eigen::VectorXd > &a, const Eigen::Ref< const Eigen::VectorXd > &b, double t, Eigen::Ref< Eigen::VectorXd > c) const override
 Interpolate to a new configuration c which is t from a to b. More...
 
void enforceBounds (Eigen::Ref< Eigen::VectorXd > a) const override
 Enforce bounds on a joint configuration. More...
 
bool satisfiesBounds (const Eigen::Ref< const Eigen::VectorXd > &a) const override
 Check if a joint configuration satisfies bounds. More...
 
void sample (Eigen::Ref< Eigen::VectorXd > a) const override
 Sample a configuration for this joint. More...
 
void sampleNear (Eigen::Ref< Eigen::VectorXd > a, const Eigen::Ref< const Eigen::VectorXd > &near, double r) const override
 Sample a configuration for this joint near another configuration near. More...
 
- Public Member Functions inherited from robowflex::darts::Joint
 Joint (StateSpace *space, unsigned int skelIndex, unsigned int jointIndex, unsigned int sizeInSpace, unsigned int startIndex, unsigned int numDof)
 Constructor. More...
 
 Joint (StateSpace *space, dart::dynamics::Joint *joint, unsigned int sizeInSpace, unsigned int startIndex=0, unsigned int numDof=0)
 Constructor. More...
 
Eigen::Ref< Eigen::VectorXd > getSpaceVars (Eigen::Ref< Eigen::VectorXd > a)
 Gets the joint configuration (subvector of variables for this joint) from a configuration. More...
 
Eigen::Ref< const Eigen::VectorXd > getSpaceVarsConst (const Eigen::Ref< const Eigen::VectorXd > &a)
 Gets the subvector of variables for this joint from a configuration. More...
 
const std::vector< std::size_t > & getIndices () const
 Get the indices in the skeleton for this joint. More...
 
const std::vector< std::string > & getDofs () const
 Get the names of the DoF in the skeleton for this joint. More...
 
std::size_t getSkeletonIndex () const
 Get the index of the skeleton for this joint in the world. More...
 
std::size_t getJointIndex () const
 Get the index of the joint in the skeleton. More...
 
std::size_t getDimension () const
 Get the dimension of this joint. More...
 
virtual void setUpperLimits (const Eigen::Ref< const Eigen::VectorXd > &v)
 Set the upper limits of a joint. More...
 
virtual void setLowerLimits (const Eigen::Ref< const Eigen::VectorXd > &v)
 Set the lower limits of a joint. More...
 
virtual Eigen::VectorXd getUpperLimits () const
 Get the upper limits of a joint. More...
 
virtual Eigen::VectorXd getLowerLimits () const
 Get the lower limits of a joint. More...
 
virtual void setJointState (WorldPtr world, const Eigen::Ref< const Eigen::VectorXd > &a) const
 Set the state of the joint in world. More...
 
virtual void getJointState (WorldPtr world, Eigen::Ref< Eigen::VectorXd > a) const
 Get the state of the joint in world. More...
 
dart::dynamics::Joint * getJoint (WorldPtr world) const
 Get the Dart joint from a world. More...
 

Additional Inherited Members

- Protected Attributes inherited from robowflex::darts::Joint
StateSpacespace_
 State space this joint is for. More...
 
ompl::RNG & rng_
 Random number generator. More...
 
std::vector< std::size_tindices_
 Indices this joint corresponds to. More...
 
std::vector< std::stringdofs_
 Controlled DoF names. More...
 
unsigned int skelIndex_
 Index of skeleton. More...
 
unsigned int jointIndex_
 Index of joint. More...
 
unsigned int startInSpace_
 Start index in space configuration. More...
 
unsigned int sizeInSpace_
 Size of joint in space configuration. More...
 
unsigned int startIndex_
 Start index in joint. More...
 
unsigned int numDof_
 Number of DoF this joint controls. More...
 

Detailed Description

A SO(2) joint. Bounds are from -pi to pi, and wraps.

Definition at line 284 of file joints.h.

Constructor & Destructor Documentation

◆ SO2Joint()

SO2Joint::SO2Joint ( StateSpace space,
dart::dynamics::Joint *  joint,
unsigned int  index = 0 
)

Constructor.

Parameters
[in]spaceState space.
[in]jointJoint.

SO2Joint

Definition at line 15 of file so2joint.cpp.

17  : Joint(space, joint, 1, index, 1)
18 {
19  space_->addDimension(-constants::pi, constants::pi);
20 }
StateSpace * space_
State space this joint is for.
Definition: joints.h:205
Joint(StateSpace *space, unsigned int skelIndex, unsigned int jointIndex, unsigned int sizeInSpace, unsigned int startIndex, unsigned int numDof)
Constructor.
Definition: joint.cpp:15
static const double pi
Definition: constants.h:21

Member Function Documentation

◆ distance()

double SO2Joint::distance ( const Eigen::Ref< const Eigen::VectorXd > &  a,
const Eigen::Ref< const Eigen::VectorXd > &  b 
) const
overridevirtual

Compute the distance between two joint configurations.

Parameters
[in]aJoint configuration a.
[in]bJoint configuration b.
Returns
Distance between configurations.

Implements robowflex::darts::Joint.

Definition at line 23 of file so2joint.cpp.

25 {
26  double d = std::fabs(a[0] - b[0]);
27  return (d > constants::pi) ? constants::two_pi - d : d;
28 }
T fabs(T... args)
static const double two_pi
Definition: constants.h:24

◆ enforceBounds()

void SO2Joint::enforceBounds ( Eigen::Ref< Eigen::VectorXd >  a) const
overridevirtual

Enforce bounds on a joint configuration.

Parameters
[in,out]aJoint configuration to modify.

Implements robowflex::darts::Joint.

Definition at line 60 of file so2joint.cpp.

61 {
62  double &v = a[0];
64  if (v < -constants::pi)
65  v += constants::two_pi;
66  else if (v >= constants::pi)
67  v -= constants::two_pi;
68 }
T fmod(T... args)

◆ getMaximumExtent()

double SO2Joint::getMaximumExtent ( ) const
overridevirtual

Get the maximum extent of this joint (maximum distance).

Returns
The maximum extent.

Implements robowflex::darts::Joint.

Definition at line 30 of file so2joint.cpp.

31 {
32  return constants::pi;
33 }

◆ interpolate()

void SO2Joint::interpolate ( const Eigen::Ref< const Eigen::VectorXd > &  a,
const Eigen::Ref< const Eigen::VectorXd > &  b,
double  t,
Eigen::Ref< Eigen::VectorXd >  c 
) const
overridevirtual

Interpolate to a new configuration c which is t from a to b.

Parameters
[in]aJoint configuration a.
[in]bJoint configuration b.
[in]tAmount to interpolate.
[out]cInterpolated configuration.

Implements robowflex::darts::Joint.

Definition at line 35 of file so2joint.cpp.

39 {
40  double diff = b[0] - a[0];
41  if (std::fabs(diff) <= constants::pi)
42  c[0] = a[0] + diff * t;
43  else
44  {
45  if (diff > 0.0)
46  diff = constants::two_pi - diff;
47  else
48  diff = -constants::two_pi - diff;
49 
50  double &v = c[0];
51  v = a[0] - diff * t;
52 
53  if (v > constants::pi)
54  v -= constants::two_pi;
55  else if (v < -constants::pi)
56  v += constants::two_pi;
57  }
58 }

◆ sample()

void SO2Joint::sample ( Eigen::Ref< Eigen::VectorXd >  a) const
overridevirtual

Sample a configuration for this joint.

Parameters
[out]aJoint configuration to sample.

Implements robowflex::darts::Joint.

Definition at line 76 of file so2joint.cpp.

77 {
78  a[0] = rng_.uniformReal(-constants::pi, constants::pi);
79 }
ompl::RNG & rng_
Random number generator.
Definition: joints.h:206

◆ sampleNear()

void SO2Joint::sampleNear ( Eigen::Ref< Eigen::VectorXd >  a,
const Eigen::Ref< const Eigen::VectorXd > &  near,
double  r 
) const
overridevirtual

Sample a configuration for this joint near another configuration near.

Parameters
[out]aJoint configuration to sample.
[in]nearJoint configuration to sample near.
[in]rDistance from near to sample within.

Implements robowflex::darts::Joint.

Definition at line 81 of file so2joint.cpp.

84 {
85  a[0] = rng_.uniformReal(near[0] - r, near[0] + r);
86  enforceBounds(a);
87 }
void enforceBounds(Eigen::Ref< Eigen::VectorXd > a) const override
Enforce bounds on a joint configuration.
Definition: so2joint.cpp:60

◆ satisfiesBounds()

bool SO2Joint::satisfiesBounds ( const Eigen::Ref< const Eigen::VectorXd > &  a) const
overridevirtual

Check if a joint configuration satisfies bounds.

Parameters
[in,out]aJoint configuration to check.
Returns
True if configuration satisfies bounds, false otherwise.

Implements robowflex::darts::Joint.

Definition at line 70 of file so2joint.cpp.

71 {
72  const double &v = a[0];
73  return (v >= -constants::pi) and (v <= constants::pi);
74 }

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