Skip to content

Chrono Core Components

bloc0105 edited this page Oct 3, 2024 · 3 revisions

Core Components

This page focuses on all of the core components of Project Chrono, all of which are located in src/chrono/core.

Classes

ChFrame

What it is The ChFrame represents anything that has a position and a rotation. Many objects derive from the ChFrame, as most objects will have these properties. It's important to know that a frame doesn't have any physical existence, it's just a position and direction. Therefore, physics doesn't have a direct effect on it because it isn't a ChPhysicsItem. This means that it can't be added to a physics system such as a ChSystemNSC.

How Do I use it

The ChFrame is located in the core library:

#include "chrono/core/ChFrame.h"

A ChFrame can be instantiated using a default constructor. When the default constructor is used, the ChFrame is located at the origin with no rotation.

chrono::ChFrame the_frame;

Other constructors allow you to set initial positions and directions for the ChFrame.

You can set a frame with an initial position and direction.

chrono::ChFrame frame_object(chrono::ChVector3d(1,2,3),chrono::ChQuaterniond(1,0,0,0));

You can also use a rotation matrix to define the direction instead of a quaternion.

chrono::ChMatrix33d matrix_object({{1,4,5},{23.7,90,43},{82.1,18,544}});
chrono::ChFrame frame_object(chrono::ChVector3d(3,4,5), matrix_object);

It is also possible to make a frame out of a set of predefined coordinates.

chrono::ChCoordsysd coords(chrono::ChVector3d(1,2,3),chrono::ChQuaterniond(1,0,0,0));
chrono::ChFrame frame_object(coords);

A ChFrame can be printed directly to an output stream:

std::cout << the_frame << std::endl;

This will display the position in $(x,y,z)$ coordinates and the rotation as a quaternion in $(w,x,y,z)$ coordinates.

someone@computer:/location#
0  0  0
1  0  0  0

ChFrameMoving

What it is

The ChFrameMoving represents an object with position and direction and additionally with motion, in the form of a velocity and acceleration. The motion is represented by two coordinate systems (ChCoordsys objects) representing the velocity and acceleration, respectively. Because they are defined as coordinate systems, they posess both a linear and rotational component.

How Do I use it

The ChFrameMoving is located in the core library:

#include "chrono/core/ChFrameMoving.h"

A ChFrameMoving can be instantiated using a default constructor. When the default constructor is used, the ChFrameMoving is located at the origin with no rotation. The default velocity and acceleration of a ChFrameMoving are always zero.

chrono::ChFrameMoving the_frame;

Other constructors allow you to set initial positions and directions for the ChFrameMoving.

You can set a frame with an initial position and direction.

chrono::ChFrameMoving frame_object(chrono::ChVector3d(1,2,3),chrono::ChQuaterniond(1,0,0,0));

You can also use a rotation matrix to define the direction instead of a quaternion.

chrono::ChMatrix33d matrix_object({{1,4,5},{23.7,90,43},{82.1,18,544}});
chrono::ChFrameMoving frame_object(chrono::ChVector3d(3,4,5), matrix_object);

It is also possible to make a frame out of a set of predefined coordinates.

chrono::ChCoordsysd coords(chrono::ChVector3d(1,2,3),chrono::ChQuaterniond(1,0,0,0));
chrono::ChFrameMoving frame_object(coords);

A ChFrameMoving can be printed directly to an output stream:

std::cout << frame_object << std::endl;

This will display the position in $(x,y,z)$ coordinates and the rotation as a quaternion in $(w,x,y,z)$ coordinates. The velocity and acceleration are not displayed.

someone@computer:/location#
1  2  3
1  0  0  0
Clone this wiki locally