Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
loco-3d
Multicontact-api
Commits
6140805e
Commit
6140805e
authored
May 06, 2020
by
Pierre Fernbach
Browse files
ContactPhase: add a ContactModel member and remove friction coefficient
parent
e5720363
Changes
2
Hide whitespace changes
Inline
Side-by-side
include/multicontact-api/scenario/contact-patch.hpp
View file @
6140805e
...
...
@@ -3,6 +3,7 @@
#define __multicontact_api_scenario_contact_patch_hpp__
#include "multicontact-api/scenario/fwd.hpp"
#include "multicontact-api/scenario/contact-model.hpp"
#include <pinocchio/spatial/se3.hpp>
#include "multicontact-api/serialization/archive.hpp"
#include "multicontact-api/serialization/spatial.hpp"
...
...
@@ -15,29 +16,30 @@ struct ContactPatchTpl : public serialization::Serializable<ContactPatchTpl<_Sca
EIGEN_MAKE_ALIGNED_OPERATOR_NEW
typedef
_Scalar
Scalar
;
typedef
ContactModelTpl
<
_Scalar
>
ContactModel
;
typedef
pinocchio
::
SE3Tpl
<
Scalar
,
0
>
SE3
;
/// \brief Default constructor.
ContactPatchTpl
()
:
m_placement
(
SE3
::
Identity
()),
m_
mu
(
-
1.
)
{}
ContactPatchTpl
()
:
m_placement
(
SE3
::
Identity
()),
m_
contact_model
(
)
{}
/// \brief Init contact patch from a given placement.
explicit
ContactPatchTpl
(
const
SE3
&
placement
)
:
m_placement
(
placement
),
m_
mu
(
-
1.
)
{}
explicit
ContactPatchTpl
(
const
SE3
&
placement
)
:
m_placement
(
placement
),
m_
contact_model
(
)
{}
/// \brief Init contact patch from a given placement and a friction coefficient
ContactPatchTpl
(
const
SE3
&
placement
,
const
Scalar
mu
)
:
m_placement
(
placement
),
m_
mu
(
mu
)
{}
ContactPatchTpl
(
const
SE3
&
placement
,
const
Scalar
mu
)
:
m_placement
(
placement
),
m_
contact_model
(
mu
)
{}
/// \brief Copy constructor
ContactPatchTpl
(
const
ContactPatchTpl
&
other
)
:
m_placement
(
other
.
m_placement
),
m_
mu
(
other
.
m_mu
)
{}
ContactPatchTpl
(
const
ContactPatchTpl
&
other
)
:
m_placement
(
other
.
m_placement
),
m_
contact_model
(
other
.
m_contact_model
)
{}
const
SE3
&
placement
()
const
{
return
m_placement
;
}
SE3
&
placement
()
{
return
m_placement
;
}
const
Scalar
&
friction
()
const
{
return
m_mu
;
}
Scalar
&
friction
()
{
return
m_mu
;
}
const
Scalar
&
friction
()
const
{
return
m_contact_model
.
m_mu
;
}
Scalar
&
friction
()
{
return
m_contact_model
.
m_mu
;
}
template
<
typename
S2
>
bool
operator
==
(
const
ContactPatchTpl
<
S2
>&
other
)
const
{
return
m_placement
==
other
.
m_placement
&&
m_
mu
==
other
.
m_mu
;
return
m_placement
==
other
.
m_placement
&&
m_
contact_model
==
other
.
m_contact_model
;
}
template
<
typename
S2
>
...
...
@@ -46,7 +48,7 @@ struct ContactPatchTpl : public serialization::Serializable<ContactPatchTpl<_Sca
}
void
disp
(
std
::
ostream
&
os
)
const
{
os
<<
"Placement:
\n
"
<<
m_placement
<<
std
::
endl
<<
"
Friction coefficient : "
<<
m_mu
<<
std
::
endl
;
os
<<
"Placement:
\n
"
<<
m_placement
<<
std
::
endl
<<
"
ContactModel : "
<<
m_contact_model
<<
std
::
endl
;
}
template
<
typename
S2
>
...
...
@@ -59,7 +61,7 @@ struct ContactPatchTpl : public serialization::Serializable<ContactPatchTpl<_Sca
/// \brief Placement of the contact patch
SE3
m_placement
;
/// \brief friction coefficient for this contact
Scalar
m_mu
;
ContactModel
m_contact_model
;
private:
// Serialization of the class
...
...
@@ -68,13 +70,13 @@ struct ContactPatchTpl : public serialization::Serializable<ContactPatchTpl<_Sca
template
<
class
Archive
>
void
save
(
Archive
&
ar
,
const
unsigned
int
/*version*/
)
const
{
ar
&
boost
::
serialization
::
make_nvp
(
"placement"
,
m_placement
);
ar
&
boost
::
serialization
::
make_nvp
(
"
mu"
,
m_mu
);
ar
&
boost
::
serialization
::
make_nvp
(
"
contact_model"
,
m_contact_model
);
}
template
<
class
Archive
>
void
load
(
Archive
&
ar
,
const
unsigned
int
/*version*/
)
{
ar
>>
boost
::
serialization
::
make_nvp
(
"placement"
,
m_placement
);
ar
>>
boost
::
serialization
::
make_nvp
(
"
mu"
,
m_mu
);
ar
>>
boost
::
serialization
::
make_nvp
(
"
contact_model"
,
m_contact_model
);
}
BOOST_SERIALIZATION_SPLIT_MEMBER
()
// why is it required ? using only serialize() lead to compilation error,
...
...
unittest/scenario.cpp
View file @
6140805e
...
...
@@ -362,13 +362,10 @@ BOOST_AUTO_TEST_CASE(contact_model) {
mp3
.
m_contact_type
=
ContactType
::
POINT
;
BOOST_CHECK
(
mp1
!=
mp3
);
std
::
cout
<<
"ContactModel before serialization :
\n
"
<<
mp1
<<
std
::
endl
;
std
::
string
fileName
(
"fileTest_contactModel"
);
mp1
.
saveAsText
(
fileName
+
".txt"
);
ContactModel
mp_from_text
;
mp_from_text
.
loadFromText
(
fileName
+
".txt"
);
std
::
cout
<<
"ContactModel after serialization :
\n
"
<<
mp_from_text
<<
std
::
endl
;
BOOST_CHECK
(
mp1
==
mp_from_text
);
mp1
.
saveAsXML
(
fileName
+
".xml"
,
"ContactModel"
);
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment