Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
Gepetto
be-insa
Commits
7dccf356
Commit
7dccf356
authored
Dec 19, 2019
by
Florent Lamiraux
Committed by
Florent Lamiraux florent@laas.fr
Dec 19, 2019
Browse files
Make code compatible with python3.
parent
1410604e
Changes
2
Hide whitespace changes
Inline
Side-by-side
display.py
View file @
7dccf356
...
...
@@ -23,15 +23,15 @@ class Display():
try
:
self
.
viewer
=
gepetto
.
corbaserver
.
Client
()
except
:
print
"Error while starting the viewer client. "
print
"Check whether Gepetto-viewer is properly started"
print
(
"Error while starting the viewer client. "
)
print
(
"Check whether Gepetto-viewer is properly started"
)
# Open a window for displaying your model.
try
:
# If the window already exists, do not do anything.
windowID
=
self
.
viewer
.
gui
.
getWindowID
(
windowName
)
print
"Warning: window '"
+
windowName
+
"' already created."
print
"The previously created objects will not be destroyed and do not have to be created again."
print
(
"Warning: window '"
+
windowName
+
"' already created."
)
print
(
"The previously created objects will not be destroyed and do not have to be created again."
)
except
:
# Otherwise, create the empty window.
windowID
=
self
.
viewer
.
gui
.
createWindow
(
windowName
)
...
...
example_scipy.py
View file @
7dccf356
...
...
@@ -19,21 +19,21 @@ class CallbackLogger:
def
__init__
(
self
):
self
.
nfeval
=
1
def
__call__
(
self
,
x
):
print
'===CBK=== {0:4d} {1: 3.6f} {2: 3.6f} {3: 3.6f}'
.
format
(
self
.
nfeval
,
x
[
0
],
x
[
1
],
cost
(
x
))
print
(
'===CBK=== {0:4d} {1: 3.6f} {2: 3.6f} {3: 3.6f}'
.
format
(
self
.
nfeval
,
x
[
0
],
x
[
1
],
cost
(
x
))
)
self
.
nfeval
+=
1
x0
=
np
.
array
([
0.0
,
0.0
])
# Optimize cost without any constraints in BFGS, with traces.
xopt_bfgs
=
fmin_bfgs
(
cost
,
x0
,
callback
=
CallbackLogger
())
print
'
\n
*** Xopt in BFGS = '
,
xopt_bfgs
,
'
\n\n\n\n
'
print
(
'
\n
*** Xopt in BFGS = '
,
xopt_bfgs
,
'
\n\n\n\n
'
)
# Optimize cost without any constraints in CLSQ
xopt_lsq
=
fmin_slsqp
(
cost
,[
-
1.0
,
1.0
],
iprint
=
2
,
full_output
=
1
)
print
'
\n
*** Xopt in LSQ = '
,
xopt_lsq
,
'
\n\n\n\n
'
print
(
'
\n
*** Xopt in LSQ = '
,
xopt_lsq
,
'
\n\n\n\n
'
)
# Optimize cost with equality and inequality constraints in CLSQ
xopt_clsq
=
fmin_slsqp
(
cost
,[
-
1.0
,
1.0
],
f_eqcons
=
constraint_eq
,
f_ieqcons
=
constraint_ineq
,
iprint
=
2
,
full_output
=
1
)
print
'
\n
*** Xopt in c-lsq = '
,
xopt_clsq
,
'
\n\n\n\n
'
print
(
'
\n
*** Xopt in c-lsq = '
,
xopt_clsq
,
'
\n\n\n\n
'
)
Write
Preview
Supports
Markdown
0%
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!
Cancel
Please
register
or
sign in
to comment