Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 14 additions & 14 deletions Project.toml
Original file line number Diff line number Diff line change
Expand Up @@ -18,28 +18,28 @@ Meshing = "e6723b4c-ebff-59f1-b4b7-d97aa5274f73"
Parameters = "d96e819e-fc66-5662-9728-84c9c7592b0a"
Pkg = "44cfe95a-1eb2-52ea-b672-e2afdf69b78f"
Polyhedra = "67491407-f73d-577b-9b50-8179a7c68029"
Quaternions = "94ee1d12-ae83-5a48-8b1c-48b8ff168ae0"
Random = "9a3f8284-a2c9-5f02-9a11-845980a1fd5c"
Rotations = "6038ab10-8711-5258-84ad-4b1120ba62dc"
Scratch = "6c6a2e73-6563-6170-7368-637461726353"
SparseArrays = "2f01184e-e22b-5df5-ae63-d93ebab69eaf"
StaticArrays = "90137ffa-7385-5640-81b9-e52037218182"
Statistics = "10745b16-79ce-11e8-11f9-7d13ad32a3b2"
Test = "8dfed614-e22c-5e08-85e1-65c5234f0b40"

[compat]
Colors = "<0.12.6, 0.12.6"
DocStringExtensions = "<0.8.3, 0.8.3"
Colors = "<0.12.8, 0.12.8"
DocStringExtensions = "<0.8.6, 0.8.6"
FFMPEG = "0.4.1"
GeometryBasics = "0.3"
JLD2 = "0.4.21"
LaTeXStrings = "1.3.0"
LightGraphs = "1.3.5"
GeometryBasics = "<0.4.0, 0.4.0"
JLD2 = "<0.4.22, 0.4.22"
LaTeXStrings = "1.3"
LightGraphs = "1.3"
LightXML = "<0.9.0, 0.9.0"
MeshCat = "0.14"
Meshing = "0.5.7"
Parameters = "0.12"
Polyhedra = "0.6.18"
Rotations = "1.0.2 - 1.0.2"
MeshCat = "<0.14.0, 0.14.0"
Meshing = "<0.5.7, 0.5.7"
Parameters = "<0.12.0, 0.12.0"
Polyhedra = "<0.7.1, 0.7.1"
Quaternions = "<0.5.3, 0.5.3"
Scratch = "1.1"
StaticArrays = "1.4"
julia = "1.6"
StaticArrays = "1.2"
julia = "1.6, 1.7"
2 changes: 1 addition & 1 deletion environments/box/methods/initialize.jl
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ end

function initialize_box!(mechanism::Mechanism{T};
x=[0.0, 0.0, 1.0],
q=UnitQuaternion(1.0, 0.0, 0.0, 0.0),
q=Quaternion(1.0, 0.0, 0.0, 0.0),
v=[1.0, 0.3, 0.2],
ω=[2.5, -1.0, 2.0]) where T

Expand Down
2 changes: 1 addition & 1 deletion environments/box2D/methods/initialize.jl
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ function initialize_box2D!(mechanism::Mechanism{T};

set_maximal_configurations!(body,
x=[0.0; position] + [0.0, 0.0 , z],
q=UnitQuaternion(RotX(orientation)))
q=RotX(orientation))
set_maximal_velocities!(body,
v=[0.0; linear_velocity],
ω=[angular_velocity, 0.0, 0.0])
Expand Down
2 changes: 1 addition & 1 deletion environments/cartpole/methods/env.jl
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,7 @@ function ghost(env::Environment{Cartpole}, z_sol;
for (i, xt) in enumerate(z_sol)
z_pendulum = xt[13 .+ (1:13)]
x = z_pendulum[1:3]
q = UnitQuaternion(z_pendulum[6 .+ (1:4)]...)
q = Quaternion(z_pendulum[6 .+ (1:4)]...)
k = x + vector_rotate([0.0; 0.0; -0.5], q)

push!(points, Point(k[1], k[2], k[3]))
Expand Down
6 changes: 3 additions & 3 deletions environments/cartpole/methods/initialize.jl
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ function get_cartpole(;
# Links
origin = Origin{Float64}()
slider = Capsule(1.5 * radius, slider_length, slider_mass,
axis_offset=UnitQuaternion(RotX(0.5 * π)),
axis_offset=RotX(0.5 * π),
color=RGBA(0.7, 0.7, 0.7, 1.0))
pendulum = Capsule(radius, pendulum_length, pendulum_mass,
color=RGBA(0.7, 0.7, 0.7, 1.0))
Expand Down Expand Up @@ -56,14 +56,14 @@ function initialize_cartpole!(mech::Mechanism{T,Nn,Ne,Nb};
if mode == :down
set_maximal_configurations!(mech.bodies[1], mech.bodies[2],
Δx=[0.0; 0.0; -0.5 * pendulum_length],
Δq=UnitQuaternion(RotX(π)))
Δq=RotX(π))
set_maximal_velocities!(mech.bodies[2],
v=zeros(3),
ω=zeros(3))
elseif mode == :up
set_maximal_configurations!(mech.bodies[1], mech.bodies[2],
Δx=[0.0; 0.0; 0.5 * pendulum_length],
Δq=UnitQuaternion(RotX(π)))
Δq=RotX(π))
set_maximal_velocities!(mech.bodies[2],
v=zeros(3),
ω=zeros(3))
Expand Down
2 changes: 1 addition & 1 deletion environments/dzhanibekov/methods/initialize.jl
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ function get_dzhanibekov(;
main_body = Capsule(radius, body_length, body_mass,
color=color, name=:main)
side_body = Capsule(0.5 * radius, 0.35 * body_length, 0.5 * body_mass,
axis_offset=UnitQuaternion(RotY(0.5 * π)),
axis_offset=RotY(0.5 * π),
color=color, name=:side)
links = [main_body, side_body]

Expand Down
4 changes: 2 additions & 2 deletions environments/humanoid/methods/initialize.jl
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,8 @@ function get_humanoid(;

aa = -0.43000 * [-0.44721, 0.00000, 0.89442]
ql = axis_angle_to_quaternion(aa)
qll = ql * UnitQuaternion(RotXYZ(roll=-1.57080, pitch=1.47585, yaw=-1.47585)) # roll pitch yaw
qlr = ql * UnitQuaternion(RotXYZ(roll=+1.57080, pitch=1.47585, yaw=+1.47585)) # roll pitch yaw
qll = ql * RotX(-1.57080)*RotY(1.47585)*RotZ(-1.47585) # Quaternion(RotXYZ(roll=-1.57080, pitch=1.47585, yaw=-1.47585)) # roll pitch yaw
qlr = ql * RotX(+1.57080)*RotY(1.47585)*RotZ(+1.47585) # Quaternion(RotXYZ(roll=+1.57080, pitch=1.47585, yaw=+1.47585)) # roll pitch yaw

pfll = vector_rotate([ 0.5 * left_foot.shape.shape[1].rh[2] + 0.03500; -0.03; 0.0], qll)
pbll = vector_rotate([-0.5 * left_foot.shape.shape[1].rh[2] + 0.03500; -0.03; 0.0], qll)
Expand Down
2 changes: 1 addition & 1 deletion environments/orbital/methods/initialize.jl
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ function initialize_orbital!(mechanism::Mechanism{T};
# set position and velocities
set_maximal_configurations!(mechanism.origin, pbody,
child_vertex=vert11,
Δq=UnitQuaternion(RotX(0.0)))
Δq=RotX(0.0))

set_minimal_coordinates!(mechanism, mechanism.joints[2], orientation)

Expand Down
4 changes: 2 additions & 2 deletions environments/pendulum/methods/initialize.jl
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ function get_pendulum(;
spring=0.0,
damper=0.0,
spring_offset=szeros(1),
axis_offset=one(UnitQuaternion),
axis_offset=one(Quaternion),
T=Float64)

# Parameters
Expand Down Expand Up @@ -106,7 +106,7 @@ function initialize_npendulum!(mechanism::Mechanism{T};
# set position and velocities
set_maximal_configurations!(mechanism.origin, pbody,
child_vertex=vert11,
Δq=UnitQuaternion(RotX(base_angle)))
Δq=RotX(base_angle))
set_maximal_velocities!(pbody,
ω=base_angular_velocity)

Expand Down
2 changes: 1 addition & 1 deletion environments/raiberthopper/methods/env.jl
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,7 @@ function visualize(env::Environment{RaibertHopper}, traj::Vector{Vector{T}};
name=name)
step = range(0.0, stop=norm(dir), length=n_leg)
for i = 1:n_leg
MeshCat.settransform!(env.vis["leg$i"], MeshCat.compose(MeshCat.Translation(step[i] .* dir_norm + x_foot), MeshCat.LinearMap(Rotations.RotY(0.0))))
MeshCat.settransform!(env.vis["leg$i"], MeshCat.compose(MeshCat.Translation(step[i] .* dir_norm + x_foot), MeshCat.LinearMap(Dojo.RotY(0.0))))
end
end
end
Expand Down
2 changes: 1 addition & 1 deletion environments/raiberthopper/methods/initialize.jl
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ function initialize_raiberthopper!(mech::Mechanism{T,Nn,Ne,Nb};
# body to foot
set_maximal_configurations!(pbody, cbody,
Δx=[0.0; 0.0; -leg_length],
Δq=UnitQuaternion(RotX(0.0)))
Δq=RotX(0.0))
set_maximal_velocities!(pbody, cbody,
parent_vertex=tra2.vertices[1],
child_vertex=tra2.vertices[2],
Expand Down
2 changes: 1 addition & 1 deletion environments/snake/methods/initialize.jl
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ end

function initialize_snake!(mechanism::Mechanism{T};
base_position=[0.0, -0.5, 0.0],
base_orientation=UnitQuaternion(RotX(0.6 * π)),
base_orientation=RotX(0.6 * π),
base_linear_velocity=zeros(3),
base_angular_velocity=zeros(3),
relative_linear_velocity=zeros(3),
Expand Down
2 changes: 1 addition & 1 deletion environments/sphere/methods/initialize.jl
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ end

function initialize_sphere!(mechanism::Mechanism{T};
x=zeros(3),
q=one(UnitQuaternion),
q=one(Quaternion),
v=zeros(3),
ω=zeros(3)) where T

Expand Down
2 changes: 1 addition & 1 deletion environments/tennisracket/methods/initialize.jl
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ end

function initialize_tennisracket!(mechanism::Mechanism{T};
x=zeros(3),
q=one(UnitQuaternion),
q=one(Quaternion),
v=zeros(3),
ω=zeros(3)) where T

Expand Down
2 changes: 1 addition & 1 deletion environments/twister/methods/initialize.jl
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ end

function initialize_twister!(mechanism::Mechanism{T};
base_position=[0.0, -1.0, 0.0],
base_orientation=UnitQuaternion(RotX(0.6 * π)),
base_orientation=RotX(0.6 * π),
base_linear_velocity=zeros(3),
base_angular_velocity=zeros(3),
relative_linear_velocity=zeros(3),
Expand Down
2 changes: 1 addition & 1 deletion examples/animations/generate/box.jl
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ for t = 1:length(z_vis)
u = (t == length(z_vis) ? 0.5 * u_vis[end] ./ u_max : 0.5 * u_vis[t] ./ u_max)
MeshCat.atframe(anim, t) do

settransform!(v[:robot], MeshCat.compose(MeshCat.Translation(z[2], z[1], z[3]), MeshCat.LinearMap(UnitQuaternion(z[6 .+ (1:4)]...))))
settransform!(v[:robot], MeshCat.compose(MeshCat.Translation(z[2], z[1], z[3]), MeshCat.LinearMap(Quaternion(z[6 .+ (1:4)]...))))
settransform!(force_vis,
Point(z[2] - u[2] - shift[2], z[1] - u[1] - shift[1], z[3] - u[3] - shift[3]),
Vec(u[2], u[1], u[3]),
Expand Down
8 changes: 4 additions & 4 deletions examples/simulation/cone_compare.jl
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ mech_lc = get_mechanism(:box,
# ## Simulate
initialize!(mech_lc, :box,
x=x0,
q=one(UnitQuaternion),
q=one(Quaternion),
v=v0,
ω=ω0)

Expand All @@ -70,7 +70,7 @@ mech_nc = get_mechanism(:box,
# ## Simulate
initialize!(mech_nc, :box,
x=x0,
q=one(UnitQuaternion),
q=one(Quaternion),
v=v0,
ω=ω0)

Expand Down Expand Up @@ -101,7 +101,7 @@ mech_mjlc = get_mechanism(:box,
# ## Load
initialize!(mech_mjlc, :box,
x=x0,
q=one(UnitQuaternion),
q=one(Quaternion),
v=v0,
ω=ω0)
file = jldopen(joinpath(@__DIR__, "../mujoco_benchmark/results/cone_compare_pyramidal.jld2"))
Expand Down Expand Up @@ -135,7 +135,7 @@ mech_mjnc = get_mechanism(:box,
# ## Load
initialize!(mech_mjnc, :box,
x=x0,
q=one(UnitQuaternion),
q=one(Quaternion),
v=v0,
ω=ω0)
file = jldopen(joinpath(@__DIR__, "../mujoco_benchmark/results/cone_compare_elliptic.jld2"))
Expand Down
4 changes: 2 additions & 2 deletions examples/system_identification/data/data.jl
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,8 @@ function toss2z(toss, timestep; s=1)
q2 = vec2[4:7]

v15 = (x2 - x1) / timestep
ϕ15 = ω_finite_difference(UnitQuaternion(q1...),
UnitQuaternion(q2...), timestep)
ϕ15 = ω_finite_difference(Quaternion(q1...),
Quaternion(q2...), timestep)

z2 = [x2; v15; q2; ϕ15]
push!(z, z2)
Expand Down
10 changes: 5 additions & 5 deletions examples/system_identification/methods/utils.jl
Original file line number Diff line number Diff line change
Expand Up @@ -128,19 +128,19 @@ function datafilename(model::Symbol; kwargs...)
end

function datafilenamesphere(; N::Int=10, friction_coefficient=0.1, radius=0.5)
"sphere_dim_N:$(N)_friction_coefficient:$(friction_coefficient)_radius:$(radius).jld2"
"sphere_dim_N_$(N)_friction_coefficient_$(friction_coefficient)_radius_$(radius).jld2"
end

function datafilenamebox2D(; N::Int=10, friction_coefficient=0.1, radius=0.05, side=0.50)
"box2D_dim_N:$(N)_friction_coefficient:$(friction_coefficient)_radius:$(radius)_side:$(side).jld2"
"box2D_dim_N_$(N)_friction_coefficient_$(friction_coefficient)_radius_$(radius)_side_$(side).jld2"
end

function datafilenamebox(; N::Int=10, friction_coefficient=0.1, radius=0., side=0.50)
"box_dim_N:$(N)_friction_coefficient:$(friction_coefficient)_radius:$(radius)_side:$(side).jld2"
"box_dim_N_$(N)_friction_coefficient_$(friction_coefficient)_radius_$(radius)_side_$(side).jld2"
end

function datafilenamehardwarebox(; N::Int=10, s=1)
"hardwarebox_dim_N:$(N)_sample_S:$(S).jld2"
"hardwarebox_dim_N_$(N)_sample_S_$(S).jld2"
end

function initial_state(model::Symbol; kwargs...)
Expand Down Expand Up @@ -176,7 +176,7 @@ function initial_state_box(;
x = xlims[1] + rand(3) .* (xlims[2] - xlims[1])
v = vlims[1] + rand(3) .* (vlims[2] - vlims[1])
ω = ωlims[1] + rand(3) .* (ωlims[2] - ωlims[1])
return Dict(:x => x, :v => v , :q => rand(UnitQuaternion), :ω => ω)
return Dict(:x => x, :v => v , :q => normalize(rand(Quaternion{Float64})), :ω => ω)
end

function build_pairs(mechanism::Mechanism, trajs::AbstractVector)
Expand Down
8 changes: 2 additions & 6 deletions src/Dojo.jl
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,7 @@ using Random
using StaticArrays
using SparseArrays
using StaticArrays: SUnitRange
using Rotations
using Rotations: RotationError, params, lmult, rmult, tmat, vmat, hmat, skew, pure_quaternion
using Quaternions
using Parameters
using Statistics

Expand Down Expand Up @@ -256,10 +255,7 @@ export

# Orientation
export
UnitQuaternion,
RotX,
RotY,
RotZ,
Quaternion,
attitude_jacobian

# Data
Expand Down
4 changes: 2 additions & 2 deletions src/bodies/set.jl
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ end
# maximal
function set_maximal_configurations!(body::Body;
x::AbstractVector=SA[0.0; 0.0; 0.0],
q::UnitQuaternion=one(UnitQuaternion))
q::Quaternion=one(Quaternion))

body.state.x2 = x
body.state.q2 = q
Expand All @@ -60,7 +60,7 @@ function set_maximal_configurations!(pbody::Node, cbody::Body;
parent_vertex::AbstractVector=SA[0.0; 0.0; 0.0],
child_vertex::AbstractVector=SA[0.0; 0.0; 0.0],
Δx::AbstractVector=SA[0.0; 0.0; 0.0],
Δq::UnitQuaternion=one(UnitQuaternion))
Δq::Quaternion=one(Quaternion))

q1 = pbody.state.q2
q2 = pbody.state.q2 * Δq
Expand Down
Loading