Skip to content

Commit

Permalink
Merge pull request #469 from JuliaRobotics/tk/more-0.7
Browse files Browse the repository at this point in the history
More fixes for 0.7
  • Loading branch information
tkoolen authored Aug 2, 2018
2 parents 42bf239 + 4fa9e51 commit 163aa89
Show file tree
Hide file tree
Showing 9 changed files with 19 additions and 15 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
"using ForwardDiff\n",
"using Test\n",
"using Random\n",
"srand(1);"
"Random.seed!(1);"
]
},
{
Expand Down
4 changes: 2 additions & 2 deletions notebooks/Jacobian IK and Control.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
"\n",
"# Fix the random seed, so we get repeatable results\n",
"using Random\n",
"srand(42)"
"Random.seed!(42)"
]
},
{
Expand Down Expand Up @@ -65,7 +65,7 @@
}
],
"source": [
"urdf = Pkg.dir(\"RigidBodyDynamics\", \"test\", \"urdf\", \"Acrobot.urdf\")\n",
"urdf = joinpath(dirname(pathof(RigidBodyDynamics)), \"..\", \"test\", \"urdf\", \"Acrobot.urdf\")\n",
"\n",
"mechanism = parse_urdf(Float64, urdf)\n",
"state = MechanismState(mechanism)\n",
Expand Down
2 changes: 1 addition & 1 deletion notebooks/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,5 +11,5 @@ You can also run the notebooks locally by performing the following steps:
3. [install IJulia](https://github.com/JuliaLang/IJulia.jl)
4. in the Julia REPL, run
```
using IJulia; notebook(dir=Pkg.dir("RigidBodyDynamics", "notebooks"))
using IJulia, RigidBodyDynamics; notebook(dir=joinpath(dirname(pathof(RigidBodyDynamics)), "..", "notebooks"))
```
Original file line number Diff line number Diff line change
Expand Up @@ -304,7 +304,7 @@
],
"source": [
"const T = Interval{Float64}\n",
"const mechanism = parse_urdf(T, Pkg.dir(\"RigidBodyDynamics\", \"test\", \"urdf\", \"Acrobot.urdf\"))\n",
"const mechanism = parse_urdf(T, joinpath(dirname(pathof(RigidBodyDynamics)), \"..\", \"test\", \"urdf\", \"Acrobot.urdf\"))\n",
"remove_fixed_tree_joints!(mechanism)\n",
"state = MechanismState(mechanism)"
]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@
}
],
"source": [
"urdf = Pkg.dir(\"RigidBodyDynamics\", \"test\", \"urdf\", \"Acrobot.urdf\")\n",
"urdf = joinpath(dirname(pathof(RigidBodyDynamics)), \"..\", \"test\", \"urdf\", \"Acrobot.urdf\")\n",
"mechanism = parse_urdf(Float64, urdf)\n",
"remove_fixed_tree_joints!(mechanism)\n",
"mechanism"
Expand Down
2 changes: 1 addition & 1 deletion src/RigidBodyDynamics.jl
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
__precompile__()
VERSION < v"0.7.0-beta2.199" && __precompile__()

module RigidBodyDynamics

Expand Down
14 changes: 8 additions & 6 deletions src/mechanism_algorithms.jl
Original file line number Diff line number Diff line change
Expand Up @@ -35,11 +35,13 @@ function center_of_mass(state::MechanismState, itr)
com = Point3D(frame, zero(SVector{3, T}))
mass = zero(T)
for body in itr
inertia = spatial_inertia(body)
if inertia.mass > 0
bodycom = transform_to_root(state, body, false) * center_of_mass(inertia)
com += inertia.mass * FreeVector3D(bodycom)
mass += inertia.mass
if body.inertia !== nothing
inertia = spatial_inertia(body)
if inertia.mass > 0
bodycom = transform_to_root(state, body, false) * center_of_mass(inertia)
com += inertia.mass * FreeVector3D(bodycom)
mass += inertia.mass
end
end
end
com /= mass
Expand All @@ -51,7 +53,7 @@ $(SIGNATURES)
Compute the center of mass of the whole `Mechanism` in the given state.
"""
center_of_mass(state::MechanismState) = center_of_mass(state, non_root_bodies(state.mechanism))
center_of_mass(state::MechanismState) = center_of_mass(state, bodies(state.mechanism))

const geometric_jacobian_doc = """Compute a geometric Jacobian (also known as a
basic, or spatial Jacobian) associated with a directed path in the `Mechanism`'s
Expand Down
4 changes: 3 additions & 1 deletion test/test_mechanism_algorithms.jl
Original file line number Diff line number Diff line change
Expand Up @@ -301,7 +301,9 @@ end
@test_throws ArgumentError point_jacobian!(J_point, x, p, transform(x, point, default_frame(base)))
end
point_jacobian!(J_point, x, p, point)
@test @allocated(point_jacobian!(J_point, x, p, point)) == 0
let x = x
@test @allocated(point_jacobian!(J_point, x, p, point)) == 0
end
J = geometric_jacobian(x, p)
T = Twist(J, velocity(x))
point_in_world = transform(x, point, root_frame(mechanism))
Expand Down
2 changes: 1 addition & 1 deletion test/test_spatial.jl
Original file line number Diff line number Diff line change
Expand Up @@ -205,7 +205,7 @@ end

@testset "log / exp" begin
hat = RigidBodyDynamics.Spatial.hat
srand(1) # TODO: https://github.com/JuliaRobotics/RigidBodyDynamics.jl/issues/135
Random.seed!(1) # TODO: https://github.com/JuliaRobotics/RigidBodyDynamics.jl/issues/135
for θ in [LinRange(0., 10 * eps(), 100);
LinRange(0., π - eps(), 100)]
# have magnitude of parts of twist be bounded by θ to check for numerical issues
Expand Down

0 comments on commit 163aa89

Please sign in to comment.