Description

Generic robot actuation driver using interpolated data from files.

ChRobotActuation takes 3 input files, the lines of which contain a time stamp and values for the motor actuations (equal in number to the number of specified motors). The "cycle" input data file is required, while the "start" and "stop" input files are optional. Within each input data file, time stamps are assumed to start at 0. Actuations at the current time are calculated (through linear interpolation within each data set) each time the Update() function is called.

In the most general case, the robot is assumed to go through the following phases:

1. POSE:
   During this phase (of user-specified duration), the actuations are evolved to the initial pose, defined by the
   first line of the "start" dataset (if it exists, otherwise, the "cycle" dataset).
   This is done by interpolation using a logistic function.
2. HOLD:
   During this phase (of user-specified duration), the robot holds the initial pose.
3. START:
   During this phase, the robot assumes the pose necessary for a particular operation mode.
4. CYCLE:
   This is the main operating phase. This phase can be repeated if so indicated.
5. STOP:
   During this phase, the robot assumes a rest end position.

The different input data files are assumed to be consistent with each other (for example, the end of the "start" dataset must match the beginning of a cycle.

#include <ChRobotActuation.h>

Collaboration diagram for chrono::models::ChRobotActuation:

Classes

class  PhaseChangeCallback
 Class to be used as callback interface for user-defined actions at phase changes. More...
 

Public Types

enum  Phase {
  Phase::POSE, Phase::HOLD, Phase::START, Phase::CYCLE,
  Phase::STOP
}
 Actuation phases. More...
 
typedef std::vector< double > Actuation
 

Public Member Functions

 ChRobotActuation (int num_motors, const std::string &filename_start, const std::string &filename_cycle, const std::string &filename_stop, bool repeat=false)
 Construct a robot actuator using the specified input data files. More...
 
void SetVerbose (bool verbose)
 Enable/disable verbose output (default: false).
 
void SetDrivingMode (bool drivemode)
 Set the driving mode to accept external inputs (default: false).
 
void SetTimeOffsets (double time_pose, double time_hold)
 Specify time intervals to assume and then hold the initial pose (default: 1s, 1s). More...
 
const Actuation & GetActuation () const
 Return the current motor actuations.
 
Actuation & GetActuation ()
 
void SetActuation (Actuation ext_act)
 Directly feed actuations to the motors.
 
std::string GetCurrentPhase () const
 Return the current phase.
 
void SetPhase (Phase phase)
 Set (force) the phase.
 
void RegisterPhaseChangeCallback (PhaseChangeCallback *callback)
 Register a phase-change callback object.
 
void Update (double time)
 Update internal state of the robot driver.
 

Static Public Member Functions

static std::string GetPhaseAsString (Phase phase)
 

Protected Member Functions

void LoadDataLine (double &time, Actuation &buffer)
 

Protected Attributes

int m_num_motors
 number of actuated motors
 
bool m_verbose
 verbose output
 
std::ifstream m_ifs_start
 input file stream for start phase
 
std::ifstream m_ifs_cycle
 input file stream for cycle phase
 
std::ifstream m_ifs_stop
 input file stream for stop phase
 
std::ifstream * m_ifs
 active input file stream
 
double m_time_pose
 time interval to assume initial pose
 
double m_time_hold
 time interval to hold initial pose
 
double m_offset
 current time offset in input files
 
bool m_repeat
 repeat cycle
 
Phase m_phase
 current phase
 
double m_time_1
 time for cached actuations
 
double m_time_2
 time for cached actuations
 
Actuation m_actuations_1
 cached actuations (before)
 
Actuation m_actuations_2
 cached actuations (after)
 
Actuation m_actuations
 current actuations
 
PhaseChangeCallbackm_callback
 user callback for phase change
 
bool m_driven = false
 true if the using external inputs instead of reading from a file
 

Friends

class RoboSimian
 

Member Enumeration Documentation

◆ Phase

Actuation phases.

Enumerator
POSE 

from design configuration to an initial pose

HOLD 

hold the last configuration

START 

from initial pose to operating pose

CYCLE 

operation (periodic)

STOP 

from operating pose to final pose

Constructor & Destructor Documentation

◆ ChRobotActuation()

chrono::models::ChRobotActuation::ChRobotActuation ( int  num_motors,
const std::string &  filename_start,
const std::string &  filename_cycle,
const std::string &  filename_stop,
bool  repeat = false 
)

Construct a robot actuator using the specified input data files.

The data files for the "start" and "stop" phases are not required (pass an empty string).

Parameters
num_motorsnumber of actuated motors
filename_startname of file with joint actuations for start phase
filename_cyclename of file with joint actuations for cycle phase
filename_stopname of file with joint actuations for stop phase
repeattrue if cycle phase is looped

Member Function Documentation

◆ SetTimeOffsets()

void chrono::models::ChRobotActuation::SetTimeOffsets ( double  time_pose,
double  time_hold 
)

Specify time intervals to assume and then hold the initial pose (default: 1s, 1s).

Parameters
time_posetime to transition to initial pose (duration of POSE phase)
time_holdtime to hold initial pose (duration of HOLD phase)

The documentation for this class was generated from the following files:
  • /builds/uwsbel/chrono/src/chrono_models/robot/ChRobotActuation.h
  • /builds/uwsbel/chrono/src/chrono_models/robot/ChRobotActuation.cpp