Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
Q
quadruped-reactive-walking
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
Gepetto
quadruped-reactive-walking
Commits
369eef8a
Commit
369eef8a
authored
4 years ago
by
Pierre-Alexandre Leziart
Browse files
Options
Downloads
Patches
Plain Diff
Tweaking and enabling timer
parent
758650a4
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
scripts/Controller.py
+11
-9
11 additions, 9 deletions
scripts/Controller.py
scripts/QP_WBC.py
+11
-6
11 additions, 6 deletions
scripts/QP_WBC.py
scripts/main_solo12_control.py
+5
-5
5 additions, 5 deletions
scripts/main_solo12_control.py
with
27 additions
and
20 deletions
scripts/Controller.py
+
11
−
9
View file @
369eef8a
...
...
@@ -47,7 +47,7 @@ class dummyDevice:
class
Controller
:
def
__init__
(
self
,
q_init
,
envID
,
velID
,
dt_
tsid
,
dt_mpc
,
k_mpc
,
t
,
T_gait
,
T_mpc
,
N_SIMULATION
,
type_MPC
,
def
__init__
(
self
,
q_init
,
envID
,
velID
,
dt_
wbc
,
dt_mpc
,
k_mpc
,
t
,
T_gait
,
T_mpc
,
N_SIMULATION
,
type_MPC
,
pyb_feedback
,
on_solo8
,
use_flat_plane
,
predefined_vel
,
enable_pyb_GUI
,
kf_enabled
):
"""
Function that runs a simulation scenario based on a reference velocity profile, an environment and
various parameters to define the gait
...
...
@@ -55,7 +55,7 @@ class Controller:
Args:
envID (int): identifier of the current environment to be able to handle different scenarios
velID (int): identifier of the current velocity profile to be able to handle different scenarios
dt_
tsid
(float): time step of
TSID
dt_
wbc
(float): time step of
the whole body control
dt_mpc (float): time step of the MPC
k_mpc (int): number of iterations of inverse dynamics for one iteration of the MPC
t (float): time of the simulation
...
...
@@ -99,7 +99,7 @@ class Controller:
# Create Joystick, FootstepPlanner, Logger and Interface objects
self
.
joystick
,
self
.
logger
,
self
.
estimator
=
utils_mpc
.
init_objects
(
dt_
tsid
,
dt_mpc
,
N_SIMULATION
,
k_mpc
,
T_gait
,
type_MPC
,
predefined_vel
,
self
.
h_init
,
kf_enabled
)
dt_
wbc
,
dt_mpc
,
N_SIMULATION
,
k_mpc
,
T_gait
,
type_MPC
,
predefined_vel
,
self
.
h_init
,
kf_enabled
)
# Enable/Disable hybrid control
self
.
enable_hybrid_control
=
True
...
...
@@ -111,7 +111,7 @@ class Controller:
self
.
v
=
np
.
zeros
((
18
,
1
))
self
.
b_v
=
np
.
zeros
((
18
,
1
))
self
.
o_v_filt
=
np
.
zeros
((
18
,
1
))
self
.
planner
=
PyPlanner
(
dt_mpc
,
dt_
tsid
,
T_gait
,
T_mpc
,
self
.
planner
=
PyPlanner
(
dt_mpc
,
dt_
wbc
,
T_gait
,
T_mpc
,
k_mpc
,
on_solo8
,
h_ref
,
self
.
fsteps_init
)
# Wrapper that makes the link with the solver that you want to use for the MPC
...
...
@@ -125,11 +125,11 @@ class Controller:
# myForceMonitor = ForceMonitor.ForceMonitor(pyb_sim.robotId, pyb_sim.planeId)
# Define the default controller
self
.
myController
=
wbc_controller
(
dt_
tsid
,
int
(
N_SIMULATION
)
)
self
.
myController
=
wbc_controller
(
dt_
wbc
)
self
.
envID
=
envID
self
.
velID
=
velID
self
.
dt_
tsid
=
dt_
tsid
self
.
dt_
wbc
=
dt_
wbc
self
.
dt_mpc
=
dt_mpc
self
.
k_mpc
=
k_mpc
self
.
t
=
t
...
...
@@ -271,6 +271,8 @@ class Controller:
"""
if self.k % 5 == 0:
self.solo.display(self.q)
"""
t_wbc
=
time
.
time
()
# Security check
self
.
security_check
()
...
...
@@ -279,7 +281,7 @@ class Controller:
self
.
pyb_camera
(
device
)
# Logs
self
.
log_misc
(
t_start
,
t_filter
,
t_planner
,
t_mpc
)
self
.
log_misc
(
t_start
,
t_filter
,
t_planner
,
t_mpc
,
t_wbc
)
# Increment loop counter
self
.
k
+=
1
...
...
@@ -321,7 +323,7 @@ class Controller:
self
.
result
.
v_des
[:]
=
np
.
zeros
(
12
)
self
.
result
.
tau_ff
[:]
=
np
.
zeros
(
12
)
def
log_misc
(
self
,
tic
,
t_filter
,
t_planner
,
t_mpc
):
def
log_misc
(
self
,
tic
,
t_filter
,
t_planner
,
t_mpc
,
t_wbc
):
# Log joystick command
if
self
.
joystick
is
not
None
:
...
...
@@ -330,7 +332,7 @@ class Controller:
self
.
t_list_filter
[
self
.
k
]
=
t_filter
-
tic
self
.
t_list_planner
[
self
.
k
]
=
t_planner
-
t_filter
self
.
t_list_mpc
[
self
.
k
]
=
t_mpc
-
t_planner
self
.
t_list_wbc
[
self
.
k
]
=
t
ime
.
time
()
-
t_mpc
self
.
t_list_wbc
[
self
.
k
]
=
t
_wbc
-
t_mpc
self
.
t_list_loop
[
self
.
k
]
=
time
.
time
()
-
tic
self
.
t_list_InvKin
[
self
.
k
]
=
self
.
myController
.
tac
-
self
.
myController
.
tic
self
.
t_list_QPWBC
[
self
.
k
]
=
self
.
myController
.
toc
-
self
.
myController
.
tac
This diff is collapsed.
Click to expand it.
scripts/QP_WBC.py
+
11
−
6
View file @
369eef8a
...
...
@@ -8,8 +8,13 @@ import libquadruped_reactive_walking as lrw
class
wbc_controller
():
"""
Whole body controller which contains an Inverse Kinematics step and a BoxQP step
def
__init__
(
self
,
dt
,
N_SIMULATION
):
Args:
dt (float): time step of the whole body control
"""
def
__init__
(
self
,
dt
):
self
.
dt
=
dt
# Time step
...
...
@@ -48,12 +53,12 @@ class wbc_controller():
self
.
k_since_contact
+=
contacts
# Increment feet in stance phase
self
.
k_since_contact
*=
contacts
# Reset feet in swing phase
#
self.tic = time()
self
.
tic
=
time
()
# Compute Inverse Kinematics
ddq_cmd
=
np
.
array
([
self
.
invKin
.
refreshAndCompute
(
q
.
copy
(),
dq
.
copy
(),
x_cmd
,
contacts
,
planner
)]).
T
#
self.tac = time()
self
.
tac
=
time
()
# Compute the joint space inertia matrix M by using the Composite Rigid Body Algorithm
self
.
M
=
pin
.
crba
(
self
.
invKin
.
rmodel
,
self
.
invKin
.
rdata
,
q
)
...
...
@@ -86,10 +91,10 @@ class wbc_controller():
self
.
vdes
[:,
0
]
=
self
.
invKin
.
dq_cmd
self
.
qdes
[:]
=
self
.
invKin
.
q_cmd
#
self.toc = time()
self
.
toc
=
time
()
self
.
tic
=
0.0
"""
self.tic = 0.0
self.tac = 0.0
self
.
toc
=
0.0
self.toc = 0.0
"""
return
0
This diff is collapsed.
Click to expand it.
scripts/main_solo12_control.py
+
5
−
5
View file @
369eef8a
...
...
@@ -86,7 +86,7 @@ def control_loop(name_interface):
t
=
0.0
# Time
T_gait
=
0.32
# Duration of one gait period
T_mpc
=
0.32
# Duration of the prediction horizon
N_SIMULATION
=
20
000
# number of simulated wbc time steps
N_SIMULATION
=
4
000
# number of simulated wbc time steps
# Which MPC solver you want to use
# True to have PA's MPC, to False to have Thomas's MPC
...
...
@@ -108,7 +108,7 @@ def control_loop(name_interface):
kf_enabled
=
False
# Enable or disable PyBullet GUI
enable_pyb_GUI
=
Tru
e
enable_pyb_GUI
=
Fals
e
if
not
SIMULATION
:
enable_pyb_GUI
=
False
...
...
@@ -287,7 +287,7 @@ def control_loop(name_interface):
plt.plot(log_b_v[i-3, :], c=
'
b
'
, linewidth=3)
plt.show()
"""
"""
from matplotlib import pyplot as plt
from
matplotlib
import
pyplot
as
plt
plt
.
figure
()
plt
.
plot
(
controller
.
t_list_filter
[
1
:],
'
r+
'
)
plt
.
plot
(
controller
.
t_list_planner
[
1
:],
'
g+
'
)
...
...
@@ -296,9 +296,9 @@ def control_loop(name_interface):
plt
.
plot
(
controller
.
t_list_loop
[
1
:],
'
k+
'
)
plt
.
plot
(
controller
.
t_list_InvKin
[
1
:],
'
o
'
,
color
=
"
darkgreen
"
)
plt
.
plot
(
controller
.
t_list_QPWBC
[
1
:],
'
o
'
,
color
=
"
royalblue
"
)
plt.legend([
"
Estimator
"
,
"
Planner
"
,
"
MPC
"
,
"
WBC
"
,
"
Whole loop
"
,
"
InvKin
"
,
"
QP WBC
"
,
"
Integ
"
])
plt
.
legend
([
"
Estimator
"
,
"
Planner
"
,
"
MPC
"
,
"
WBC
"
,
"
Whole loop
"
,
"
InvKin
"
,
"
QP WBC
"
])
plt
.
title
(
"
Loop time [s]
"
)
plt.show(block=True)
"""
plt
.
show
(
block
=
True
)
"""
from matplotlib import pyplot as plt
N = len(controller.log_tmp2)
...
...
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