Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
U
ur_simple_control
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Deploy
Releases
Package registry
Container registry
Model registry
Operate
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor 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
Marko Guberina
ur_simple_control
Commits
040fac18
Commit
040fac18
authored
1 year ago
by
m-guberina
Browse files
Options
Downloads
Patches
Plain Diff
commit before making a branch
parent
056f87e3
No related branches found
No related tags found
No related merge requests found
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
dmp/my_sol/forcemode_example.py
+63
-17
63 additions, 17 deletions
dmp/my_sol/forcemode_example.py
dmp/my_sol/run_dmp.py
+10
-10
10 additions, 10 deletions
dmp/my_sol/run_dmp.py
with
73 additions
and
27 deletions
dmp/my_sol/forcemode_example.py
+
63
−
17
View file @
040fac18
from
rtde_control
import
RTDEControlInterface
as
RTDEControl
from
rtde_control
import
RTDEControlInterface
from
rtde_receive
import
RTDEReceiveInterface
import
pinocchio
as
pin
import
numpy
as
np
import
os
import
time
import
signal
import
matplotlib.pyplot
as
plt
rtde_c
=
RTDEControl
(
"
192.168.1.102
"
)
rtde_control
=
RTDEControlInterface
(
"
192.168.1.102
"
)
rtde_receive
=
RTDEReceiveInterface
(
"
192.168.1.102
"
)
def
handler
(
signum
,
frame
):
rtde_control
.
forceModeStop
()
print
(
'
sending 100 speedjs full of zeros
'
)
for
i
in
range
(
100
):
vel_cmd
=
np
.
zeros
(
6
)
rtde_control
.
speedJ
(
vel_cmd
,
0.1
,
1.0
/
500
)
rtde_control
.
stopScript
()
exit
()
signal
.
signal
(
signal
.
SIGINT
,
handler
)
# task frame defines force frame relative to base frame
task_frame
=
[
0
,
0
,
0
,
0
,
0
,
0
]
task_frame
=
[
0
,
0
,
0
,
0
,
0
,
0
]
selection_vector
=
[
0
,
0
,
1
,
0
,
0
,
0
]
# these are in {0,1} and select which task frame direction compliance is active in
wrench_down
=
[
0
,
0
,
-
10
,
0
,
0
,
0
]
selection_vector
=
[
1
,
1
,
0
,
0
,
0
,
0
]
wrench_up
=
[
0
,
0
,
10
,
0
,
0
,
0
]
# the wrench applied to the environment:
force_type
=
2
# position is adjusted to achieve the specified wrench
wrench
=
[
-
10
,
0
,
0
,
0
,
0
,
0
]
# type is in {1,2,3}
# 1: force frame is transformed so that it's y-axis is aligned
# with a vector from tcp to origin of force frame (what and why??)
# 2: force frame is not transformed
# 3: transforms force frame s.t. it's x-axis is the projection of
# tcp velocity to the x-y plane of the force frame (again, what and why??)
ftype
=
2
# limits for:
# - compliant axes: highest tcp velocities allowed on compliant axes
# - non-compliant axes: maximum tcp position error compared to the program (which prg,
# and where is this set?)
limits
=
[
2
,
2
,
1.5
,
1
,
1
,
1
]
limits
=
[
2
,
2
,
1.5
,
1
,
1
,
1
]
joint_q
=
[
-
1.52
,
-
1.411
,
-
1.374
,
-
2.026
,
1.375
,
-
0.034
]
# NOTE: avoid movements parallel to compliant direction
# NOTE: avoid high a-/de-celeration because this decreses force control accuracy
# there's also force_mode_set_damping:
# - A value of 1 is full damping, so the robot will decellerate quickly if no
# force is present. A value of 0 is no damping, here the robot will maintain
# the speed.
# - call this before calling force mode if you want it to work.
# Move to initial joint position with a regular moveJ
update_rate
=
500
rtde_c
.
moveJ
(
joint_q
)
dt
=
1
/
update_rate
q
=
np
.
array
(
rtde_receive
.
getActualQ
())
rtde_control
.
forceMode
(
task_frame
,
selection_vector
,
wrench
,
ftype
,
limits
)
# Execute 500Hz control loop for 4 seconds, each cycle is 2ms
for
i
in
range
(
20000
):
for
i
in
range
(
20000
):
t_start
=
rtde_c
.
initPeriod
()
start
=
time
.
time
()
# First move the robot down for 2 seconds, then up for 2 seconds
if
i
>
10000
:
if
i
>
10000
:
rtde_c
.
forceMode
(
task_frame
,
selection_vector
,
wrench_up
,
force_type
,
limits
)
wrench
[
0
]
=
10
rtde_control
.
forceMode
(
task_frame
,
selection_vector
,
wrench
,
ftype
,
limits
)
else
:
rtde_control
.
forceMode
(
task_frame
,
selection_vector
,
wrench
,
ftype
,
limits
)
end
=
time
.
time
()
diff
=
end
-
start
if
dt
<
diff
:
print
(
"
missed deadline by
"
,
diff
-
dt
)
continue
else
:
else
:
rtde_c
.
forceMode
(
task_frame
,
selection_vector
,
wrench_down
,
force_type
,
limits
)
time
.
sleep
(
dt
-
diff
)
rtde_c
.
waitPeriod
(
t_start
)
rtde_c
.
forceModeStop
()
rtde_c
ontrol
.
forceModeStop
()
rtde_c
.
stopScript
()
rtde_c
ontrol
.
stopScript
()
This diff is collapsed.
Click to expand it.
dmp/my_sol/run_dmp.py
+
10
−
10
View file @
040fac18
...
@@ -56,24 +56,24 @@ def handler(signum, frame):
...
@@ -56,24 +56,24 @@ def handler(signum, frame):
rtde_control
.
speedJ
(
vel_cmd
,
0.1
,
1.0
/
500
)
rtde_control
.
speedJ
(
vel_cmd
,
0.1
,
1.0
/
500
)
print
(
'
also plotting
'
)
print
(
'
also plotting
'
)
t
ime
=
np
.
arange
(
N_ITER
)
t
=
np
.
arange
(
N_ITER
)
ax_q
=
plt
.
subplot
(
221
)
ax_q
=
plt
.
subplot
(
221
)
ax_dq
=
plt
.
subplot
(
222
)
ax_dq
=
plt
.
subplot
(
222
)
ax_dmp_q
=
plt
.
subplot
(
223
)
ax_dmp_q
=
plt
.
subplot
(
223
)
ax_dmp_dq
=
plt
.
subplot
(
224
)
ax_dmp_dq
=
plt
.
subplot
(
224
)
for
i
in
range
(
5
):
for
i
in
range
(
5
):
ax_q
.
plot
(
t
ime
,
qs
[:,
i
],
color
=
'
blue
'
)
ax_q
.
plot
(
t
,
qs
[:,
i
],
color
=
'
blue
'
)
ax_dq
.
plot
(
t
ime
,
dqs
[:,
i
],
color
=
'
red
'
)
ax_dq
.
plot
(
t
,
dqs
[:,
i
],
color
=
'
red
'
)
ax_dmp_q
.
plot
(
t
ime
,
dmp_poss
[:,
i
],
color
=
'
green
'
)
ax_dmp_q
.
plot
(
t
,
dmp_poss
[:,
i
],
color
=
'
green
'
)
ax_dmp_dq
.
plot
(
t
ime
,
dmp_vels
[:,
i
],
color
=
'
orange
'
)
ax_dmp_dq
.
plot
(
t
,
dmp_vels
[:,
i
],
color
=
'
orange
'
)
# for labels
# for labels
ax_q
.
plot
(
t
ime
,
qs
[:,
5
],
color
=
'
blue
'
,
label
=
'
q
'
)
ax_q
.
plot
(
t
,
qs
[:,
5
],
color
=
'
blue
'
,
label
=
'
q
'
)
ax_q
.
legend
()
ax_q
.
legend
()
ax_dq
.
plot
(
t
ime
,
dqs
[:,
5
],
color
=
'
red
'
,
label
=
'
dq
'
)
ax_dq
.
plot
(
t
,
dqs
[:,
5
],
color
=
'
red
'
,
label
=
'
dq
'
)
ax_dq
.
legend
()
ax_dq
.
legend
()
ax_dmp_q
.
plot
(
t
ime
,
dmp_poss
[:,
5
],
color
=
'
green
'
,
label
=
'
dmp_q
'
)
ax_dmp_q
.
plot
(
t
,
dmp_poss
[:,
5
],
color
=
'
green
'
,
label
=
'
dmp_q
'
)
ax_dmp_q
.
legend
()
ax_dmp_q
.
legend
()
ax_dmp_dq
.
plot
(
t
ime
,
dmp_vels
[:,
5
],
color
=
'
orange
'
,
label
=
'
dmp_dq
'
)
ax_dmp_dq
.
plot
(
t
,
dmp_vels
[:,
5
],
color
=
'
orange
'
,
label
=
'
dmp_dq
'
)
ax_dmp_dq
.
legend
()
ax_dmp_dq
.
legend
()
plt
.
show
()
plt
.
show
()
exit
()
exit
()
...
@@ -84,7 +84,7 @@ signal.signal(signal.SIGINT, handler)
...
@@ -84,7 +84,7 @@ signal.signal(signal.SIGINT, handler)
dmp
=
DMP
()
dmp
=
DMP
()
rtde_control
.
moveJ
(
dmp
.
pos
.
reshape
((
6
,)))
rtde_control
.
moveJ
(
dmp
.
pos
.
reshape
((
6
,)))
# TODO check that you're there instead of a sleep
# TODO check that you're there instead of a sleep
#t
ime
.sleep(3)
#t.sleep(3)
TEMPORAL_COUPLING
=
True
TEMPORAL_COUPLING
=
True
update_rate
=
500
update_rate
=
500
...
...
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