Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
T
talos-data
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container Registry
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Stack Of Tasks
talos-data
Commits
4c710120
Commit
4c710120
authored
4 years ago
by
Guilhem Saurel
Browse files
Options
Downloads
Patches
Plain Diff
Format
parent
d24f733d
No related branches found
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
src/SpringPlugin.cc
+6
-16
6 additions, 16 deletions
src/SpringPlugin.cc
src/SpringPlugin.hh
+31
-18
31 additions, 18 deletions
src/SpringPlugin.hh
with
37 additions
and
34 deletions
src/SpringPlugin.cc
+
6
−
16
View file @
4c710120
...
...
@@ -17,7 +17,6 @@
#include
"SpringPlugin.hh"
using
namespace
gazebo
;
GZ_REGISTER_MODEL_PLUGIN
(
SpringPlugin
)
...
...
@@ -26,9 +25,7 @@ GZ_REGISTER_MODEL_PLUGIN(SpringPlugin)
SpringPlugin
::
SpringPlugin
()
{}
/////////////////////////////////////////////////
void
SpringPlugin
::
Load
(
physics
::
ModelPtr
lmodel
,
sdf
::
ElementPtr
lsdf
)
{
void
SpringPlugin
::
Load
(
physics
::
ModelPtr
lmodel
,
sdf
::
ElementPtr
lsdf
)
{
model_
=
lmodel
;
// hardcoded params for this test
...
...
@@ -43,24 +40,18 @@ void SpringPlugin::Load(physics::ModelPtr lmodel,
axisExplicit_
=
lsdf
->
Get
<
int
>
(
"axis"
);
ROS_INFO_NAMED
(
"SpringPlugin"
,
"Loading joint : %s kp: %f kd: %f alongs %d axis"
,
jointExplicitName_
.
c_str
(),
kpExplicit_
,
kdExplicit_
,
axisExplicit_
);
ROS_INFO_NAMED
(
"SpringPlugin"
,
"Loading joint : %s kp: %f kd: %f alongs %d axis"
,
jointExplicitName_
.
c_str
(),
kpExplicit_
,
kdExplicit_
,
axisExplicit_
);
}
/////////////////////////////////////////////////
void
SpringPlugin
::
Init
()
{
void
SpringPlugin
::
Init
()
{
jointExplicit_
=
model_
->
GetJoint
(
jointExplicitName_
);
/* jointImplicit->SetStiffnessDamping(0, kpImplicit,
kdImplicit); */
updateConnection_
=
event
::
Events
::
ConnectWorldUpdateBegin
(
boost
::
bind
(
&
SpringPlugin
::
ExplicitUpdate
,
this
));
updateConnection_
=
event
::
Events
::
ConnectWorldUpdateBegin
(
boost
::
bind
(
&
SpringPlugin
::
ExplicitUpdate
,
this
));
}
/////////////////////////////////////////////////
...
...
@@ -80,7 +71,6 @@ void SpringPlugin::ExplicitUpdate() {
double
pos
=
jointExplicit_
->
Position
(
axisExplicit_
);
#endif
double
vel
=
jointExplicit_
->
GetVelocity
(
axisExplicit_
);
double
force
=
-
kpExplicit_
*
pos
-
kdExplicit_
*
vel
;
double
force
=
-
kpExplicit_
*
pos
-
kdExplicit_
*
vel
;
jointExplicit_
->
SetForce
(
axisExplicit_
,
force
);
}
This diff is collapsed.
Click to expand it.
src/SpringPlugin.hh
+
31
−
18
View file @
4c710120
...
...
@@ -28,33 +28,46 @@
#pragma GCC diagnostic pop
namespace
gazebo
{
class
GAZEBO_VISIBLE
SpringPlugin
:
public
ModelPlugin
{
public:
SpringPlugin
();
public:
virtual
void
Load
(
physics
::
ModelPtr
_model
,
sdf
::
ElementPtr
_sdf
);
public:
virtual
void
Init
();
namespace
gazebo
{
class
GAZEBO_VISIBLE
SpringPlugin
:
public
ModelPlugin
{
public:
SpringPlugin
();
private:
void
ExplicitUpdate
();
public:
virtual
void
Load
(
physics
::
ModelPtr
_model
,
sdf
::
ElementPtr
_sdf
);
private:
event
::
ConnectionPtr
updateConnection_
;
public:
virtual
void
Init
();
private:
physics
::
ModelPtr
model_
;
private:
void
ExplicitUpdate
();
private:
common
::
Time
prevUpdateTime_
;
private:
event
::
ConnectionPtr
updateConnection_
;
private:
physics
::
JointPtr
jointExplicit_
;
private:
std
::
string
jointExplicitName_
;
private:
physics
::
ModelPtr
model_
;
private:
common
::
Time
prevUpdateTime_
;
private:
physics
::
JointPtr
jointExplicit_
;
private:
std
::
string
jointExplicitName_
;
/// \brief simulate spring/damper with ExplicitUpdate function
private:
double
kpExplicit_
;
private:
double
kpExplicit_
;
/// \brief simulate spring/damper with ExplicitUpdate function
private:
double
kdExplicit_
;
private:
double
kdExplicit_
;
/// \brief Specify on which axis the spring is applied.
private:
int
axisExplicit_
;
private:
int
axisExplicit_
;
};
}
}
// namespace gazebo
#endif
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment