Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
D
dynamixel_robot_gazebo
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
Model registry
Operate
Environments
Monitor
Incidents
Service Desk
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
humanoides
common
ROS
dynamixel_robot_gazebo
Commits
5b3ce276
Commit
5b3ce276
authored
5 years ago
by
Sergi Hernandez
Browse files
Options
Downloads
Patches
Plain Diff
Added a module to implement the compliance control.
parent
872d70bf
No related branches found
No related tags found
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
CMakeLists.txt
+1
-0
1 addition, 0 deletions
CMakeLists.txt
include/compliance_control.h
+26
-0
26 additions, 0 deletions
include/compliance_control.h
src/compliance_control.cpp
+76
-0
76 additions, 0 deletions
src/compliance_control.cpp
with
103 additions
and
0 deletions
CMakeLists.txt
+
1
−
0
View file @
5b3ce276
...
...
@@ -104,6 +104,7 @@ include_directories(${dynamixel_INCLUDE_DIR})
# src/${PROJECT_NAME}/dynamixel_controller.cpp
# )
add_library
(
${
PROJECT_NAME
}
src/dynamixel_robot_gazebo.cpp
src/compliance_control.cpp
src/dynamixel_servo.cpp
)
## Declare a cpp executable
...
...
This diff is collapsed.
Click to expand it.
include/compliance_control.h
0 → 100644
+
26
−
0
View file @
5b3ce276
#ifndef _COMPLIANCE_CONTROL_H
#define _COMPLIANCE_CONTROL_H
#include
<ros/node_handle.h>
class
CComplianceControl
{
private:
int
punch
;
int
margin
;
int
slope
;
unsigned
int
enc_res
;
double
max_angle
;
double
max_torque
;
protected:
public:
CComplianceControl
();
bool
init
(
ros
::
NodeHandle
&
nh
,
double
max_torque
,
unsigned
int
enc_res
=
1024
,
double
max_angle
=
300
);
double
control
(
double
error
);
int
get_punch
(
void
);
int
get_margin
(
void
);
int
get_slope
(
void
);
~
CComplianceControl
();
};
#endif
This diff is collapsed.
Click to expand it.
src/compliance_control.cpp
0 → 100644
+
76
−
0
View file @
5b3ce276
#include
"compliance_control.h"
CComplianceControl
::
CComplianceControl
()
{
}
bool
CComplianceControl
::
init
(
ros
::
NodeHandle
&
nh
,
double
max_torque
,
unsigned
int
enc_res
,
double
max_angle
)
{
this
->
punch
=
32
;
if
(
!
nh
.
getParam
(
"punch"
,
this
->
punch
))
{
ROS_ERROR
(
"Dynamixel servo: No punch value specified"
);
throw
;
}
this
->
margin
=
1
;
if
(
!
nh
.
getParam
(
"margin"
,
this
->
margin
))
{
ROS_ERROR
(
"Dynamixel servo: No margin value specified"
);
throw
;
}
this
->
slope
=
32
;
if
(
!
nh
.
getParam
(
"slope"
,
this
->
slope
))
{
ROS_ERROR
(
"Dynamixel servo: No slope value specified"
);
throw
;
}
this
->
enc_res
=
enc_res
;
this
->
max_angle
=
max_angle
;
this
->
max_torque
=
max_torque
;
}
double
CComplianceControl
::
control
(
double
error
)
{
double
p
,
cmd
;
if
(
fabs
(
error
)
<
this
->
margin
*
this
->
max_angle
*
3.14159
/
(
this
->
enc_res
*
180.0
))
return
0.0
;
else
{
p
=
this
->
max_torque
*
(
this
->
enc_res
-
this
->
punch
)
*
180.0
/
(
this
->
slope
*
this
->
max_angle
*
3.14159
);
if
(
error
<
0.0
)
{
cmd
=
p
*
error
-
this
->
max_torque
*
this
->
punch
/
this
->
enc_res
;
if
(
cmd
<-
this
->
max_torque
)
cmd
=-
this
->
max_torque
;
}
else
{
cmd
=
p
*
error
+
this
->
max_torque
*
this
->
punch
/
this
->
enc_res
;
if
(
cmd
>
this
->
max_torque
)
cmd
=
this
->
max_torque
;
}
return
cmd
;
}
}
int
CComplianceControl
::
get_punch
(
void
)
{
return
this
->
punch
;
}
int
CComplianceControl
::
get_margin
(
void
)
{
return
this
->
margin
;
}
int
CComplianceControl
::
get_slope
(
void
)
{
return
this
->
slope
;
}
CComplianceControl
::~
CComplianceControl
()
{
}
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