1 // =============================================================================
2 // PROJECT CHRONO - http://projectchrono.org
3 //
4 // Copyright (c) 2014 projectchrono.org
5 // All rights reserved.
6 //
7 // Use of this source code is governed by a BSD-style license that can be found
8 // in the LICENSE file at the top level of the distribution and at
9 // http://projectchrono.org/license-chrono.txt.
10 //
11 // =============================================================================
12 // Authors: Radu Serban
13 // =============================================================================
14 //
15 // Brake for wheeled vehicles modeled using a clutch between two shafts.
16 //
17 // =============================================================================
18 
19 #include "chrono_vehicle/wheeled_vehicle/brake/ChBrakeShafts.h"
20 
21 namespace chrono {
22 namespace vehicle {
23 
ChBrakeShafts(const std::string & name)24 ChBrakeShafts::ChBrakeShafts(const std::string& name) : ChBrake(name), m_modulation(0), m_locked(false) {}
25 
~ChBrakeShafts()26 ChBrakeShafts::~ChBrakeShafts() {
27     auto sys = m_shaft->GetSystem();
28     if (sys) {
29         sys->Remove(m_shaft);
30         sys->Remove(m_clutch);
31     }
32 }
33 
Initialize(std::shared_ptr<ChChassis> chassis,std::shared_ptr<ChSuspension> suspension,VehicleSide side)34 void ChBrakeShafts::Initialize(std::shared_ptr<ChChassis> chassis,
35                                std::shared_ptr<ChSuspension> suspension,
36                                VehicleSide side) {
37     // Create and initialize the brake shaft
38     m_shaft = chrono_types::make_shared<ChShaft>();
39     m_shaft->SetNameString(m_name + "_shaft");
40     m_shaft->SetInertia(GetShaftInertia());
41     chassis->GetBody()->GetSystem()->Add(m_shaft);
42 
43     // Create and initialize the connection between the brake shaft and a "fixed" body
44     auto body = suspension->GetBrakeBody(side);
45     if (!body)
46         body = chassis->GetBody();
47     auto connection = chrono_types::make_shared<ChShaftsBody>();
48     connection->Initialize(m_shaft, body, ChVector<>(0, 1, 0));
49     chassis->GetBody()->GetSystem()->Add(connection);
50 
51     // Create and initialize the brake clutch (set as unlocked)
52     m_clutch = chrono_types::make_shared<ChShaftsClutch>();
53     m_clutch->SetTorqueLimit(GetMaxBrakingTorque());
54     m_clutch->Initialize(m_shaft, suspension->GetAxle(side));
55     m_clutch->SetModulation(0);
56     chassis->GetBody()->GetSystem()->Add(m_clutch);
57 }
58 
Synchronize(double modulation)59 void ChBrakeShafts::Synchronize(double modulation) {
60     m_modulation = modulation;
61     m_clutch->SetModulation(modulation);
62     //// TODO: more here?
63 }
64 
65 }  // end namespace vehicle
66 }  // end namespace chrono
67