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 chassis subsystem.
 
std::shared_ptr< ChBodyAuxRefGetChassisBody () const
 Get a handle to the vehicle's chassis body.
 
virtual double GetVehicleMass () const =0
 Get the vehicle total mass. More...
 
virtual ChVector GetVehicleCOMPos () const =0
 Get the current global vehicle COM location.
 
const ChVectorGetVehiclePos () const
 Get the vehicle location. More...
 
const ChQuaternionGetVehicleRot () const
 Get the vehicle orientation. More...
 
double GetVehicleSpeed () const
 Get the vehicle speed. More...
 
double GetVehicleSpeedCOM () const
 Get the speed of the chassis COM. More...
 
ChVector GetVehiclePointLocation (const ChVector<> &locpos) const
 Get the global position of the specified point. More...
 
ChVector GetVehiclePointVelocity (const ChVector<> &locpos) const
 Get the global velocity of the specified point. More...
 
ChVector GetVehicleAcceleration (const ChVector<> &locpos) const
 Get the acceleration at the specified point. More...
 
virtual std::shared_ptr< ChShaftGetDriveshaft () const =0
 Get a handle to the vehicle's driveshaft body.
 
virtual double GetDriveshaftSpeed () const =0
 Get the angular speed of the driveshaft. More...
 
ChVector GetDriverPos () const
 Get the global location of the driver.
 
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...
 
virtual void Initialize (const ChCoordsys<> &chassisPos, double chassisFwdVel=0)=0
 Initialize this vehicle at the specified global location and orientation. More...
 
void SetChassisVisualizationType (VisualizationType vis)
 Set visualization mode for the chassis subsystem.
 
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.
 
virtual void Advance (double step)
 Advance the state of this vehicle by the specified time step. More...
 
void SetStepsize (double val)
 Set the integration step size for the vehicle system.
 
double GetStepsize () const
 Get the current value of the integration step size for the vehicle system.
 
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, ChMaterialSurface::ContactMethod contact_method=ChMaterialSurface::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...
 

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
 
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 chassis subsystem
 
double m_stepsize
 integration step-size for the vehicle system
 

Constructor & Destructor Documentation

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

Construct a vehicle system with an underlying ChSystem.

Parameters
[in]namevehicle name
[in]contact_methodcontact method
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

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

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

This 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::ChTrackedVehicle, and chrono::vehicle::ChSuspensionTestRig.

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, chrono::vehicle::ChTrackedVehicle, chrono::vehicle::ChSuspensionTestRig, and chrono::vehicle::ChTrackTestRig.

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, chrono::vehicle::ChTrackedVehicle, chrono::vehicle::ChSuspensionTestRig, and chrono::vehicle::ChTrackTestRig.

virtual double chrono::vehicle::ChVehicle::GetDriveshaftSpeed ( ) const
pure virtual

Get the angular speed of the driveshaft.

This function provides the interface between a vehicle system and a powertrain system.

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

ChVector chrono::vehicle::ChVehicle::GetVehicleAcceleration ( const ChVector<> &  locpos) const

Get the acceleration at the specified point.

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

virtual double chrono::vehicle::ChVehicle::GetVehicleMass ( ) const
pure virtual

Get the vehicle total mass.

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

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

ChVector chrono::vehicle::ChVehicle::GetVehiclePointLocation ( const ChVector<> &  locpos) const

Get the global position of the specified point.

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

ChVector chrono::vehicle::ChVehicle::GetVehiclePointVelocity ( const ChVector<> &  locpos) const

Get the global velocity of the specified point.

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

const ChVector& chrono::vehicle::ChVehicle::GetVehiclePos ( ) const

Get the vehicle location.

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

const ChQuaternion& chrono::vehicle::ChVehicle::GetVehicleRot ( ) const

Get the vehicle orientation.

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

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

Get the vehicle speed.

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

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

Get the speed of the chassis COM.

Return the speed measured at the chassis center of mass.

virtual void chrono::vehicle::ChVehicle::Initialize ( const ChCoordsys<> &  chassisPos,
double  chassisFwdVel = 0 
)
pure virtual
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.

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

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.

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 ooutput DB
[in]out_diroutput directory name
[in]out_namerootname of output file
[in]output_stepinterval between output times