chrono::vehicle::ChVehicleCosimTerrainNode Class Referenceabstract

Description

Base class for a terrain node.

Implements required functionality for a co-simulation node (Initialize(), Synchronize(), Advance()) and all MPI communication.

A derived class must implement functions to:

Optionally, a derived class may implement functions to:

#include <ChVehicleCosimTerrainNode.h>

Inheritance diagram for chrono::vehicle::ChVehicleCosimTerrainNode:
Collaboration diagram for chrono::vehicle::ChVehicleCosimTerrainNode:

Public Member Functions

virtual NodeType GetNodeType () const override
 Return the node type as NodeType::TERRAIN.
 
void SetDimensions (double length, double width)
 Set the terrain patch dimensions. More...
 
void GetDimensions (double &length, double &width)
 Get the terrain patch dimensions.
 
virtual void Initialize () override final
 Initialize this node. More...
 
virtual void Synchronize (int step_number, double time) override final
 Synchronize this node. More...
 
virtual void Advance (double step_size) override final
 Advance simulation. More...
 
virtual void OutputData (int frame) override final
 Output logging and debugging data.
 
virtual void OutputVisualizationData (int frame) override
 Output post-processing visualization data. More...
 
virtual unsigned int GetNumContacts () const
 Return current number of contacts. More...
 
- Public Member Functions inherited from chrono::vehicle::ChVehicleCosimBaseNode
std::string GetNodeTypeString () const
 Return the node type as a string.
 
bool IsCosimNode () const
 Return true if this node is part of the co-simulation infrastructure.
 
void SetStepSize (double step)
 Set the integration step size (default: 1e-4).
 
double GetStepSize () const
 Get the integration step size.
 
void SetOutDir (const std::string &dir_name, const std::string &suffix="")
 Set the name of the output directory and an identifying suffix. More...
 
void SetVerbose (bool verbose)
 Enable/disable verbose messages during simulation (default: true).
 
void EnableRuntimeVisualization (double render_fps=100, bool save_img=false)
 Enable run-time visualization (default: false). More...
 
void SetCameraPosition (const ChVector3d &cam_pos, const ChVector3d &cam_target=VNULL)
 Set camera location and target point.
 
void SetCameraTracking (bool track)
 Enable/disable tracking of objects (default: true).
 
void EnablePostprocessVisualization (double render_fps=100)
 Enable Blender postprocessing (default: false). More...
 
const std::string & GetOutDirName () const
 Get the output directory name for this node.
 
double GetStepExecutionTime () const
 Get the simulation execution time for the current step on this node. More...
 
double GetTotalExecutionTime () const
 Get the cumulative simulation execution time on this node.
 
virtual void OnRender ()
 Render the current simulation frame. More...
 
void Render (double step_size)
 Render simulation frame. More...
 
virtual void WriteCheckpoint (const std::string &filename) const
 Write checkpoint to the specified file (which will be created in the output directory).
 

Protected Member Functions

 ChVehicleCosimTerrainNode (double length, double width)
 Construct a terrain node to wrap a terrain patch of given length and width.
 
virtual bool SupportsMeshInterface () const =0
 Specify whether or not the terrain node supports the MESH communication interface. More...
 
virtual double GetInitHeight () const =0
 Return the terrain initial height. More...
 
virtual void OnInitialize (unsigned int num_objects)=0
 Perform any additional operations after the initial data exchange with the MBS node, including creating any required proxies for the specified number of objects. More...
 
virtual void OnSynchronize (int step_number, double time)
 Perform any additional operations after the data exchange and synchronization with the MBS node. More...
 
virtual void OnAdvance (double step_size)=0
 Advance the state of the terrain system by the specified step.
 
virtual void OnOutputData (int frame)
 Perform additional output at the specified frame (called from within OutputData).
 
virtual void UpdateMeshProxy (unsigned int i, MeshState &mesh_state)
 Update the state of the i-th proxy mesh. More...
 
virtual void GetForceMeshProxy (unsigned int i, MeshContact &mesh_contact)
 Collect cumulative contact forces on the i-th proxy mesh. More...
 
virtual void UpdateRigidProxy (unsigned int i, BodyState &rigid_state)=0
 Update the state of the i-th proxy rigid. More...
 
virtual void GetForceRigidProxy (unsigned int i, TerrainForce &rigid_contact)=0
 Collect cumulative contact force and torque on the i-th proxy rigid. More...
 
- Protected Member Functions inherited from chrono::vehicle::ChVehicleCosimBaseNode
 ChVehicleCosimBaseNode (const std::string &name)
 
virtual ChSystemGetSystemPostprocess () const =0
 Get the Chrono system that holds the visualization shapes (used only for post-processing export).
 
void SendGeometry (const utils::ChBodyGeometry &geom, int dest) const
 Utility function to pack and send a struct with geometry information.
 
void RecvGeometry (utils::ChBodyGeometry &geom, int source) const
 Utility function to receive and unpack a struct with geometry information.
 
void ProgressBar (unsigned int x, unsigned int n, unsigned int w=50)
 Utility function to display a progress bar to the terminal. More...
 

Protected Attributes

double m_dimX
 patch length (X direction)
 
double m_dimY
 patch width (Y direction)
 
bool m_wheeled
 comm node (true: TIRE nodes, false: tracked MBS node)
 
InterfaceType m_interface_type
 communication interface (body or mesh)
 
int m_num_objects
 number of interacting objects
 
std::vector< ChAABBm_aabb
 AABB of collision models for interacting objects.
 
std::vector< utils::ChBodyGeometrym_geometry
 contact geometry and materials for interacting objects
 
std::vector< double > m_load_mass
 vertical load on interacting objects
 
std::vector< int > m_obj_map
 mapping from interacting object to shape
 
std::vector< MeshState > m_mesh_state
 mesh state (used for MESH communication)
 
std::vector< BodyStatem_rigid_state
 rigid state (used for BODY communication interface)
 
std::vector< MeshContactm_mesh_contact
 mesh contact forces (used for MESH communication interface)
 
std::vector< TerrainForcem_rigid_contact
 rigid contact force (used for BODY communication interface)
 
- Protected Attributes inherited from chrono::vehicle::ChVehicleCosimBaseNode
int m_rank
 MPI rank of this node (in MPI_COMM_WORLD)
 
double m_step_size
 integration step size
 
std::string m_name
 name of the node
 
std::string m_out_dir
 top-level output directory
 
std::string m_node_out_dir
 node-specific output directory
 
std::ofstream m_outf
 output file stream
 
bool m_renderRT
 if true, perform run-time rendering
 
bool m_renderRT_all
 if true, render all frames
 
double m_renderRT_step
 time step between rendered frames
 
bool m_writeRT
 if true, write images to file
 
bool m_renderPP
 if true, save data for post-processing
 
bool m_renderPP_all
 if true, save data at all frames
 
double m_renderPP_step
 time step between post-processing save frames
 
bool m_track
 track objects
 
ChVector3d m_cam_pos
 camera location
 
ChVector3d m_cam_target
 camera target (lookat) point
 
unsigned int m_num_wheeled_mbs_nodes
 
unsigned int m_num_tracked_mbs_nodes
 
unsigned int m_num_terrain_nodes
 
unsigned int m_num_tire_nodes
 
ChTimer m_timer
 timer for integration cost
 
double m_cum_sim_time
 cumulative integration cost
 
bool m_verbose
 verbose messages during simulation?
 

Additional Inherited Members

- Public Types inherited from chrono::vehicle::ChVehicleCosimBaseNode
enum  NodeType { NodeType::MBS_WHEELED, NodeType::MBS_TRACKED, NodeType::TERRAIN, NodeType::TIRE }
 Type of node participating in co-simulation. More...
 
enum  InterfaceType { InterfaceType::BODY, InterfaceType::MESH }
 Type of the vehicle-terrain communication interface. More...
 
- Static Public Member Functions inherited from chrono::vehicle::ChVehicleCosimBaseNode
static std::string OutputFilename (const std::string &dir, const std::string &root, const std::string &ext, int frame, int frame_digits)
 Utility function for creating an output file name. More...
 
- Static Protected Attributes inherited from chrono::vehicle::ChVehicleCosimBaseNode
static const double m_gacc = -9.81
 

Member Function Documentation

◆ Advance()

void chrono::vehicle::ChVehicleCosimTerrainNode::Advance ( double  step_size)
finaloverridevirtual

Advance simulation.

This function is called after a synchronization to allow the node to advance its state by the specified time step. A node is allowed to take as many internal integration steps as required, but no inter-node communication should occur.

Implements chrono::vehicle::ChVehicleCosimBaseNode.

◆ GetForceMeshProxy()

virtual void chrono::vehicle::ChVehicleCosimTerrainNode::GetForceMeshProxy ( unsigned int  i,
MeshContact mesh_contact 
)
inlineprotectedvirtual

Collect cumulative contact forces on the i-th proxy mesh.

Load indices of vertices in contact and the corresponding vertex forces (expressed in absolute frame) into the provided MeshContact struct.

◆ GetForceRigidProxy()

virtual void chrono::vehicle::ChVehicleCosimTerrainNode::GetForceRigidProxy ( unsigned int  i,
TerrainForce rigid_contact 
)
protectedpure virtual

Collect cumulative contact force and torque on the i-th proxy rigid.

Load contact forces (expressed in absolute frame) into the provided TerrainForce struct.

◆ GetInitHeight()

virtual double chrono::vehicle::ChVehicleCosimTerrainNode::GetInitHeight ( ) const
protectedpure virtual

Return the terrain initial height.

This value must be available before the call to Initialize() (and therefore, before the derived class's OnInitialize() is called).

Implemented in chrono::vehicle::ChVehicleCosimTerrainNodeChrono.

◆ GetNumContacts()

virtual unsigned int chrono::vehicle::ChVehicleCosimTerrainNode::GetNumContacts ( ) const
inlinevirtual

Return current number of contacts.

(concrete terrain specific)

◆ Initialize()

void chrono::vehicle::ChVehicleCosimTerrainNode::Initialize ( )
finaloverridevirtual

Initialize this node.

This function allows the node to initialize itself and, optionally, perform an initial data exchange with any other node.

Reimplemented from chrono::vehicle::ChVehicleCosimBaseNode.

◆ OnInitialize()

virtual void chrono::vehicle::ChVehicleCosimTerrainNode::OnInitialize ( unsigned int  num_objects)
protectedpure virtual

Perform any additional operations after the initial data exchange with the MBS node, including creating any required proxies for the specified number of objects.

A derived class has access to the following vectors, each of size m_num_shapes:

  • m_aabb: collision model bounding box
  • m_load_mass: vertical load on each object
  • m_geometry: collision geometry and contact material for each object

Implemented in chrono::vehicle::ChVehicleCosimTerrainNodeGranularOMP, chrono::vehicle::ChVehicleCosimTerrainNodeChrono, chrono::vehicle::ChVehicleCosimTerrainNodeGranularGPU, chrono::vehicle::ChVehicleCosimTerrainNodeSCM, chrono::vehicle::ChVehicleCosimTerrainNodeRigid, and chrono::vehicle::ChVehicleCosimTerrainNodeGranularSPH.

◆ OnSynchronize()

virtual void chrono::vehicle::ChVehicleCosimTerrainNode::OnSynchronize ( int  step_number,
double  time 
)
inlineprotectedvirtual

Perform any additional operations after the data exchange and synchronization with the MBS node.

A derived class has access to the following vectors (of size equal to the number of interacting objects):

  • full dynamic state of the rigid bodies (through m_rigid_state) when using the BODY communication interface
  • state of the mesh vertices (through m_mesh_state) when using the MESH communication interface

◆ OutputVisualizationData()

virtual void chrono::vehicle::ChVehicleCosimTerrainNode::OutputVisualizationData ( int  frame)
inlineoverridevirtual

Output post-processing visualization data.

If implemented, this function should write a file in the "visualization" subdirectory of m_node_out_dir.

Implements chrono::vehicle::ChVehicleCosimBaseNode.

Reimplemented in chrono::vehicle::ChVehicleCosimTerrainNodeGranularOMP, chrono::vehicle::ChVehicleCosimTerrainNodeGranularGPU, chrono::vehicle::ChVehicleCosimTerrainNodeRigid, and chrono::vehicle::ChVehicleCosimTerrainNodeGranularSPH.

◆ SetDimensions()

void chrono::vehicle::ChVehicleCosimTerrainNode::SetDimensions ( double  length,
double  width 
)

Set the terrain patch dimensions.

If invoked, this function must be called before Initialize.

◆ SupportsMeshInterface()

virtual bool chrono::vehicle::ChVehicleCosimTerrainNode::SupportsMeshInterface ( ) const
protectedpure virtual

Specify whether or not the terrain node supports the MESH communication interface.

See ChVehicleCosimBaseNode::InterfaceType. A terrain that also supports the MESH communication interface must override the functions UpdateMeshProxy() and GetForceMeshProxy().

◆ Synchronize()

void chrono::vehicle::ChVehicleCosimTerrainNode::Synchronize ( int  step_number,
double  time 
)
finaloverridevirtual

Synchronize this node.

This function is called at every co-simulation synchronization time to allow the node to exchange information with any other node.

Implements chrono::vehicle::ChVehicleCosimBaseNode.

◆ UpdateMeshProxy()

virtual void chrono::vehicle::ChVehicleCosimTerrainNode::UpdateMeshProxy ( unsigned int  i,
MeshState &  mesh_state 
)
inlineprotectedvirtual

Update the state of the i-th proxy mesh.

Use information in the provided MeshState struct (vertex positions and velocities expressed in absolute frame).

◆ UpdateRigidProxy()

virtual void chrono::vehicle::ChVehicleCosimTerrainNode::UpdateRigidProxy ( unsigned int  i,
BodyState rigid_state 
)
protectedpure virtual

Update the state of the i-th proxy rigid.

Use information in the provided BodyState struct (pose and velocities expressed in absolute frame).


The documentation for this class was generated from the following files:
  • /builds/uwsbel/chrono/src/chrono_vehicle/cosim/ChVehicleCosimTerrainNode.h
  • /builds/uwsbel/chrono/src/chrono_vehicle/cosim/ChVehicleCosimTerrainNode.cpp