Skip to content

Commit

Permalink
Merge pull request #17 from uwsbel/cleanup
Browse files Browse the repository at this point in the history
Cleanup
  • Loading branch information
ishaanamahajan authored Mar 25, 2024
2 parents 3008393 + 4c26a7d commit 89f73ae
Show file tree
Hide file tree
Showing 33 changed files with 172 additions and 176 deletions.
4 changes: 2 additions & 2 deletions wheeled_vehicle_models/11dof-gpu/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,10 +32,10 @@ Once you launch the curses-based GUI for CMake, you will see an `Empty Cache`, h
- `CUDA_USE_STATIC_CUDA_RUNTIME` - Boolean for whether CUDA runtime is statically linked. Leave as is. Default: `ON`
- `CUDA_rt_LIBRARY` - Path to CUDA runtime library. Should be automatically filled in. Default: `path_to_runtime_library_on_your_machine`

Once the options are set, hit `c` to configure and `g` to generate. This will then populate your `build` directory with the necessary `makefile` with which you can build the 11dof-gpu model along with its demos by running
Once the options are set, hit `c` to configure and `g` to generate. This will then populate your `build` directory with the necessary `makefile` with which you can build the 11 DOF GPU model along with its demos by running
```bash
make -j4
```
We recommend to not run `make install` to ensure path consistencies for the demos (as they call upon certain data files relative to the build directory
We recommend to not run `make install` to ensure path consistencies for the demos (as they call upon certain data files relative to the build directory).


2 changes: 1 addition & 1 deletion wheeled_vehicle_models/11dof-gpu/demos/HMMWV/demo_hmmwv.cu
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ int main(int argc, char** argv) {
d11SolverHalfImplicitGPU solver(num_vehicles);
// The number of vehicles here sets these parameters and inputs for all these vehicles
// If there is a need to set different parameters for different vehicles, then the solver
// needs to be constructed for each vehicle separately (using the same sovler object)
// needs to be constructed for each vehicle separately (using the same solver object)
solver.Construct(vehParamsJSON, tireParamsJSON, num_vehicles, driver_file);

// Set the threads per block
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ int main(int argc, char** argv) {
d11SolverHalfImplicitGPU solver(num_vehicles);
// The number of vehicles here sets these parameters and inputs for all these vehicles
// If there is a need to set different parameters for different vehicles, then the solver
// needs to be constructed for each vehicle separately (using the same sovler object)
// needs to be constructed for each vehicle separately (using the same solver object)
// No driver file
solver.Construct(vehParamsJSON, tireParamsJSON, num_vehicles);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ int main(int argc, char** argv) {
cudaEventElapsedTime(&milliseconds, start, stop);
std::cout << "Solve time (ms): " << milliseconds << "\n";

// Extract terminal state of choosen vehicles and print the position
// Extract terminal state of chosen vehicles and print the position
SimState sim_state_1 = solver.GetSimState(499);
SimState sim_state_2 = solver.GetSimState(999);

Expand Down
16 changes: 8 additions & 8 deletions wheeled_vehicle_models/11dof-gpu/dof11_gpu.cu
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,7 @@ __device__ void d11GPU::tireToVehTransform(TMeasyNrState* tiref_st,
/// Tire Functions
////////////////////////////////////////////////////////////

// Code for the TM easy tire model implemented with the 8DOF model
// Code for the TM easy tire model implemented with the 11 DOF model
__device__ __host__ void d11GPU::tireInit(TMeasyParam* t_params) {
// calculates some critical values that are needed
t_params->_fzRdynco = (t_params->_pn * (t_params->_rdyncoP2n - 2.0 * t_params->_rdyncoPn + 1.)) /
Expand Down Expand Up @@ -446,7 +446,7 @@ __device__ void d11GPU::computeTireRHS(TMeasyState* t_states,

// Also compute the tire forces that need to be applied on the vehicle
// Note here that these tire forces are computed using the current pre
// integreated xe, unline in the semi-implicit solver
// integrated xe, unlike in the semi-implicit solver
double fxdyn = t_params->_dx * (-vtxs * t_params->_cx * t_states->_xe - fos * vsx) / (vtxs * t_params->_dx + fos) +
t_params->_cx * t_states->_xe;

Expand Down Expand Up @@ -550,7 +550,7 @@ __device__ void d11GPU::computeTireRHS(TMeasyNrState* t_states,
double sxs = InterpL(fz, t_params->_sxsPn, t_params->_sxsP2n, t_params->_pn);
double sys = InterpL(fz, t_params->_sysPn, t_params->_sysP2n, t_params->_pn);

// Compute the coefficient to "blend" the columb force with the slip force
// Compute the coefficient to "blend" the coulomb force with the slip force
double frblend = sineStep(abs(t_states->_vsx), t_params->_frblend_begin, 0., t_params->_frblend_end, 1.);
// Now standard TMeasy tire forces
// For now, not using any normalization of the slips - similar to Chrono implementation
Expand Down Expand Up @@ -585,7 +585,7 @@ __device__ void d11GPU::computeTireRHS(TMeasyNrState* t_states,
Fy = 0.;
}

// Now that we have both the columb force and the slip force, we can combine them with the sine blend to prevent
// Now that we have both the coulomb force and the slip force, we can combine them with the sine blend to prevent
// force jumping

Fx = (1.0 - frblend) * Fx0 + frblend * Fx;
Expand Down Expand Up @@ -701,7 +701,7 @@ __device__ void d11GPU::computePowertrainRHS(VehicleState* v_states,
v_states->_crankOmega =
0.5 * (tiref_st->_omega + tirer_st->_omega) / v_params->_gearRatios[v_states->_current_gr];

// The torque after tranny will then just become as there is no torque
// The torque after transmission will then just become as there is no torque
// converter
torque_t = driveTorque(v_params, controls->m_throttle, v_states->_crankOmega) /
v_params->_gearRatios[v_states->_current_gr];
Expand Down Expand Up @@ -847,7 +847,7 @@ __device__ void d11GPU::computePowertrainRHS(VehicleState* v_states,
v_states->_crankOmega =
0.5 * (tiref_st->_omega + tirer_st->_omega) / v_params->_gearRatios[v_states->_current_gr];

// The torque after tranny will then just become as there is no torque
// The torque after transmission will then just become as there is no torque
// converter
torque_t = driveTorque(v_params, controls->m_throttle, v_states->_crankOmega) /
v_params->_gearRatios[v_states->_current_gr];
Expand Down Expand Up @@ -1119,7 +1119,7 @@ __host__ void d11GPU::setTireParamsJSON(TMeasyNrParam& t_params, const char* fil
// level parameters
if (d.HasMember("highLevelParams")) {
if (d["highLevelParams"].GetBool()) {
// Set basic desing parameters
// Set basic design parameters
t_params._jw = d["jw"].GetDouble() * 2.;
t_params._rr = d["rr"].GetDouble() * 2.;
t_params._mu = d["mu"].GetDouble() * 2.;
Expand Down Expand Up @@ -1287,7 +1287,7 @@ __host__ void d11GPU::setTireParamsJSON(TMeasyNrParam& t_params, const char* fil
}

// Utility functions that guess the tire parameters for a TMeasy tire based on standard tire specifications that user
// can get from a spec sheet These functions are directly copy pasted from Chrono with minor modifications
// can get from a spec sheet. These functions are directly copy pasted from Chrono with minor modifications

// Function to compute the max tire load from the load index specified by the user
__host__ double d11GPU::GetTireMaxLoad(unsigned int li) {
Expand Down
24 changes: 12 additions & 12 deletions wheeled_vehicle_models/11dof-gpu/dof11_gpu.cuh
Original file line number Diff line number Diff line change
Expand Up @@ -129,8 +129,8 @@ struct TMeasyParam {
// Longitudinal
double _dfx0Pn; //!< Initial longitudinal slopes dFx/dsx [N] at Nominal load
double _dfx0P2n; //!< Intial longitudinal slopes dFx/dsx [N] at max load
double _fxmPn; //!< Maximum longituidnal force [N] at nominal load
double _fxmP2n; //!< Maximum longituidnal force [N] at max load
double _fxmPn; //!< Maximum longitudinal force [N] at nominal load
double _fxmP2n; //!< Maximum longitudinal force [N] at max load
double _fxsPn; //!< Longitudinal load at sliding [N] at nominal load
double _fxsP2n; //!< Longitudinal load at sliding [N] at max load
double _sxmPn; //!< Slip sx at maximum longitudinal load Fx at nominal load
Expand Down Expand Up @@ -366,8 +366,8 @@ struct TMeasyNrParam {
// Longitudinal
double _dfx0Pn; //!< Initial longitudinal slopes dFx/dsx [N] at Nominal load
double _dfx0P2n; //!< Intial longitudinal slopes dFx/dsx [N] at max load
double _fxmPn; //!< Maximum longituidnal force [N] at nominal load
double _fxmP2n; //!< Maximum longituidnal force [N] at max load
double _fxmPn; //!< Maximum longitudinal force [N] at nominal load
double _fxmP2n; //!< Maximum longitudinal force [N] at max load
double _fxsPn; //!< Longitudinal load at sliding [N] at nominal load
double _fxsP2n; //!< Longitudinal load at sliding [N] at max load
double _sxmPn; //!< Slip sx at maximum longitudinal load Fx at nominal load
Expand Down Expand Up @@ -489,9 +489,9 @@ struct TMeasyNrState {
// -----------------------------------------------------------------------------

/// @brief Defined here are chassis, engine/motor, powertrain, driveline and steering parameters required for the
/// simualtion of a 11 DOF model.
/// simulation of a 11 DOF model.

/// The single-track vehicle model, also known as the ’bicycle model’ and here the 11DOF model, is commonly used in
/// The single-track vehicle model, also known as the ’bicycle model’ and here the 11 DOF model, is commonly used in
/// controller design and serves as the entry point in our library of vehicle models. The Chassis includes 3 DOF at the
/// vehicle lumped C.M, representing the vehicle’s yaw, lateral, and longitudinal motions. This model assumes the same
/// engine, torque converter, and powertrain as the 18 DOF and 24 DOF models. However, as it is a single-track model, it
Expand Down Expand Up @@ -677,11 +677,11 @@ struct VehicleParam {
};

/// @brief The VehicleState struct holds the chassis, engine/motor, powertrain, driveline and steering states required
/// for the simualtion.
/// for the simulation.

/// Apart from the states that are updated by time integration, this struct also holds "non-states"
/// such as accelerations, forces and torques that are not updated by time integration. See here for more details
/// https://uwmadison.box.com/s/2tsvr4adbrzklle30z0twpu2nlzvlayc. important to note that this implementation within the
/// https://uwmadison.box.com/s/2tsvr4adbrzklle30z0twpu2nlzvlayc. Important to note that this implementation within the
/// d11GPU namespace is exactly the same as the implementation in the d11 namespace. The only difference is that the
/// d11GPU namespace is meant to be used on the GPU where standard library functions are not available.
struct VehicleState {
Expand Down Expand Up @@ -765,14 +765,14 @@ struct VehicleState {
};

// -----------------------------------------------------------------------------
// Data structures that help handing multiple vehicles as needed in GPU version
// Data structures that help handling multiple vehicles as needed in GPU version
// -----------------------------------------------------------------------------
/// @brief The SimData struct holds the parameters of the vehicle and tire needed in kernel along with the
/// @brief The SimData struct holds the parameters of the vehicle and tire needed in kernel along with the
/// driver inputs (steering, throttle, brake) in case specified at the beginning of the simulation.

/// In essence, this
/// stores all the "data" required to simulate 1 vehicle on the GPU. This is something largely the user does not have to
/// worrry about.
/// worry about.
struct SimData {
SimData() : _driver_data(nullptr), _driver_data_len(0) {}

Expand Down Expand Up @@ -913,7 +913,7 @@ __device__ void tireToVehTransform(TMeasyNrState* tiref_st,
/// input parameters
__device__ void tmxy_combined(double* f, double* fos, double s, double df0, double sm, double fm, double ss, double fs);

/// @brief Computes the combined columnb force for the TMeasyNr tire model
/// @brief Computes the combined coulomb force for the TMeasyNr tire model

/// This force provides the stability at low speeds and is belnded with the slip force provided by the tmxy_combined
/// function.
Expand Down
10 changes: 5 additions & 5 deletions wheeled_vehicle_models/11dof-gpu/dof11_halfImplicit_gpu.cu
Original file line number Diff line number Diff line change
Expand Up @@ -291,7 +291,7 @@ void d11SolverHalfImplicitGPU::Initialize(d11GPU::VehicleState& vehicle_states,
d11GPU::TMeasyState& tire_states_F,
d11GPU::TMeasyState& tire_states_R,
unsigned int num_vehicles) {
// Esnure that construct was called with TMeasy tire type
// Ensure that construct was called with TMeasy tire type
assert((m_tire_type == TireType::TMeasy) &&
"Construct function called with TMeasyNr tire type, but Initialize called with TMeasy tire type");
assert((num_vehicles + m_vehicle_count_tracker_states <= m_total_num_vehicles) &&
Expand All @@ -312,7 +312,7 @@ void d11SolverHalfImplicitGPU::Initialize(d11GPU::VehicleState& vehicle_states,
d11GPU::TMeasyNrState& tire_states_F,
d11GPU::TMeasyNrState& tire_states_R,
unsigned int num_vehicles) {
// Esnure that construct was called with TMeasyNr tire type
// Ensure that construct was called with TMeasyNr tire type
assert((m_tire_type == TireType::TMeasyNr) &&
"Construct function called with TMeasy tire type, but Initialize called with TMeasyNR tire type");
assert((num_vehicles + m_vehicle_count_tracker_states <= m_total_num_vehicles) &&
Expand All @@ -338,7 +338,7 @@ __host__ void d11SolverHalfImplicitGPU::SetOutput(const std::string& output_file
m_store_all = store_all;
if (!m_store_all) {
// Check if number of outputs asked is greater than the total number of vehicles, if this is the case, raise
// awarning and set to m_total_num_vehicles
// a warning and set to m_total_num_vehicles
if (no_outs > m_total_num_vehicles) {
std::cout << "Number of outputs asked is greater than the total number of vehicles, setting number of "
"outputs to total number of vehicles"
Expand Down Expand Up @@ -456,7 +456,7 @@ __host__ void d11SolverHalfImplicitGPU::Solve() {

// If we have to save output, copy over the device into the response
if (m_output) {
// Amount of respoonse already filled
// Amount of response already filled
unsigned int filled_response = m_total_num_vehicles * m_collection_states * m_device_collection_timeSteps *
kernel_launches_since_last_dump;

Expand Down Expand Up @@ -625,7 +625,7 @@ __host__ void d11SolverHalfImplicitGPU::WriteToFile() {
}
for (unsigned int sim_no = 0; sim_no < loop_limit; sim_no++) {
unsigned int index_by = 0;
// If we are no storing all, we will have to index by random numbers
// If we are not storing all, we will have to index by random numbers
if (m_store_all) {
index_by = sim_no;
} else {
Expand Down
16 changes: 8 additions & 8 deletions wheeled_vehicle_models/11dof-gpu/dof11_halfImplicit_gpu.cuh
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ class d11SolverHalfImplicitGPU {
/// Each of these vehicles will have the specified parameters and driver inputs. To add
/// more vehicles (ensuring they are still lesser than the total number of vehicles initally specified in the class
/// constructor) with different parameters, call the Construct function again. The tire type defaults to TMEasy and
/// is set for all the vehilces. It is also important to note thet the TireType has to be consistent across all the
/// is set for all the vehilces. It is also important to note that the TireType has to be consistent across all the
/// vehicles currently. For examples of use, see demos.
/// @param vehicle_params_file Path to the vehicle parameter json file
/// @param tire_params_file Path to the tire parameter json file
Expand All @@ -42,7 +42,7 @@ class d11SolverHalfImplicitGPU {

/// Each of these vehicles will have the
/// specified parameters and driver inputs. To add more vehicles with different parameters, call the Construct
/// function again. It is also important to note thet the TireType has to be consistent across all the
/// function again. It is also important to note that the TireType has to be consistent across all the
/// vehicles currently. For examples of use, see demos.
/// @param vehicle_params_file Path to the vehicle parameter json file
/// @param tire_params_file Path to the tire parameter json file
Expand All @@ -60,8 +60,8 @@ class d11SolverHalfImplicitGPU {

/// Each of these vehicles will have the specified parameters. This function signature
/// is mainly provided for cases where the driver inputs are not available at the start of the simulation but rather
/// come from a controller during the simualtion. TireType defualts to TMEasy tires. To add more vehicles with
/// different parameters, call the Construct function again. It is also important to note thet the TireType has to
/// come from a controller during the simulation. TireType defaults to TMEasy tires. To add more vehicles with
/// different parameters, call the Construct function again. It is also important to note that the TireType has to
/// be consistent across all the vehicles currently. For examples of use, see demos.
/// @param vehicle_params_file Path to the vehicle parameter json file
/// @param tire_params_file Path to the tire parameter json file
Expand All @@ -75,9 +75,9 @@ class d11SolverHalfImplicitGPU {

/// Each of these vehicles will have the specified
/// parameters. This is mainly provided for cases where the driver inputs are not available at the start of the
/// simulation but rather come from a controller during the simualtion and the user wants to specify a TireType. To
/// simulation but rather come from a controller during the simulation and the user wants to specify a TireType. To
/// add more vehicles with different parameters, call the Construct function again. It is also important to note
/// thet the TireType has to be consistent across all the vehicles currently. For examples of use, see demos.
/// that the TireType has to be consistent across all the vehicles currently. For examples of use, see demos.
/// @param vehicle_params_file Path to the vehicle parameter json file
/// @param tire_params_file Path to the tire parameter json file
/// @param num_vehicles Number of vehicles to be simulated with the specified parameters and driver inputs
Expand Down Expand Up @@ -330,7 +330,7 @@ class d11SolverHalfImplicitGPU {
// Need a bunch of csv writers for each of the vehicles. We will store a pointer to this list
std::unique_ptr<CSV_writer[]> m_csv_writers_ptr;
};
// Cannout have global function as class member function
// Cannot have global function as class member function
/// @brief Integrate the system of equations using the half implicit method - Calls the RHS function at each time step

/// Used internally within Solve
Expand Down Expand Up @@ -393,7 +393,7 @@ __global__ void Integrate(double current_time,
d11GPU::SimData* sim_data,
d11GPU::SimState* sim_states);
//===================================================================================================================
// Integrate calss rhsFun so this also cannot be a class member function
// Integrate calls rhsFun so this also cannot be a class member function

/// @brief Computes the RHS of all the ODEs (tire velocities, chassis accelerations) using the computeRHS functions
/// within the vehicle model
Expand Down
Loading

0 comments on commit 89f73ae

Please sign in to comment.