This package contains a library (eufs_models
). This library implements numerous vehicle models. The current implemented vehicle models can be found
within the src directory.
An outline of the library design can be found here. There are also wiki pages containing information on the physical models used in Point Mass and Dynamic Bicycle.
The models.txt file contains the name of every vehicle model implemented in this library. Each name should be on a new line. This file is used by the eufs_launcher to determine which vehicle models are available for use.
Everything in the eufs_models
package is contained within the eufs::models
namespace.
For example, to initialize a DynamicBicycle
object:
#include <string>
#include "eufs_models/dynamic_bicycle"
std::string yaml_file_path = "<path_to_yaml_config_file>";
eufs::models::DynamicBicycle dynamic_bicycle_model = eufs::models::DynamicBicycle(yaml_file_path);
The VehicleModel
class is a base class from which all implementations of vehicle models should inherit from.
For examples, please take a look at the currently implemented models in the src directory
(e.g DynamicBicycle
or PointMass
).
Inherited models must implement the updateState
virtual method. This method is reponsible for updating the provided
state (state
) based on the provided input (input
) and change in time (dt
). If using with
gazebo_ros_race_car_model,
this is the method that is used to update the state of the vehicle in the simulation.
The other important aspect of the base class is the _param
private attribute.
This stores the various vehicle parameters in the Param
struct defined in vehicle_param.hpp.
The struct is initialized by the Param
constructor via the VehicleModel
constructor.
Initialization requires a path to a yaml file. When implementing vehicle models make sure that
your constructor calls the VehicleModel
constructor with the path to the yaml file that
contains your vehicle model parameters.
A vehicle model object will allow public use of the following methods:
Name | input(s) | output | Purpose |
---|---|---|---|
getWheelSpeeds |
State, Input | eufs_msgs/WheelSpeeds | Calculates the wheel speeds (rpm) based on the vehicle velocity. |
getSlipAngle |
State, Input, bool (is front?) | double | Gets the slip angle (radians). |
validateInput |
Input | void | Ensures that the vehicle steering angle, velocity and acceleration values are never above their maximum or below their minimum. If they are, the values are clipped. |
validateState |
State | void | Ensures that the linear velocity is always greater than zero. If not, it is set to 0. |
updateState |
State, Input, double (timestep) | void | Updates then validates the current vehicle State based on the model dynamics and the (validated) command input. |
The noise.hpp header file defines a Noise
class. This class implements two main methods: applyNoise
and
applyNoiseToWheelSpeeds
. The first of these methods takes a State object and applies Gaussian noise to every
State attribute. The second takes a eufs_msgs/WheelSpeeds message and applies Gaussian noise to each individual wheel
speed. The exact Gaussian distribution depends on the configuration file provided to the Noise
object during
initialization.
To utilise the vehicle model library in your own packages, the CMakeLists.txt
file will need to be properly
configured. A proper configuration involves finding the eufs_models
package which contains the vehicle model library
and then linking the library to the executable:
# find eufs_models package
find_package(eufs_models REQUIRED)
# link vehicle model library to target executable
target_link_libraries(${PROJECT_NAME}
eufs_models::eufs_models
)
If the above doesn't work for you, the following alternative may:
find_package(eufs_models REQUIRED)
# Directories to look for *.h and *.hpp file in
include_directories(
include
${eufs_models_INCLUDE_DIRS}
)
# Target Libraries that do not support ament
target_link_libraries(${PROJECT_NAME}
${eufs_models_LIBRARIES}
)
See here for an example of setting up this library.