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
ae535940
Commit
ae535940
authored
4 years ago
by
Sergi Hernandez
Browse files
Options
Downloads
Patches
Plain Diff
Added a feature to set the initial angle of the servos.
parent
6c1c5601
No related branches found
Branches containing commit
No related tags found
1 merge request
!1
Improved the way to execute trajectories using the time and velocity profile options
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
include/dynamixel_servo.h
+1
-0
1 addition, 0 deletions
include/dynamixel_servo.h
src/dynamixel_servo.cpp
+26
-1
26 additions, 1 deletion
src/dynamixel_servo.cpp
with
27 additions
and
1 deletion
include/dynamixel_servo.h
+
1
−
0
View file @
ae535940
...
@@ -32,6 +32,7 @@ namespace dynamixel_robot_gazebo
...
@@ -32,6 +32,7 @@ namespace dynamixel_robot_gazebo
void
init_compliance
(
const
std
::
string
&
joint_name
,
ros
::
NodeHandle
&
controller_nh
);
void
init_compliance
(
const
std
::
string
&
joint_name
,
ros
::
NodeHandle
&
controller_nh
);
void
init_memory
(
void
);
void
init_memory
(
void
);
void
set_current_angle
(
double
angle
);
void
set_current_angle
(
double
angle
);
void
set_target_angle
(
double
angle
);
void
set_current_speed
(
double
speed
);
void
set_current_speed
(
double
speed
);
void
set_current_pwm
(
double
pwm
);
void
set_current_pwm
(
double
pwm
);
double
saturate_command
(
double
command
);
double
saturate_command
(
double
command
);
...
...
This diff is collapsed.
Click to expand it.
src/dynamixel_servo.cpp
+
26
−
1
View file @
ae535940
...
@@ -5,6 +5,7 @@ namespace dynamixel_robot_gazebo
...
@@ -5,6 +5,7 @@ namespace dynamixel_robot_gazebo
CDynServo
::
CDynServo
(
const
std
::
string
&
joint_name
,
CDynamixelSlaveSerial
*
dyn_slave
,
hardware_interface
::
EffortJointInterface
*
hw
,
ros
::
NodeHandle
&
controller_nh
)
CDynServo
::
CDynServo
(
const
std
::
string
&
joint_name
,
CDynamixelSlaveSerial
*
dyn_slave
,
hardware_interface
::
EffortJointInterface
*
hw
,
ros
::
NodeHandle
&
controller_nh
)
{
{
int
id
;
int
id
;
double
initial_angle
;
// Joint handle
// Joint handle
try
{
try
{
...
@@ -140,6 +141,10 @@ namespace dynamixel_robot_gazebo
...
@@ -140,6 +141,10 @@ namespace dynamixel_robot_gazebo
else
else
this
->
id
=
id
;
this
->
id
=
id
;
this
->
init_memory
();
this
->
init_memory
();
// read initial angle
initial_angle
=
0.0
;
servo_nh
.
getParam
(
"initial_angle"
,
initial_angle
);
this
->
set_target_angle
(
initial_angle
);
dyn_slave
->
add_slave
(
id
,
boost
::
bind
(
&
CDynServo
::
on_ping
,
this
),
boost
::
bind
(
&
CDynServo
::
on_read
,
this
,
_1
,
_2
,
_3
),
boost
::
bind
(
&
CDynServo
::
on_write
,
this
,
_1
,
_2
,
_3
));
dyn_slave
->
add_slave
(
id
,
boost
::
bind
(
&
CDynServo
::
on_ping
,
this
),
boost
::
bind
(
&
CDynServo
::
on_read
,
this
,
_1
,
_2
,
_3
),
boost
::
bind
(
&
CDynServo
::
on_write
,
this
,
_1
,
_2
,
_3
));
}
}
...
@@ -471,6 +476,26 @@ namespace dynamixel_robot_gazebo
...
@@ -471,6 +476,26 @@ namespace dynamixel_robot_gazebo
}
}
}
}
void
CDynServo
::
set_target_angle
(
double
angle
)
{
unsigned
int
value
;
value
=
((((
angle
*
180.0
)
/
3.14159
)
+
(
this
->
max_angle
/
2.0
))
*
this
->
encoder_res
)
/
this
->
max_angle
;
if
(
model
==
"AX12W"
||
model
==
"AX12A"
||
model
==
"AX18A"
||
model
==
"MX12W"
||
model
==
"MX28v1"
||
model
==
"MX64v1"
||
model
==
"MX106v1"
||
model
==
"XL320"
)
{
this
->
memory
[
30
]
=
value
&
0x000000FF
;
this
->
memory
[
31
]
=
(
value
>>
8
)
&
0x000000FF
;
}
else
{
this
->
memory
[
116
]
=
value
&
0x000000FF
;
this
->
memory
[
117
]
=
(
value
>>
8
)
&
0x000000FF
;
this
->
memory
[
118
]
=
(
value
>>
16
)
&
0x000000FF
;
this
->
memory
[
119
]
=
(
value
>>
24
)
&
0x000000FF
;
}
}
void
CDynServo
::
set_current_speed
(
double
speed
)
void
CDynServo
::
set_current_speed
(
double
speed
)
{
{
unsigned
int
value
;
unsigned
int
value
;
...
@@ -553,7 +578,7 @@ namespace dynamixel_robot_gazebo
...
@@ -553,7 +578,7 @@ namespace dynamixel_robot_gazebo
if
(
model
==
"AX12W"
||
model
==
"AX12A"
||
model
==
"AX18A"
||
model
==
"MX12W"
||
model
==
"MX28v1"
||
model
==
"MX64v1"
||
model
==
"MX106v1"
||
model
==
"XL320"
)
if
(
model
==
"AX12W"
||
model
==
"AX12A"
||
model
==
"AX18A"
||
model
==
"MX12W"
||
model
==
"MX28v1"
||
model
==
"MX64v1"
||
model
==
"MX106v1"
||
model
==
"XL320"
)
value
=
this
->
memory
[
30
]
+
(
this
->
memory
[
31
]
<<
8
);
value
=
this
->
memory
[
30
]
+
(
this
->
memory
[
31
]
<<
8
);
else
else
value
=
this
->
memory
[
116
]
+
(
this
->
memory
[
1
33
]
<<
8
)
+
(
this
->
memory
[
1
34
]
<<
16
)
+
(
this
->
memory
[
1
35
]
<<
24
);
value
=
this
->
memory
[
116
]
+
(
this
->
memory
[
1
17
]
<<
8
)
+
(
this
->
memory
[
1
18
]
<<
16
)
+
(
this
->
memory
[
1
19
]
<<
24
);
angle
=
(((((
value
*
this
->
max_angle
)
/
this
->
encoder_res
))
-
this
->
max_angle
/
2.0
)
*
3.14159
)
/
180.0
;
angle
=
(((((
value
*
this
->
max_angle
)
/
this
->
encoder_res
))
-
this
->
max_angle
/
2.0
)
*
3.14159
)
/
180.0
;
return
angle
;
return
angle
;
...
...
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