sot-torque-control  1.5.2
JointTrajectoryGenerator Class Reference

#include <sot/torque_control/joint-trajectory-generator.hh>

Inheritance diagram for JointTrajectoryGenerator:
[legend]
Collaboration diagram for JointTrajectoryGenerator:
[legend]

Public Member Functions

 JointTrajectoryGenerator (const std::string &name)
 
 DECLARE_SIGNAL (fLeftFoot, OUT, dynamicgraph::Vector)
 
 DECLARE_SIGNAL (fLeftHand, OUT, dynamicgraph::Vector)
 
 DECLARE_SIGNAL (fRightFoot, OUT, dynamicgraph::Vector)
 
 DECLARE_SIGNAL (fRightHand, OUT, dynamicgraph::Vector)
 
 DECLARE_SIGNAL_IN (base6d_encoders, dynamicgraph::Vector)
 
 DECLARE_SIGNAL_OUT (ddq, dynamicgraph::Vector)
 
 DECLARE_SIGNAL_OUT (dq, dynamicgraph::Vector)
 
 DECLARE_SIGNAL_OUT (q, dynamicgraph::Vector)
 
virtual void display (std::ostream &os) const
 
void getJoint (const std::string &jointName)
 
void init (const double &dt, const std::string &robotRef)
 
bool isTrajectoryEnded ()
 
void moveForce (const std::string &forceName, const int &axis, const double &fFinal, const double &time)
 
void moveJoint (const std::string &jointName, const double &qFinal, const double &time)
 
void playTrajectoryFile (const std::string &fileName)
 
void sendMsg (const std::string &msg, MsgType t=MSG_TYPE_INFO, const char *="", int=0)
 
void startConstAcc (const std::string &jointName, const double &qFinal, const double &time)
 
void startForceLinearChirp (const std::string &forceName, const int &axis, const double &fFinal, const double &f0, const double &f1, const double &time)
 
void startForceSinusoid (const std::string &forceName, const int &axis, const double &fFinal, const double &time)
 
void startLinearChirp (const std::string &jointName, const double &qFinal, const double &f0, const double &f1, const double &time)
 
void startSinusoid (const std::string &jointName, const double &qFinal, const double &time)
 
void startTriangle (const std::string &jointName, const double &qFinal, const double &time, const double &Tacc)
 
void stop (const std::string &jointName)
 
void stopForce (const std::string &forceName)
 

Protected Types

enum  JTG_Status {
  JTG_STOP,
  JTG_SINUSOID,
  JTG_MIN_JERK,
  JTG_LIN_CHIRP,
  JTG_TRIANGLE,
  JTG_CONST_ACC,
  JTG_TEXT_FILE
}
 

Protected Member Functions

bool convertForceNameToForceId (const std::string &name, unsigned int &id)
 
bool convertJointNameToJointId (const std::string &name, unsigned int &id)
 
 DECLARE_SIGNAL_OUT_FUNCTION (fLeftFoot, dynamicgraph::Vector)
 
 DECLARE_SIGNAL_OUT_FUNCTION (fLeftHand, dynamicgraph::Vector)
 
 DECLARE_SIGNAL_OUT_FUNCTION (fRightFoot, dynamicgraph::Vector)
 
 DECLARE_SIGNAL_OUT_FUNCTION (fRightHand, dynamicgraph::Vector)
 
bool generateReferenceForceSignal (const std::string &forceName, int fid, dynamicgraph::Vector &s, int iter)
 
bool isForceInRange (unsigned int id, const Eigen::VectorXd &f)
 
bool isForceInRange (unsigned int id, int axis, double f)
 
bool isJointInRange (unsigned int id, double q)
 

Protected Attributes

std::vector< ConstantAccelerationTrajectoryGenerator * > m_constAccTrajGen
 
std::vector< AbstractTrajectoryGenerator * > m_currentTrajGen
 status of the joints More...
 
std::vector< AbstractTrajectoryGenerator * > m_currentTrajGen_force
 status of the forces More...
 
double m_dt
 true if it is the first iteration, false otherwise More...
 
bool m_firstIter
 true if the entity has been successfully initialized More...
 
bool m_initSucceeded
 
std::vector< int > m_iterForceSignals
 
std::vector< LinearChirpTrajectoryGenerator * > m_linChirpTrajGen
 
std::vector< LinearChirpTrajectoryGenerator * > m_linChirpTrajGen_force
 
std::vector< MinimumJerkTrajectoryGenerator * > m_minJerkTrajGen
 
std::vector< MinimumJerkTrajectoryGenerator * > m_minJerkTrajGen_force
 
std::vector< NoTrajectoryGenerator * > m_noTrajGen
 
std::vector< NoTrajectoryGenerator * > m_noTrajGen_force
 
RobotUtilShrPtr m_robot_util
 control loop time period More...
 
std::vector< SinusoidTrajectoryGenerator * > m_sinTrajGen
 
std::vector< SinusoidTrajectoryGenerator * > m_sinTrajGen_force
 
std::vector< JTG_Statusm_status
 
std::vector< JTG_Statusm_status_force
 
TextFileTrajectoryGeneratorm_textFileTrajGen
 
std::vector< TriangleTrajectoryGenerator * > m_triangleTrajGen
 

Detailed Description

Definition at line 45 of file joint-trajectory-generator.hh.

Member Enumeration Documentation

◆ JTG_Status

enum JTG_Status
protected
Enumerator
JTG_STOP 
JTG_SINUSOID 
JTG_MIN_JERK 
JTG_LIN_CHIRP 
JTG_TRIANGLE 
JTG_CONST_ACC 
JTG_TEXT_FILE 

Definition at line 155 of file joint-trajectory-generator.hh.

Constructor & Destructor Documentation

◆ JointTrajectoryGenerator()

Member Function Documentation

◆ convertForceNameToForceId()

bool convertForceNameToForceId ( const std::string &  name,
unsigned int &  id 
)
protected

◆ convertJointNameToJointId()

◆ DECLARE_SIGNAL() [1/4]

DECLARE_SIGNAL ( fLeftFoot  ,
OUT  ,
dynamicgraph::Vector   
)

◆ DECLARE_SIGNAL() [2/4]

DECLARE_SIGNAL ( fLeftHand  ,
OUT  ,
dynamicgraph::Vector   
)

◆ DECLARE_SIGNAL() [3/4]

DECLARE_SIGNAL ( fRightFoot  ,
OUT  ,
dynamicgraph::Vector   
)

◆ DECLARE_SIGNAL() [4/4]

DECLARE_SIGNAL ( fRightHand  ,
OUT  ,
dynamicgraph::Vector   
)

◆ DECLARE_SIGNAL_IN()

DECLARE_SIGNAL_IN ( base6d_encoders  ,
dynamicgraph::Vector   
)

◆ DECLARE_SIGNAL_OUT() [1/3]

DECLARE_SIGNAL_OUT ( ddq  ,
dynamicgraph::Vector   
)

◆ DECLARE_SIGNAL_OUT() [2/3]

DECLARE_SIGNAL_OUT ( dq  ,
dynamicgraph::Vector   
)

◆ DECLARE_SIGNAL_OUT() [3/3]

DECLARE_SIGNAL_OUT ( ,
dynamicgraph::Vector   
)

◆ DECLARE_SIGNAL_OUT_FUNCTION() [1/4]

DECLARE_SIGNAL_OUT_FUNCTION ( fLeftFoot  ,
dynamicgraph::Vector   
)
protected

◆ DECLARE_SIGNAL_OUT_FUNCTION() [2/4]

DECLARE_SIGNAL_OUT_FUNCTION ( fLeftHand  ,
dynamicgraph::Vector   
)
protected

◆ DECLARE_SIGNAL_OUT_FUNCTION() [3/4]

DECLARE_SIGNAL_OUT_FUNCTION ( fRightFoot  ,
dynamicgraph::Vector   
)
protected

◆ DECLARE_SIGNAL_OUT_FUNCTION() [4/4]

DECLARE_SIGNAL_OUT_FUNCTION ( fRightHand  ,
dynamicgraph::Vector   
)
protected

◆ display()

void display ( std::ostream &  os) const
virtual

Definition at line 705 of file joint-trajectory-generator.cpp.

◆ generateReferenceForceSignal()

◆ getJoint()

void getJoint ( const std::string &  jointName)

Print the current angle of the specified joint.

Definition at line 346 of file joint-trajectory-generator.cpp.

References JointTrajectoryGenerator::convertJointNameToJointId().

Referenced by JointTrajectoryGenerator::JointTrajectoryGenerator().

◆ init()

◆ isForceInRange() [1/2]

bool isForceInRange ( unsigned int  id,
const Eigen::VectorXd &  f 
)
protected

◆ isForceInRange() [2/2]

bool isForceInRange ( unsigned int  id,
int  axis,
double  f 
)
protected

◆ isJointInRange()

◆ isTrajectoryEnded()

◆ moveForce()

◆ moveJoint()

void moveJoint ( const std::string &  jointName,
const double &  qFinal,
const double &  time 
)

Move a joint to a position with a minimum-jerk trajectory.

Parameters
jointNameThe short name of the joint.
qFinalThe desired final position of the joint [rad].
timeThe time to go from the current position to qFinal [sec].

Definition at line 557 of file joint-trajectory-generator.cpp.

References JointTrajectoryGenerator::convertJointNameToJointId(), JointTrajectoryGenerator::isJointInRange(), JointTrajectoryGenerator::JTG_MIN_JERK, JointTrajectoryGenerator::JTG_STOP, JointTrajectoryGenerator::m_currentTrajGen, JointTrajectoryGenerator::m_initSucceeded, JointTrajectoryGenerator::m_minJerkTrajGen, JointTrajectoryGenerator::m_noTrajGen, and JointTrajectoryGenerator::m_status.

Referenced by JointTrajectoryGenerator::JointTrajectoryGenerator().

◆ playTrajectoryFile()

◆ sendMsg()

void sendMsg ( const std::string &  msg,
MsgType  t = MSG_TYPE_INFO,
const char *  = "",
int  = 0 
)
inline

Definition at line 150 of file joint-trajectory-generator.hh.

◆ startConstAcc()

void startConstAcc ( const std::string &  jointName,
const double &  qFinal,
const double &  time 
)

Start an infinite trajectory with piece-wise constant acceleration.

Parameters
jointNameThe short name of the joint.
qFinalThe position of the joint corresponding to the max amplitude of the trajectory [rad].
timeThe time to go from the current position to qFinal [sec].
TaccThe time during witch acceleration is keept constant [sec].

Definition at line 459 of file joint-trajectory-generator.cpp.

References JointTrajectoryGenerator::convertJointNameToJointId(), JointTrajectoryGenerator::isJointInRange(), JointTrajectoryGenerator::JTG_CONST_ACC, JointTrajectoryGenerator::JTG_STOP, JointTrajectoryGenerator::m_constAccTrajGen, JointTrajectoryGenerator::m_currentTrajGen, JointTrajectoryGenerator::m_initSucceeded, JointTrajectoryGenerator::m_noTrajGen, and JointTrajectoryGenerator::m_status.

Referenced by JointTrajectoryGenerator::JointTrajectoryGenerator().

◆ startForceLinearChirp()

◆ startForceSinusoid()

void startForceSinusoid ( const std::string &  forceName,
const int &  axis,
const double &  fFinal,
const double &  time 
)

Start an infinite sinusoidal trajectory for the specified force signal.

Parameters
forceNameThe short name of the force signal (rh, lh, rf, lf).
fFinalThe 6d force corresponding to the max amplitude of the sinusoid [N/Nm].
timeThe time to go from 0 to fFinal [sec].

Definition at line 478 of file joint-trajectory-generator.cpp.

References JointTrajectoryGenerator::convertForceNameToForceId(), JointTrajectoryGenerator::isForceInRange(), JointTrajectoryGenerator::JTG_SINUSOID, JointTrajectoryGenerator::JTG_STOP, JointTrajectoryGenerator::m_currentTrajGen_force, JointTrajectoryGenerator::m_initSucceeded, JointTrajectoryGenerator::m_noTrajGen_force, JointTrajectoryGenerator::m_sinTrajGen_force, and JointTrajectoryGenerator::m_status_force.

Referenced by JointTrajectoryGenerator::JointTrajectoryGenerator().

◆ startLinearChirp()

void startLinearChirp ( const std::string &  jointName,
const double &  qFinal,
const double &  f0,
const double &  f1,
const double &  time 
)

Start a linear-chirp trajectory, that is a sinusoidal trajectory with frequency being a linear function of time.

Parameters
jointNameThe short name of the joint.
qFinalThe position of the joint corresponding to the max amplitude of the sinusoid [rad].
f0The initial (min) frequency of the sinusoid [Hz]
f1The final (max) frequency of the sinusoid [Hz]
timeThe time to get from f0 to f1 [sec]

Definition at line 501 of file joint-trajectory-generator.cpp.

References JointTrajectoryGenerator::convertJointNameToJointId(), JointTrajectoryGenerator::isJointInRange(), JointTrajectoryGenerator::JTG_LIN_CHIRP, JointTrajectoryGenerator::JTG_STOP, JointTrajectoryGenerator::m_currentTrajGen, JointTrajectoryGenerator::m_initSucceeded, JointTrajectoryGenerator::m_linChirpTrajGen, JointTrajectoryGenerator::m_noTrajGen, and JointTrajectoryGenerator::m_status.

Referenced by JointTrajectoryGenerator::JointTrajectoryGenerator().

◆ startSinusoid()

void startSinusoid ( const std::string &  jointName,
const double &  qFinal,
const double &  time 
)

Start an infinite sinusoidal trajectory.

Parameters
jointNameThe short name of the joint.
qFinalThe position of the joint corresponding to the max amplitude of the sinusoid [rad].
timeThe time to go from the current position to qFinal [sec].

Definition at line 416 of file joint-trajectory-generator.cpp.

References JointTrajectoryGenerator::convertJointNameToJointId(), JointTrajectoryGenerator::isJointInRange(), JointTrajectoryGenerator::JTG_SINUSOID, JointTrajectoryGenerator::JTG_STOP, JointTrajectoryGenerator::m_currentTrajGen, JointTrajectoryGenerator::m_initSucceeded, JointTrajectoryGenerator::m_noTrajGen, JointTrajectoryGenerator::m_sinTrajGen, and JointTrajectoryGenerator::m_status.

Referenced by JointTrajectoryGenerator::JointTrajectoryGenerator().

◆ startTriangle()

void startTriangle ( const std::string &  jointName,
const double &  qFinal,
const double &  time,
const double &  Tacc 
)

Start an infinite triangle trajectory.

Parameters
jointNameThe short name of the joint.
qFinalThe position of the joint corresponding to the max amplitude of the trajectory [rad].
timeThe time to go from the current position to qFinal [sec].

Definition at line 434 of file joint-trajectory-generator.cpp.

References JointTrajectoryGenerator::convertJointNameToJointId(), JointTrajectoryGenerator::isJointInRange(), JointTrajectoryGenerator::JTG_STOP, JointTrajectoryGenerator::JTG_TRIANGLE, JointTrajectoryGenerator::m_currentTrajGen, JointTrajectoryGenerator::m_initSucceeded, JointTrajectoryGenerator::m_noTrajGen, JointTrajectoryGenerator::m_status, and JointTrajectoryGenerator::m_triangleTrajGen.

Referenced by JointTrajectoryGenerator::JointTrajectoryGenerator().

◆ stop()

void stop ( const std::string &  jointName)

◆ stopForce()

void stopForce ( const std::string &  forceName)

Member Data Documentation

◆ m_constAccTrajGen

std::vector<ConstantAccelerationTrajectoryGenerator*> m_constAccTrajGen
protected

◆ m_currentTrajGen

◆ m_currentTrajGen_force

◆ m_dt

double m_dt
protected

true if it is the first iteration, false otherwise

Definition at line 159 of file joint-trajectory-generator.hh.

Referenced by JointTrajectoryGenerator::init().

◆ m_firstIter

bool m_firstIter
protected

true if the entity has been successfully initialized

Definition at line 158 of file joint-trajectory-generator.hh.

Referenced by JointTrajectoryGenerator::init().

◆ m_initSucceeded

◆ m_iterForceSignals

std::vector<int> m_iterForceSignals
protected

◆ m_linChirpTrajGen

std::vector<LinearChirpTrajectoryGenerator*> m_linChirpTrajGen
protected

◆ m_linChirpTrajGen_force

◆ m_minJerkTrajGen

◆ m_minJerkTrajGen_force

◆ m_noTrajGen

◆ m_noTrajGen_force

◆ m_robot_util

◆ m_sinTrajGen

std::vector<SinusoidTrajectoryGenerator*> m_sinTrajGen
protected

◆ m_sinTrajGen_force

◆ m_status

◆ m_status_force

◆ m_textFileTrajGen

◆ m_triangleTrajGen

std::vector<TriangleTrajectoryGenerator*> m_triangleTrajGen
protected

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