Skip to content

Commit d1db0a7

Browse files
author
Markus Friedrich
committed
Merge branch 'master' of github.com:mbsim-env/mbsim
2 parents 1fb9504 + 790fe00 commit d1db0a7

25 files changed

+274
-189
lines changed

kernel/mbsim/constitutive_laws/Makefile.am

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ libconstitutivelaws_la_SOURCES = bilateral_constraint.cc\
2020
spatial_stribeck_impact.cc\
2121
unilateral_constraint.cc\
2222
unilateral_newton_impact.cc\
23+
tyre_model.cc\
2324
linear_tyre_model.cc\
2425
magic_formula_sharp.cc\
2526
magic_formula_62.cc

kernel/mbsim/constitutive_laws/linear_tyre_model.cc

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -83,20 +83,16 @@ namespace MBSim {
8383
}
8484

8585
VecV LinearTyreModel::getContourParameters() const {
86-
TyreContact *contact = static_cast<TyreContact*>(parent);
87-
Tyre *tyre = static_cast<Tyre*>(contact->getContour(1));
88-
return tyre->getContourParameters();
86+
return static_cast<Tyre*>(getTyreContact()->getContour(1))->getContourParameters();
8987
}
9088

9189
double LinearTyreModel::evalFreeRadius() {
92-
TyreContact *contact = static_cast<TyreContact*>(parent);
93-
Tyre *tyre = static_cast<Tyre*>(contact->getContour(1));
94-
return tyre->getRadius();
90+
return static_cast<Tyre*>(getTyreContact()->getContour(1))->getRadius();
9591
}
9692

9793
void LinearTyreModel::updateGeneralizedForces() {
98-
TyreContact *contact = static_cast<TyreContact*>(parent);
99-
Tyre *tyre = static_cast<Tyre*>(contact->getContour(1));
94+
auto *contact = getTyreContact();
95+
auto *tyre = contact->getRigidContour(1);
10096
double Fx, Fy, Fz, Mz;
10197
if(contact->evalGeneralizedRelativePosition()(0)>0)
10298
Fz = 0;
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
/* Copyright (C) 2004-2022 MBSim Development Team
2+
*
3+
* This library is free software; you can redistribute it and/or
4+
* modify it under the terms of the GNU Lesser General Public
5+
* License as published by the Free Software Foundation; either
6+
* version 2.1 of the License, or (at your option) any later version.
7+
*
8+
* This library is distributed in the hope that it will be useful,
9+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
10+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
11+
* Lesser General Public License for more details.
12+
*
13+
* You should have received a copy of the GNU Lesser General Public
14+
* License along with this library; if not, write to the Free Software
15+
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
16+
*
17+
* Contact: martin.o.foerg@googlemail.com
18+
*/
19+
20+
#include <config.h>
21+
#include "tyre_model.h"
22+
#include "mbsim/links/tyre_contact.h"
23+
24+
namespace MBSim {
25+
26+
TyreContact* TyreModel::getTyreContact() const {
27+
return static_cast<TyreContact*>(parent);
28+
}
29+
30+
}

kernel/mbsim/constitutive_laws/tyre_model.h

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,8 @@
2424

2525
namespace MBSim {
2626

27+
class TyreContact;
28+
2729
class TyreModel : public Element {
2830
public:
2931
TyreModel() : Element(uniqueDummyName(this)) {
@@ -33,7 +35,9 @@ namespace MBSim {
3335

3436
virtual void initPlot(std::vector<std::string> &plotColumns) { }
3537
virtual void plot(std::vector<double> &plotVector) { }
38+
#ifndef SWIG
3639
using Element::plot;
40+
#endif
3741

3842
virtual int getxSize() const { return 0; }
3943
virtual int getDMSize() const { return 1; }
@@ -44,10 +48,13 @@ namespace MBSim {
4448
int getDataSize() const { return 17; }
4549
virtual fmatvec::VecV getData() const = 0;
4650

47-
virtual bool motorcycleKinematics() const = 0;
51+
virtual bool motorcycleKinematics() const { return false; }
4852

4953
virtual fmatvec::VecV getContourParameters() const = 0;
5054
virtual double evalFreeRadius() = 0;
55+
56+
protected:
57+
TyreContact* getTyreContact() const;
5158
};
5259

5360
}

kernel/mbsim/contours/circle.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,13 +65,14 @@ namespace MBSim {
6565
fmatvec::Vec3 evalParDer2Wu(const fmatvec::Vec2 &zeta) override { return zero3; }
6666

6767
fmatvec::Vec2 evalZeta(const fmatvec::Vec3& WrPoint) override;
68+
69+
fmatvec::Vec2 evalCurvatures(const fmatvec::Vec2 &zeta) override { return fmatvec::Vec2({sign/r,0}); }
6870
/***************************************************/
6971

7072
/* GETTER / SETTER */
7173
void setRadius(double r_) { r = r_; }
7274
double getRadius() const { return r; }
7375
double getSign() const { return sign; }
74-
double getCurvature(const fmatvec::Vec2 &zeta) { return sign/r; }
7576

7677
void setSolid(bool solid_=true) { solid = solid_; }
7778
bool getSolid() const { return solid; }

kernel/mbsim/contours/contour.cc

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -149,6 +149,10 @@ namespace MBSim {
149149
throwError("(Contour::evalZeta): Not implemented.");
150150
}
151151

152+
Vec2 Contour::evalCurvatures(const Vec2 &zeta) {
153+
throwError("(Contour::evalCurvatures): Not implemented.");
154+
}
155+
152156
void Contour::initializeUsingXML(DOMElement *element) {
153157
Element::initializeUsingXML(element);
154158
DOMElement *e=E(element)->getFirstElementChildNamed(MBSIM%"thickness");

kernel/mbsim/contours/contour.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -176,6 +176,8 @@ namespace MBSim {
176176

177177
virtual fmatvec::Vec2 evalZeta(const fmatvec::Vec3 &WrPS);
178178

179+
virtual fmatvec::Vec2 evalCurvatures(const fmatvec::Vec2 &zeta);
180+
179181
void initializeUsingXML(xercesc::DOMElement *element) override;
180182

181183
void setThickness(double thickness_) { thickness = thickness_; }

kernel/mbsim/contours/line.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ namespace MBSim {
6262
fmatvec::Vec3 evalParDer1Wn(const fmatvec::Vec2 &zeta) override { return zero3; }
6363
/***************************************************/
6464

65-
virtual double getCurvature(const fmatvec::Vec2 &zeta) { return 0; }
65+
fmatvec::Vec2 evalCurvatures(const fmatvec::Vec2 &zeta) override { return fmatvec::Vec2(); }
6666

6767
BOOST_PARAMETER_MEMBER_FUNCTION( (void), enableOpenMBV, tag, (optional (length,(double),1)(diffuseColor,(const fmatvec::Vec3&),fmatvec::Vec3(std::vector<double>{-1,1,1}))(transparency,(double),0)(pointSize,(double),0)(lineWidth,(double),0))) {
6868
OpenMBVLine ombv(length,diffuseColor,transparency,pointSize,lineWidth);

kernel/mbsim/contours/line_segment.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ namespace MBSim {
7171
fmatvec::Vec3 evalParDer1Wn(const fmatvec::Vec2 &zeta) override { return zero3; }
7272
/***************************************************/
7373

74-
virtual double getCurvature(const fmatvec::Vec2 &zeta) { return 0; }
74+
fmatvec::Vec2 evalCurvatures(const fmatvec::Vec2 &zeta) override { return fmatvec::Vec2(); }
7575

7676
BOOST_PARAMETER_MEMBER_FUNCTION( (void), enableOpenMBV, tag, (optional (diffuseColor,(const fmatvec::Vec3&),fmatvec::Vec3(std::vector<double>{-1,1,1}))(transparency,(double),0)(pointSize,(double),0)(lineWidth,(double),0))) {
7777
OpenMBVLine ombv(1,diffuseColor,transparency,pointSize,lineWidth);

kernel/mbsim/contours/planar_contour.cc

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -107,10 +107,14 @@ namespace MBSim {
107107
funcCrPC->setName("Contour");
108108
}
109109

110-
double PlanarContour::getCurvature(const Vec2 &zeta) {
111-
const Vec3 rs = funcCrPC->parDer(zeta(0));
112-
return nrm2(crossProduct(rs,funcCrPC->parDerDirDer(1,zeta(0))))/pow(nrm2(rs),3);
113-
}
110+
Vec2 PlanarContour::evalCurvatures(const Vec2 &zeta) {
111+
Vec3 Ks = evalKs(zeta);
112+
Vec3 Ksp = evalParDer1Ks(zeta);
113+
Vec2 kappa(NONINIT);
114+
kappa(0) = (Ksp(1)*Ks(0)-Ksp(0)*Ks(1))/pow(sqrt(Ks(0)*Ks(0)+Ks(1)*Ks(1)),3);
115+
kappa(1) = 0;
116+
return kappa;
117+
}
114118

115119
void PlanarContour::initializeUsingXML(DOMElement * element) {
116120
RigidContour::initializeUsingXML(element);

0 commit comments

Comments
 (0)