chrono::parsers::ChParserWheelRigYAML Class Reference

Description

Parser for YAML specification files for Chrono::Vehicle single-wheel test rig simulations (ChWheelTestRig).

A WHEEL_RIG simulation specification file references a rig mechanism file (wheel assembly, rig properties, and MBS solver) and a terrain file (terrain type, patch, parameters, and, for CRM terrain, the SPH solver), and specifies the test scenario and the wheel-terrain coupling settings. The wheel assembly is either a Chrono::Vehicle wheel, tire, and (optional) suspension specified through JSON files (VEHICLE model type), or a custom wheel assembly provided by the application (CUSTOM model type) through a factory registered with RegisterWheelAssembly.

#include <ChParserWheelRigYAML.h>

Inheritance diagram for chrono::parsers::ChParserWheelRigYAML:
Collaboration diagram for chrono::parsers::ChParserWheelRigYAML:

Public Types

using WheelAssemblyFactory = std::function< std::shared_ptr< vehicle::ChWheelTestRig::WheelAssembly >(ChSystem &sys, const YAML::Node &parameters)>
 Factory for a custom wheel assembly. More...
 
- Public Types inherited from chrono::parsers::ChParserYAML
enum  YamlFileType {
  MBS, SPH, TDPF, FSI,
  VEHICLE, WHEEL_RIG, CUSTOM
}
 Type of a Chrono YAML specification file, as declared by its type key. More...
 

Public Member Functions

 ChParserWheelRigYAML (const std::string &yaml_filename, bool verbose=false)
 
void RegisterWheelAssembly (const std::string &name, WheelAssemblyFactory factory)
 Register a factory for custom wheel assemblies with the given name. More...
 
bool IsCustomAssembly () const
 Return true if the rig model specifies a custom wheel assembly.
 
const std::string & GetAssemblyName () const
 Return the name of the custom wheel assembly (empty for a VEHICLE model type).
 
std::string GetDataFile (const std::string &filename) const
 Return the full path of a data file specified relative to the data path of the rig model specification. More...
 
virtual void LoadFile (const std::string &yaml_filename) override
 Load the specified WHEEL_RIG simulation specification file (and the rig and terrain files it references).
 
std::shared_ptr< vehicle::ChWheelTestRig > CreateRig (ChSystem &sys)
 Create the single-wheel test rig in the given system from the cached specification, then initialize it. More...
 
std::shared_ptr< vehicle::ChWheelTestRig > GetRig () const
 Return the test rig (null if not yet created).
 
vehicle::ChWheelTestRig::TerrainType GetTerrainType () const
 Return the terrain type.
 
double GetRigStep () const
 Return the rig step, i.e., the interval for each call to ChWheelTestRig::Advance. More...
 
bool StopAtPatchEnd () const
 Return true if the simulation should end when the wheel reaches the end of the terrain patch. More...
 
virtual bool OutputEnabled () const override
 Return true if generating output, i.e., writing an output database or recording data for plots.
 
bool PlotsEnabled () const
 Return true if plots were requested (in the plots section of the simulation specification).
 
virtual void WriteOutput (int frame, double time) override
 Write the rig output channels (see ChWheelTestRig::GetOutputChannels) at the current time and record them for plotting (if plots were requested). More...
 
void GeneratePlots ()
 Generate the requested plots from the data recorded during the simulation. More...
 
const ChVector3d & GetCameraOffset () const
 Return the camera location relative to the wheel hub position.
 
const ChVector3d & GetCameraTargetOffset () const
 Return the camera look-at point relative to the wheel hub position.
 
- Public Member Functions inherited from chrono::parsers::ChParserMbsYAML
 ChParserMbsYAML (bool verbose=false)
 
 ChParserMbsYAML (const std::string &yaml_filename, bool verbose=false)
 
bool HasSolverData () const
 Return true if a YAML solver file has been loaded.
 
bool HasModelData () const
 Return true if a YAML model file has been loaded.
 
virtual void LoadSimData (const YAML::Node &yaml) override
 Load the simulation, output, and visualization settings from the specified YAML node.
 
virtual void LoadModelData (const YAML::Node &yaml)
 Load the MBS model from the specified YAML node.
 
virtual void LoadSolverData (const YAML::Node &yaml)
 Load the solver parameters from the specified YAML node.
 
std::shared_ptr< ChSystem > CreateSystem ()
 Create and return a Chrono system configured from cached simulation parameters. More...
 
void SetSimulationParameters (ChSystem &sys)
 Set solver and integrator settings from cached values. More...
 
double GetTimestep () const
 
double GetEndtime () const
 
bool EnforceRealtime () const
 
const ChVector3d & GetGravitationalAcceleration () const
 
VisualizationType GetVisualizationType () const
 
int Populate (ChSystem &sys, const ChFramed &model_frame=ChFramed(), const std::string &model_prefix="")
 Populate the given system with the cached Chrono components. More...
 
void Depopulate (ChSystem &sys, int instance_index)
 Remove from the specified system the Chrono objects from the specified instance.
 
int GetNumInstances () const
 Return the number of instances created from the YAML model file.
 
std::shared_ptr< ChBodyAuxRef > FindBodyByName (const std::string &name) const
 Find and return the body with specified name, in the current model instance.
 
std::shared_ptr< ChBodyAuxRef > FindBodyByName (const std::string &name, int model_instance) const
 Find and return the body with specified name, in the given model instance.
 
std::vector< std::shared_ptr< ChBodyAuxRef > > FindBodiesByName (const std::string &name) const
 Find and return bodies with given base name from all model instances.
 
std::shared_ptr< ChLinkMotor > FindMotorByName (const std::string &name) const
 Find and return the motor with specified name, in the current model instance.
 
std::shared_ptr< ChLinkMotor > FindMotorByName (const std::string &name, int model_instance) const
 Find and return the motor with specified name, in the given model instance.
 
std::vector< std::shared_ptr< ChLinkMotor > > FindMotorsByName (const std::string &name) const
 Find and return motors with given base name from all model instances.
 
void AttachLoadController (std::shared_ptr< ChLoadController > controller, const std::string &name, int model_instance)
 Attach the external controller for the load controller with given name. More...
 
void AttachMotorController (std::shared_ptr< ChMotorController > controller, const std::string &name, int model_instance)
 Attach the external controller for the motor controller with given name. More...
 
void DoStepDynamics ()
 Advance dynamics of the multibody system. More...
 
void ApplyLoadControllerLoads (const LoadControllerLoads &controller_loads)
 Apply loads generated by the load controllers in the given list. More...
 
void ApplyMotorControllerActuations (const MotorControllerActuations &controller_loads)
 Apply actuations generated by the motor controllers in the given list. More...
 
const ChAssembly::Components & GetOutputComponents () const
 Get the model components included in output (from all model instances populated so far).
 
- Public Member Functions inherited from chrono::parsers::ChParserYAML
void SetVerbose (bool verbose)
 Set verbose terminal output (default: false).
 
virtual void SetOutputDir (const std::string &out_dir)
 Set root output directory (default: "."). More...
 
const std::string & GetName () const
 Return the name of the YAML model.
 
const ChOutput::Settings & GetOutputSettings () const
 Return all output settings.
 
ChOutput::Format GetOutputFormat () const
 Return the output type.
 
ChOutput::Mode GetOutputMode () const
 Return the output mode.
 
virtual double GetOutputFPS () const
 Return the output frequency.
 
virtual bool VisualizationEnabled () const
 Return true if visualization is enabled.
 
const ChVisualSystem::Settings & GetVisualizationSettings () const
 Return all visualization settings.
 
double GetRenderFPS () const
 
CameraVerticalDir GetCameraVerticalDir () const
 
const ChVector3d & GetCameraLocation () const
 
const ChVector3d & GetCameraTarget () const
 
bool EnableShadows () const
 
bool WriteImages () const
 
const std::string & GetImageDir () const
 
virtual void Output (double time)
 Generate output at the current frame. More...
 
virtual bool Render (ChVisualSystem &vis, double time)
 Render the current frame using the specified visual system if run-time visualization is available and enabled. More...
 

Additional Inherited Members

- Static Public Member Functions inherited from chrono::parsers::ChParserYAML
static YamlFileType ReadYamlFileType (const std::string &yaml_filename)
 Peek in the specified YAML file and read the declared file type. More...
 
- Static Protected Member Functions inherited from chrono::parsers::ChParserYAML
static YamlFileType ReadYamlFileType (const YAML::Node &a)
 Read the YAML file type from the given node. More...
 
- Protected Attributes inherited from chrono::parsers::ChParserYAML
std::string m_name
 name of the YAML model
 
bool m_verbose
 verbose terminal output (default: false)
 
bool m_use_degrees
 all angles given in degrees (default: true)
 
ChVisualSystem::Settings m_vis_settings
 visualization settings
 
ChOutput::Settings m_output_settings
 output settings
 
std::string m_output_dir
 root output directory
 
std::shared_ptr< ChOutput > m_output_db
 output database
 
ChYamlFileHandler m_file_handler
 handler for data file paths
 

Member Typedef Documentation

◆ WheelAssemblyFactory

using chrono::parsers::ChParserWheelRigYAML::WheelAssemblyFactory = std::function<std::shared_ptr<vehicle::ChWheelTestRig::WheelAssembly>(ChSystem& sys, const YAML::Node& parameters)>

Factory for a custom wheel assembly.

The factory is invoked with the containing system and the parameters node of the rig model specification (an undefined node if no parameters are specified) and must return a wheel assembly constructed in that system.

Member Function Documentation

◆ CreateRig()

std::shared_ptr< vehicle::ChWheelTestRig > chrono::parsers::ChParserWheelRigYAML::CreateRig ( ChSystem &  sys)

Create the single-wheel test rig in the given system from the cached specification, then initialize it.

The system should be created with CreateSystem().

◆ GeneratePlots()

void chrono::parsers::ChParserWheelRigYAML::GeneratePlots ( )

Generate the requested plots from the data recorded during the simulation.

For each figure, a Gnuplot script is written to the output directory and executed, producing an image file or an interactive window. This function must be called once, at the end of the simulation; it does nothing if no plots were requested. Plotting requires the Chrono::Postprocess module and Gnuplot.

◆ GetDataFile()

std::string chrono::parsers::ChParserWheelRigYAML::GetDataFile ( const std::string &  filename) const
inline

Return the full path of a data file specified relative to the data path of the rig model specification.

This can be used by custom wheel assembly factories to locate their data files.

◆ GetRigStep()

double chrono::parsers::ChParserWheelRigYAML::GetRigStep ( ) const
inline

Return the rig step, i.e., the interval for each call to ChWheelTestRig::Advance.

With CRM terrain, this is the FSI coupling step.

◆ RegisterWheelAssembly()

void chrono::parsers::ChParserWheelRigYAML::RegisterWheelAssembly ( const std::string &  name,
WheelAssemblyFactory  factory 
)

Register a factory for custom wheel assemblies with the given name.

A rig model of CUSTOM type uses the factory registered under the name specified as model.assembly. Factories must be registered before calling CreateRig.

◆ StopAtPatchEnd()

bool chrono::parsers::ChParserWheelRigYAML::StopAtPatchEnd ( ) const
inline

Return true if the simulation should end when the wheel reaches the end of the terrain patch.

See ChWheelTestRig::PatchEndReached.

◆ WriteOutput()

void chrono::parsers::ChParserWheelRigYAML::WriteOutput ( int  frame,
double  time 
)
overridevirtual

Write the rig output channels (see ChWheelTestRig::GetOutputChannels) at the current time and record them for plotting (if plots were requested).

The output directory must be set (SetOutputDir) and the rig created (CreateRig) before generating output.

Reimplemented from chrono::parsers::ChParserMbsYAML.


The documentation for this class was generated from the following files:
  • /builds/uwsbel/chrono/src/chrono_parsers/yaml/ChParserWheelRigYAML.h
  • /builds/uwsbel/chrono/src/chrono_parsers/yaml/ChParserWheelRigYAML.cpp