Description

Base class for chrono vehicle systems.

The reference frame for a vehicle follows the ISO standard: Z-axis up, X-axis pointing forward, and Y-axis towards the left of the vehicle.

#include <ChVehicle.h>

Inheritance diagram for chrono::vehicle::ChVehicle:
Collaboration diagram for chrono::vehicle::ChVehicle:

Public Member Functions

virtual ~ChVehicle ()
 Destructor.
 
const std::string & GetName () const
 Get the name identifier for this vehicle.
 
void SetName (const std::string &name)
 Set the name identifier for this vehicle.
 
virtual std::string GetTemplateName () const =0
 Get the name of the vehicle system template.
 
ChSystemGetSystem ()
 Get a pointer to the Chrono ChSystem.
 
double GetChTime () const
 Get the current simulation time of the underlying ChSystem.
 
std::shared_ptr< ChChassisGetChassis () const
 Get a handle to the vehicle's main chassis subsystem.
 
std::shared_ptr< ChChassisRearGetChassisRear (int id) const
 Get the specified specified rear chassis subsystem.
 
std::shared_ptr< ChChassisConnectorGetChassisConnector (int id) const
 Get a handle to the specified chassis connector.
 
std::shared_ptr< ChBodyAuxRefGetChassisBody () const
 Get a handle to the vehicle's chassis body.
 
std::shared_ptr< ChBodyAuxRefGetChassisRearBody (int id) const
 Get a handle to the specified rear chassis body.
 
std::shared_ptr< ChPowertrainAssemblyGetPowertrainAssembly () const
 Get the powertrain attached to this vehicle.
 
std::shared_ptr< ChEngineGetEngine () const
 Get the engine in the powertrain assembly (if a powertrain is attached).
 
std::shared_ptr< ChTransmissionGetTransmission () const
 Get the transmission in the powertrain assembly (if a powertrain is attached).
 
double GetMass () const
 Get the vehicle total mass. More...
 
const ChFrameGetCOMFrame () const
 Get the current vehicle COM frame (relative to and expressed in the vehicle reference frame). More...
 
const ChMatrix33GetInertia () const
 Get the current vehicle inertia (relative to the vehicle COM frame).
 
const ChFrameMovingGetRefFrame () const
 Get the current vehicle reference frame. More...
 
const ChFrameGetTransform () const
 Get the current vehicle transform relative to the global frame. More...
 
const ChVector3dGetPos () const
 Get the vehicle global location. More...
 
ChQuaternion GetRot () const
 Get the vehicle orientation. More...
 
double GetRoll () const
 Get vehicle roll angle. More...
 
double GetPitch () const
 Get vehicle pitch angle. More...
 
double GetRoll (const ChTerrain &terrain) const
 Get vehicle roll angle (relative to local terrain). More...
 
double GetPitch (const ChTerrain &terrain) const
 Get vehicle pitch angle (relative to local terrain). More...
 
double GetSpeed () const
 Get the vehicle speed (velocity component in the vehicle forward direction). More...
 
double GetSlipAngle () const
 Get the vehicle slip angle. More...
 
double GetRollRate () const
 Get the vehicle roll rate. More...
 
double GetPitchRate () const
 Get the vehicle pitch rate. More...
 
double GetYawRate () const
 Get the vehicle yaw rate. More...
 
double GetTurnRate () const
 Get the vehicle turn rate. More...
 
ChVector3d GetPointLocation (const ChVector3d &locpos) const
 Get the global position of the specified point. More...
 
ChVector3d GetPointVelocity (const ChVector3d &locpos) const
 Get the global velocity of the specified point. More...
 
ChVector3d GetPointAcceleration (const ChVector3d &locpos) const
 Get the acceleration at the specified point. More...
 
ChVector3d GetDriverPos () const
 Get the global location of the driver.
 
void EnableRealtime (bool val)
 Enable/disable soft real-time (default: false). More...
 
double GetRTF () const
 Get current estimated RTF (real time factor). More...
 
double GetStepRTF () const
 Get current estimated step RTF (real time factor). More...
 
void SetCollisionSystemType (ChCollisionSystem::Type collsys_type)
 Change the default collision detection system. More...
 
void SetOutput (ChVehicleOutput::Type type, const std::string &out_dir, const std::string &out_name, double output_step)
 Enable output for this vehicle system. More...
 
void SetOutput (ChVehicleOutput::Type type, std::ostream &out_stream, double output_step)
 Enable output for this vehicle system using an existing output stream. More...
 
virtual void Initialize (const ChCoordsys<> &chassisPos, double chassisFwdVel=0)
 Initialize this vehicle at the specified global location and orientation. More...
 
void InitializePowertrain (std::shared_ptr< ChPowertrainAssembly > powertrain)
 Initialize the given powertrain assembly and associate it to this vehicle. More...
 
virtual void InitializeInertiaProperties ()=0
 Calculate total vehicle mass from subsystems. More...
 
void SetChassisVisualizationType (VisualizationType vis)
 Set visualization mode for the chassis subsystem.
 
void SetChassisRearVisualizationType (VisualizationType vis)
 Set visualization mode for the rear chassis subsystems.
 
void SetChassisCollide (bool state)
 Enable/disable collision for the chassis subsystem. More...
 
virtual void SetChassisVehicleCollide (bool state)
 Enable/disable collision between the chassis and all other vehicle subsystems. More...
 
void SetChassisOutput (bool state)
 Enable/disable output from the chassis subsystem.
 
bool HasBushings () const
 Return true if the vehicle model contains bushings.
 
virtual void Advance (double step)
 Advance the state of this vehicle by the specified time step. More...
 
virtual void LogConstraintViolations ()=0
 Log current constraint violations.
 
virtual std::string ExportComponentList () const =0
 Return a JSON string with information on all modeling components in the vehicle system. More...
 
virtual void ExportComponentList (const std::string &filename) const =0
 Write a JSON-format file with information on all modeling components in the vehicle system. More...
 
virtual void Output (int frame, ChVehicleOutput &database) const =0
 Output data for all modeling components in the vehicle system.
 

Protected Member Functions

 ChVehicle (const std::string &name, ChContactMethod contact_method=ChContactMethod::NSC)
 Construct a vehicle system with an underlying ChSystem. More...
 
 ChVehicle (const std::string &name, ChSystem *system)
 Construct a vehicle system using the specified ChSystem. More...
 
void SetSystem (ChSystem *sys)
 Set the associated Chrono system.
 
virtual void UpdateInertiaProperties ()=0
 Calculate current vehicle inertia properties from subsystems. More...
 

Static Protected Member Functions

template<typename T >
static bool AnyOutput (const std::vector< std::shared_ptr< T >> &list)
 Utility function for testing if any subsystem in a list generates output.
 

Protected Attributes

std::string m_name
 vehicle name
 
ChSystemm_system
 pointer to the Chrono system
 
bool m_ownsSystem
 true if system created at construction
 
double m_mass
 total vehicle mass
 
ChFrame m_com
 current vehicle COM (relative to the vehicle reference frame)
 
ChMatrix33 m_inertia
 current total vehicle inertia (Relative to the vehicle COM frame)
 
bool m_output
 generate ouput for this vehicle system
 
ChVehicleOutputm_output_db
 vehicle output database
 
double m_output_step
 output time step
 
double m_next_output_time
 time for next output
 
int m_output_frame
 current output frame
 
std::shared_ptr< ChChassism_chassis
 handle to the main chassis subsystem
 
ChChassisRearList m_chassis_rear
 list of rear chassis subsystems (can be empty)
 
ChChassisConnectorList m_chassis_connectors
 list of chassis connector (must match m_chassis_rear)
 
std::shared_ptr< ChPowertrainAssemblym_powertrain_assembly
 associated powertrain system
 

Friends

class ChVehicleCosimWheeledVehicleNode
 
class ChVehicleCosimTrackedVehicleNode
 

Constructor & Destructor Documentation

◆ ChVehicle() [1/2]

chrono::vehicle::ChVehicle::ChVehicle ( const std::string &  name,
ChContactMethod  contact_method = ChContactMethod::NSC 
)
protected

Construct a vehicle system with an underlying ChSystem.

Parameters
[in]namevehicle name
[in]contact_methodcontact method

◆ ChVehicle() [2/2]

chrono::vehicle::ChVehicle::ChVehicle ( const std::string &  name,
ChSystem system 
)
protected

Construct a vehicle system using the specified ChSystem.

All physical components of the vehicle will be added to that system.

Parameters
[in]namevehicle name
[in]systemcontaining mechanical system

Member Function Documentation

◆ Advance()

void chrono::vehicle::ChVehicle::Advance ( double  step)
virtual

Advance the state of this vehicle by the specified time step.

A call to ChSystem::DoStepDynamics is done only if the vehicle owns the underlying Chrono system. Otherwise, the caller is responsible for advancing the sate of the entire system.

Reimplemented in chrono::vehicle::ChWheeledVehicle, chrono::vehicle::ChTrackedVehicle, and chrono::vehicle::ChTrackTestRig.

◆ EnableRealtime()

void chrono::vehicle::ChVehicle::EnableRealtime ( bool  val)

Enable/disable soft real-time (default: false).

If enabled, a spinning timer is used to maintain simulation time in sync with real time. This function should be called right before the main simulation loop, since it starts the embedded ChTimer.

◆ ExportComponentList() [1/2]

virtual std::string chrono::vehicle::ChVehicle::ExportComponentList ( ) const
pure virtual

Return a JSON string with information on all modeling components in the vehicle system.

These include bodies, shafts, joints, spring-damper elements, markers, etc.

Implemented in chrono::vehicle::ChWheeledVehicle, and chrono::vehicle::ChTrackedVehicle.

◆ ExportComponentList() [2/2]

virtual void chrono::vehicle::ChVehicle::ExportComponentList ( const std::string &  filename) const
pure virtual

Write a JSON-format file with information on all modeling components in the vehicle system.

These include bodies, shafts, joints, spring-damper elements, markers, etc.

Implemented in chrono::vehicle::ChWheeledVehicle, and chrono::vehicle::ChTrackedVehicle.

◆ GetCOMFrame()

const ChFrame& chrono::vehicle::ChVehicle::GetCOMFrame ( ) const
inline

Get the current vehicle COM frame (relative to and expressed in the vehicle reference frame).

This is a frame aligned with the vehicle reference frame and origin at the current vehicle COM.

◆ GetMass()

double chrono::vehicle::ChVehicle::GetMass ( ) const
inline

Get the vehicle total mass.

This includes the mass of the chassis and all vehicle subsystems.

◆ GetPitch() [1/2]

double chrono::vehicle::ChVehicle::GetPitch ( ) const

Get vehicle pitch angle.

This version returns the pitch angle with respect to the absolte frame; as such, this is a proper representation of vehicle pitch only on flat horizontal terrain. In the ISO frame convention, a positive pitch angle corresponds to the vehicle front dipping (e.g., during braking).

◆ GetPitch() [2/2]

double chrono::vehicle::ChVehicle::GetPitch ( const ChTerrain terrain) const

Get vehicle pitch angle (relative to local terrain).

This version returns the pitch angle relative to the terrain normal at a point below the vehicle position; as such, this is a reasonable approximation of local vehicle pitch only on relatively flat (but not necessarily horizontal) terrains. In the ISO frame convention, a positive pitch angle corresponds to the vehicle front dipping below the terrain plane.

◆ GetPitchRate()

double chrono::vehicle::ChVehicle::GetPitchRate ( ) const
inline

Get the vehicle pitch rate.

The pitch rate is referenced to the chassis frame.

◆ GetPointAcceleration()

ChVector3d chrono::vehicle::ChVehicle::GetPointAcceleration ( const ChVector3d locpos) const
inline

Get the acceleration at the specified point.

The point is assumed to be given relative to the main chassis reference frame. The returned acceleration is expressed in the chassis reference frame.

◆ GetPointLocation()

ChVector3d chrono::vehicle::ChVehicle::GetPointLocation ( const ChVector3d locpos) const
inline

Get the global position of the specified point.

The point is assumed to be given relative to the main chassis reference frame. The returned location is expressed in the global reference frame.

◆ GetPointVelocity()

ChVector3d chrono::vehicle::ChVehicle::GetPointVelocity ( const ChVector3d locpos) const
inline

Get the global velocity of the specified point.

The point is assumed to be given relative to the main chassis reference frame. The returned velocity is expressed in the global reference frame.

◆ GetPos()

const ChVector3d& chrono::vehicle::ChVehicle::GetPos ( ) const
inline

Get the vehicle global location.

This is the global location of the main chassis reference frame origin.

◆ GetRefFrame()

const ChFrameMoving& chrono::vehicle::ChVehicle::GetRefFrame ( ) const
inline

Get the current vehicle reference frame.

This is the same as the reference frame of the chassis.

◆ GetRoll() [1/2]

double chrono::vehicle::ChVehicle::GetRoll ( ) const

Get vehicle roll angle.

This version returns the roll angle with respect to the absolte frame; as such, this is a proper representation of vehicle roll only on flat horizontal terrain. In the ISO frame convention, a positive roll angle corresponds to the vehicle left side lifting (e.g., in a turn to the left).

◆ GetRoll() [2/2]

double chrono::vehicle::ChVehicle::GetRoll ( const ChTerrain terrain) const

Get vehicle roll angle (relative to local terrain).

This version returns the roll angle relative to the terrain normal at a point below the vehicle position; as such, this is a reasonable approximation of local vehicle roll only on relatively flat (but not necessarily horizontal) terrains. In the ISO frame convention, a positive roll angle corresponds to the vehicle left side lifting above the terrain plane.

◆ GetRollRate()

double chrono::vehicle::ChVehicle::GetRollRate ( ) const
inline

Get the vehicle roll rate.

The roll rate is referenced to the chassis frame.

◆ GetRot()

ChQuaternion chrono::vehicle::ChVehicle::GetRot ( ) const
inline

Get the vehicle orientation.

This is the main chassis orientation, returned as a quaternion representing a rotation with respect to the global reference frame.

◆ GetRTF()

double chrono::vehicle::ChVehicle::GetRTF ( ) const
inline

Get current estimated RTF (real time factor).

Note that the "true" RTF is returned, even if soft real-time is enforced. This represents the real time factor for advancing the dynamic state of the system only and as such does not take into account any other operations performed during a step (e.g., run-time visualization). During each call to Advance(), this value is calculated as T/step_size, where T includes the time spent in system setup, collision detection, and integration.

◆ GetSlipAngle()

double chrono::vehicle::ChVehicle::GetSlipAngle ( ) const

Get the vehicle slip angle.

This represents the angle betwwen the forward vehicle X axis and the vehicle velocity vector (calculated at the origin of the vehicle frame). The return value is in radians with a positive sign for a left turn and a negative sign for a right turn.

◆ GetSpeed()

double chrono::vehicle::ChVehicle::GetSpeed ( ) const
inline

Get the vehicle speed (velocity component in the vehicle forward direction).

Return the speed measured at the origin of the main chassis reference frame.

◆ GetStepRTF()

double chrono::vehicle::ChVehicle::GetStepRTF ( ) const
inline

Get current estimated step RTF (real time factor).

Unlike the value returned by GetRTF(), this represents the real time factor for all calculations performed during a simulation step, including any other operations in addition to advancing the dynamic state of the system (run-time visualization, I/O, etc.). This RTF value is calculated as T/step_size, where T represents the time from the previous call to Advance().

◆ GetTransform()

const ChFrame& chrono::vehicle::ChVehicle::GetTransform ( ) const
inline

Get the current vehicle transform relative to the global frame.

This is the same as the global transform of the main chassis.

◆ GetTurnRate()

double chrono::vehicle::ChVehicle::GetTurnRate ( ) const
inline

Get the vehicle turn rate.

Unlike the yaw rate (referenced to the chassis frame), the turn rate is referenced to the global frame.

◆ GetYawRate()

double chrono::vehicle::ChVehicle::GetYawRate ( ) const
inline

Get the vehicle yaw rate.

The yaw rate is referenced to the chassis frame.

◆ Initialize()

◆ InitializeInertiaProperties()

virtual void chrono::vehicle::ChVehicle::InitializeInertiaProperties ( )
pure virtual

Calculate total vehicle mass from subsystems.

This function is called at the end of the vehicle initialization, but can also be called explicitly.

Implemented in chrono::vehicle::ChWheeledVehicle, and chrono::vehicle::ChTrackedVehicle.

◆ InitializePowertrain()

void chrono::vehicle::ChVehicle::InitializePowertrain ( std::shared_ptr< ChPowertrainAssembly powertrain)

Initialize the given powertrain assembly and associate it to this vehicle.

The powertrain is initialized by connecting it to this vehicle's chassis and driveline shaft.

◆ SetChassisCollide()

void chrono::vehicle::ChVehicle::SetChassisCollide ( bool  state)

Enable/disable collision for the chassis subsystem.

This function controls contact of the chassis with all other collision shapes in the simulation.

◆ SetChassisVehicleCollide()

virtual void chrono::vehicle::ChVehicle::SetChassisVehicleCollide ( bool  state)
inlinevirtual

Enable/disable collision between the chassis and all other vehicle subsystems.

Note that some of these collisions may be always disabled, as set by the particular derived vehicle class.

Reimplemented in chrono::vehicle::ChWheeledVehicle, and chrono::vehicle::ChTrackedVehicle.

◆ SetCollisionSystemType()

void chrono::vehicle::ChVehicle::SetCollisionSystemType ( ChCollisionSystem::Type  collsys_type)

Change the default collision detection system.

Note that this function should be called before initialization of the vehicle system in order to create consistent collision models.

◆ SetOutput() [1/2]

void chrono::vehicle::ChVehicle::SetOutput ( ChVehicleOutput::Type  type,
const std::string &  out_dir,
const std::string &  out_name,
double  output_step 
)

Enable output for this vehicle system.

Parameters
[in]typetype of output DB
[in]out_diroutput directory name
[in]out_namerootname of output file
[in]output_stepinterval between output times

◆ SetOutput() [2/2]

void chrono::vehicle::ChVehicle::SetOutput ( ChVehicleOutput::Type  type,
std::ostream &  out_stream,
double  output_step 
)

Enable output for this vehicle system using an existing output stream.

Parameters
[in]typetype of output DB
[in]out_streamoutput stream
[in]output_stepinterval between output times

◆ UpdateInertiaProperties()

virtual void chrono::vehicle::ChVehicle::UpdateInertiaProperties ( )
protectedpure virtual

Calculate current vehicle inertia properties from subsystems.

This function is called at the end of each vehicle state advance.

Implemented in chrono::vehicle::ChWheeledVehicle, and chrono::vehicle::ChTrackedVehicle.


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