Comments (4)
I had to explicitly import DojoEnvironments and also call DojoEnvironments.visualize explicitly.
It runs now, but fails.
Activating project at `~/Dojo.jl/examples`
┌ Info: MeshCat server started. You can open the visualizer by visiting the following URL in your browser:
└ http://127.0.0.1:8702
20.840603 seconds (284.38 M allocations: 31.481 GiB, 18.57% gc time, 36.06% compilation time)
IterativeLQR.eval_obj(s.m_data.obj.costs, s.m_data.x, s.m_data.u, s.m_data.w) = NaN
s.s_data.iter[1] = 15
norm(goal(s.m_data.x[T], zeros(0), zeros(0)), Inf) = NaN
* Terminal will be reused by tasks, press any key to close it.
Modified block.jl:
using Pkg
Pkg.activate(joinpath(@__DIR__, ".."))
Pkg.instantiate()
# ## setup
using Dojo
using IterativeLQR
using LinearAlgebra
using DojoEnvironments
import DojoEnvironments
# ## system
gravity = -9.81
timestep = 0.1
env = get_environment(:block,
representation=:maximal,
timestep=timestep,
friction_coefficient=0.5,
gravity=gravity);
env.mechanism.contacts[1].model.friction_coefficient = 10.0
# ## visualizer
render(env.vis)
# ## dimensions
n = env.num_states
m = env.num_inputs
# ## states
z1 = [0.0; 0.0; 0.25; 0.0; 0.0; 0.0; 1.0; 0.0; 0.0; 0.0; 0.0; 0.0; 0.0]
zT = [0.0; 1.0; 0.25; 0.0; 0.0; 0.0; 1.0; 0.0; 0.0; 0.0; 0.0; 0.0; 0.0] # right goal
## zT = [0.0; 0.0; 0.25 + 1.0; 0.0; 0.0; 0.0; 1.0; 0.0; 0.0; 0.0; 0.0; 0.0; 0.0] # up goal
# ## horizon
T = 11
# ## model
dyn = IterativeLQR.Dynamics(
(y, x, u, w) -> dynamics(y, env, x, u, w),
(dx, x, u, w) -> dynamics_jacobian_state(dx, env, x, u, w, attitude_decompress=true),
(du, x, u, w) -> dynamics_jacobian_input(du, env, x, u, w, attitude_decompress=true),
n, n, m)
model = [dyn for t = 1:T-1];
# ## rollout
ū = [[0.0; 0.0; 0.0] for t = 1:T-1]
x̄ = rollout(model, z1, ū)
DojoEnvironments.visualize(env, x̄);
# ## objective
ot = (x, u, w) -> transpose(x - zT) * Diagonal(1.0 * ones(n)) * (x - zT) + transpose(u) * Diagonal(1.0e-2 * ones(m)) * u
oT = (x, u, w) -> transpose(x - zT) * Diagonal(1.0 * ones(n)) * (x - zT)
ct = Cost(ot, n, m)
cT = Cost(oT, n, 0)
obj = [[ct for t = 1:T-1]..., cT];
# ## constraints
goal(x, u, w) = x - zT
cont = IterativeLQR.Constraint()
conT = IterativeLQR.Constraint(goal, n, 0)
cons = [[cont for t = 1:T-1]..., conT];
# ## solver
s = IterativeLQR.solver(model, obj, cons,
opts=Options(
linesearch=:armijo,
α_min=1.0e-5,
obj_tol=1.0e-3,
grad_tol=1.0e-3,
con_tol=0.005,
max_iter=100,
max_al_iter=10,
ρ_init=1.0,
ρ_scale=10.0,
verbose=false))
IterativeLQR.initialize_controls!(s, ū)
IterativeLQR.initialize_states!(s, x̄);
# ## solve
@time IterativeLQR.solve!(s);
# ## solution
z_sol, u_sol = IterativeLQR.get_trajectory(s)
@show IterativeLQR.eval_obj(s.m_data.obj.costs, s.m_data.x, s.m_data.u, s.m_data.w)
@show s.s_data.iter[1]
@show norm(goal(s.m_data.x[T], zeros(0), zeros(0)), Inf)
# ## visualize
z_vis = [[z_sol[1] for t = 1:10]..., z_sol..., [z_sol[end] for t = 1:10]...]
u_vis = [[u_sol[1] for t = 1:10]..., u_sol..., [u_sol[end] for t = 1:10]...]
vis, anim = DojoEnvironments.visualize(env, z_vis)
vis, anim = DojoEnvironments.visualize_block_force!(vis, anim, z_vis, u_vis)
set_camera!(env.vis,
zoom=50.0,
cam_pos=[100.0, 0.0, 0.0]);
set_floor!(env.vis,
x=0.0,
y=4.0,
z=0.02,
color=RGBA(0.7, 0.7, 0.7, 1.0));
from dojo.jl.
Also, the jupyter notebook generated with Literate.jl also NAN at the same place with no visualization for block.jl
from dojo.jl.
I just pushed a fix for the block example. Used explicit package dependencies for some of the methods, reduced the friction coefficient and changed one of the optimizer settings so that the example works. We will improve this example further, but you should be able to see a result now.
Note, at some point we changed the inputs from impulses to forces, so I think the scaling is off--we need to fix this.
from dojo.jl.
Most environments have been removed in the latest version, but the mechanisms still exist and can be created with, for example, get_mechanism(:block)
.
from dojo.jl.
Related Issues (20)
- Elasticity support? HOT 1
- Defining a Mechanism Documentation out-of-date HOT 1
- Calculate mechanism state from Quaternion? HOT 1
- How to calculate dynamics under the circumstances of reference trajectory
- Error when accessing gradients in AGS HOT 1
- Understanding Controller and applying general force on mechanism HOT 1
- atlas_min example error HOT 1
- Loading Mechanism via URDF error when calling Dojo.Mechanism HOT 5
- SingularException, ldu_factorization_acyclic error (StaticArrays 1.4.4) HOT 1
- Unexpected policy behavior in halfcheetah ARS example HOT 3
- Multiple mechanisms in one simulation HOT 3
- Contact for the wheel object HOT 1
- Memory allocations
- Add remove_fixed_joints for non-URDF mechanisms in constructor
- Question about loading a robot and an object HOT 1
- Consider adding the following code to fix the SphereBoxCollision gradients
- Bouncing Ball HOT 1
- Where can I find examples of atlas.jl HOT 1
- why divide Jτaa by 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from dojo.jl.