From 4c26a7d9f646c63c4ad9261d8db829d36fb32821 Mon Sep 17 00:00:00 2001 From: Ishaan Mahajan Date: Sun, 24 Mar 2024 17:50:57 -0500 Subject: [PATCH] 24 DOF GPU done --- wheeled_vehicle_models/24dof-gpu/dof24_gpu.cu | 23 +++++++++---------- .../24dof-gpu/dof24_gpu.cuh | 22 +++++++++--------- .../24dof-gpu/dof24_halfImplicit_gpu.cu | 8 +++---- .../24dof-gpu/dof24_halfImplicit_gpu.cuh | 6 ++--- 4 files changed, 29 insertions(+), 30 deletions(-) diff --git a/wheeled_vehicle_models/24dof-gpu/dof24_gpu.cu b/wheeled_vehicle_models/24dof-gpu/dof24_gpu.cu index 358edad..c7f964b 100644 --- a/wheeled_vehicle_models/24dof-gpu/dof24_gpu.cu +++ b/wheeled_vehicle_models/24dof-gpu/dof24_gpu.cu @@ -264,7 +264,7 @@ __device__ void d24GPU::vehToSusTransform(const VehicleState* v_states, susrr_st->_vs = -v_params->_b * v_states->_wz + v_states->_v; // y direction susrr_st->_ws = (-v_params->_cr * v_states->_wx / 2.) + v_params->_b * v_states->_wy + v_states->_w; // z direction - // Evalute the length of the struct and its compression velocity in current time step + // Evaluate the length of the struct and its compression velocity in current time step // This is to get the unsprung mass velocity and accelerations in G-RF // Instantaneous length of the strut @@ -942,7 +942,7 @@ __device__ void d24GPU::computeTireRHS(const VehicleState* v_states, double fs = hypot(fxs * calpha, fys * salpha); double ss = hypot(sxs * calpha / hsxn, sys * salpha / hsyn); - // calculate force and force /slip from the curve characteritics + // calculate force and force /slip from the curve characteristics double f, fos; tmxy_combined(&f, &fos, sc, df0, sm, fm, ss, fs); @@ -953,7 +953,7 @@ __device__ void d24GPU::computeTireRHS(const VehicleState* v_states, t_states->_My = -sineStep(vta, vx_min, 0., vx_max, 1.) * t_params->_rr * fz * t_states->_rStat * sgn(t_states->_omega); - // some normalised slip velocities + // some normalized slip velocities double vtxs = r_eff * abs(t_states->_omega) * hsxn + 0.01; double vtys = r_eff * abs(t_states->_omega) * hsyn + 0.01; @@ -966,7 +966,7 @@ __device__ void d24GPU::computeTireRHS(const VehicleState* v_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, unline 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; @@ -1071,7 +1071,7 @@ __device__ void d24GPU::computeTireRHS(const VehicleState* v_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 @@ -1106,7 +1106,7 @@ __device__ void d24GPU::computeTireRHS(const VehicleState* v_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; @@ -1288,7 +1288,7 @@ __device__ double d24GPU::driveTorque(const VehicleParam* v_params, const double powertrain_map[i]._y = v_params->_powertrainMap[i]._y * throttle; } - // interpolate in the torque map to get the torque at this paticular + // interpolate in the torque map to get the torque at this particular // speed motor_torque = getMapY(powertrain_map, motor_speed, v_params->_powertrainMapSize); double motor_losses = getMapY(v_params->_lossesMap, motor_speed, v_params->_lossesMapSize); @@ -1438,7 +1438,7 @@ __device__ void d24GPU::computePowertrainRHS(VehicleState* v_states, v_states->_crankOmega = 0.25 * (tirelf_st->_omega + tirerf_st->_omega + tirelr_st->_omega + tirerr_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]; @@ -1614,7 +1614,7 @@ __device__ void d24GPU::computePowertrainRHS(VehicleState* v_states, v_states->_crankOmega = 0.25 * (tirelf_st->_omega + tirerf_st->_omega + tirelr_st->_omega + tirerr_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]; @@ -1804,8 +1804,7 @@ __host__ void d24GPU::setTireParamsJSON(TMeasyParam& t_params, const char* fileN std::cout << "Error with rapidjson:" << std::endl << d.GetParseError() << std::endl; } - // pray to what ever you believe in and hope that the json file has all - // these + t_params._jw = d["jw"].GetDouble(); t_params._rr = d["rr"].GetDouble(); t_params._r0 = d["r0"].GetDouble(); @@ -2203,7 +2202,7 @@ __host__ void d24GPU::setSuspensionParamsJSON(SuspensionParam& sus_params, const std::cout << "Error with rapidjson:" << std::endl << d.GetParseError() << std::endl; } - // pray to what ever you believe in and hope that the json file has all these + sus_params._ks = d["ks"].GetDouble(); sus_params._bs = d["bs"].GetDouble(); } diff --git a/wheeled_vehicle_models/24dof-gpu/dof24_gpu.cuh b/wheeled_vehicle_models/24dof-gpu/dof24_gpu.cuh index 7c16224..3e8911f 100644 --- a/wheeled_vehicle_models/24dof-gpu/dof24_gpu.cuh +++ b/wheeled_vehicle_models/24dof-gpu/dof24_gpu.cuh @@ -131,8 +131,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 @@ -416,8 +416,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 @@ -581,7 +581,7 @@ struct TMeasyNrState { // Vehicle Structs // ----------------------------------------------------------------------------- /// @brief Defined here are chassis, engine/motor, powertrain, driveline and steering parameters required for the -/// simualtion of a 24 DOF model. +/// simulation of a 24 DOF model. /// The 24 DOF model, which considers the suspension at each corner, offers the same /// benefits as the 18 DOF model, but it can also predict vehicle heave and pitch motions. @@ -655,7 +655,7 @@ struct VehicleParam { _TRmapSize(other->_TRmapSize), _shiftMap(other->_shiftMap) {} - // Declaration of all the 14 DOF vehicle parameters pretty much the same as the 8DOF model + // Declaration of all the 24 DOF vehicle parameters pretty much the same as the 18 DOF model double _a; //!< Distance of C.G to front axle (m) double _b; //!< Distance of C.G to rear axle (m) double _h; //!< Height of C.G @@ -713,7 +713,7 @@ struct VehicleParam { bool _tcbool; //!< Boolean that checks for the presence of a torque converter. Can be set using "tcBool" in the //!< JSON file. Defaults to 0 if not specified. - double _maxBrakeTorque; //!< The maximum braking torque (Nm) that the brakes applu to the wheels. Can be set using + double _maxBrakeTorque; //!< The maximum braking torque (Nm) that the brakes apply to the wheels. Can be set using //!< "maxBrakeTorque" in the JSON file. Based on the normalized brake input between 0 and //!< 1, a torque input*_maxBrakeTorque is applied to the wheel. @@ -788,7 +788,7 @@ 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 @@ -1110,7 +1110,7 @@ struct SuspensionState { /// 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) {} @@ -1473,7 +1473,7 @@ __device__ void computeForcesThroughSus(const VehicleState* v_states, /// 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. @@ -1497,7 +1497,7 @@ __device__ void computeTireRHS(const VehicleState* v_states, /// @brief Computes the tire forces for the TMeasyNr tire model in the tire contact patch frame (T-RF) /// For the TMeasyNr tire model, since there is no relaxation, the tire forces from slip are blended with the tire -/// forces from columb friction. The blend coefficient depends on the longitudinal slip velocity of the tire. This model +/// forces from coulomb friction. The blend coefficient depends on the longitudinal slip velocity of the tire. This model /// is an approximation of the original TMeasy tire model and is inspired by the Project Chrono implementation (see code /// at https://github.com/projectchrono/chrono/blob/main/src/chrono_vehicle/wheeled_vehicle/tire/ChTMeasyTire.h). /// @param v_states Vehicle States diff --git a/wheeled_vehicle_models/24dof-gpu/dof24_halfImplicit_gpu.cu b/wheeled_vehicle_models/24dof-gpu/dof24_halfImplicit_gpu.cu index 9c19968..c5c6d9b 100644 --- a/wheeled_vehicle_models/24dof-gpu/dof24_halfImplicit_gpu.cu +++ b/wheeled_vehicle_models/24dof-gpu/dof24_halfImplicit_gpu.cu @@ -318,7 +318,7 @@ __host__ void d24SolverHalfImplicitGPU::Initialize(d24GPU::VehicleState& vehicle d24GPU::SuspensionState& sus_states_LR, d24GPU::SuspensionState& sus_states_RR, 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) && @@ -354,7 +354,7 @@ __host__ void d24SolverHalfImplicitGPU::Initialize(d24GPU::VehicleState& vehicle d24GPU::SuspensionState& sus_states_LR, d24GPU::SuspensionState& sus_states_RR, 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) && @@ -390,7 +390,7 @@ __host__ void d24SolverHalfImplicitGPU::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" @@ -506,7 +506,7 @@ __host__ void d24SolverHalfImplicitGPU::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; diff --git a/wheeled_vehicle_models/24dof-gpu/dof24_halfImplicit_gpu.cuh b/wheeled_vehicle_models/24dof-gpu/dof24_halfImplicit_gpu.cuh index 8e6af09..3d2213e 100644 --- a/wheeled_vehicle_models/24dof-gpu/dof24_halfImplicit_gpu.cuh +++ b/wheeled_vehicle_models/24dof-gpu/dof24_halfImplicit_gpu.cuh @@ -25,7 +25,7 @@ class d24SolverHalfImplicitGPU { /// 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 vehicles. It is also important to note thet 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 @@ -82,7 +82,7 @@ class d24SolverHalfImplicitGPU { /// 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 /// 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 sus_params_file Path to the suspension parameter json file @@ -365,7 +365,7 @@ class d24SolverHalfImplicitGPU { // Need a bunch of csv writers for each of the vehicles. We will store a pointer to this list std::unique_ptr 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