Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Switch to using MeshCat.MeshFileGeometry and MechanismGeometries.MeshFile. #32

Merged
merged 5 commits into from
Jul 12, 2019
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
7 changes: 4 additions & 3 deletions Project.toml
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,8 @@ GeometryTypes = "≥ 0.4.0"
InteractBase = "≥ 0.8.0"
Interpolations = "≥ 0.9.0"
LoopThrottle = "≥ 0.0.1"
MechanismGeometries = "≥ 0.2.0"
MeshCat = "≥ 0.6.0"
MechanismGeometries = "≥ 0.4.0"
MeshCat = "≥ 0.7.0"
NBInclude = "≥ 1.1.0"
OrderedCollections = "≥ 1.0.0"
RigidBodyDynamics = "2"
Expand All @@ -33,9 +33,10 @@ julia = "1"
Blink = "ad839575-38b3-5650-b840-f874b8c74a25"
NBInclude = "0db19996-df87-5ea3-a455-e3a50d440464"
Pkg = "44cfe95a-1eb2-52ea-b672-e2afdf69b78f"
Random = "9a3f8284-a2c9-5f02-9a11-845980a1fd5c"
StaticArrays = "90137ffa-7385-5640-81b9-e52037218182"
Test = "8dfed614-e22c-5e08-85e1-65c5234f0b40"
ValkyrieRobot = "c74b26e8-f247-5d24-b013-c11a2bbd97c6"

[targets]
test = ["StaticArrays", "Pkg", "NBInclude", "Test", "Blink", "ValkyrieRobot"]
test = ["StaticArrays", "Pkg", "NBInclude", "Test", "Blink", "ValkyrieRobot", "Random"]
2 changes: 1 addition & 1 deletion src/MeshCatMechanisms.jl
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ const rbd = RigidBodyDynamics
using RigidBodyDynamics.Graphs: ancestors, edge_to_parent, source, vertices, root
using Interpolations: interpolate, Gridded, Linear
using LoopThrottle: @throttle
using MechanismGeometries: visual_elements, VisualElement, Skeleton, URDFVisuals, AbstractGeometrySource
using MechanismGeometries: visual_elements, VisualElement, Skeleton, URDFVisuals, AbstractGeometrySource, MeshFile
using GeometryTypes: HyperSphere, Point

include("visualizer.jl")
Expand Down
20 changes: 16 additions & 4 deletions src/visualizer.jl
Original file line number Diff line number Diff line change
Expand Up @@ -79,29 +79,41 @@ end

Attach the given geometry to the visualizer at the given frame, using its default material.
"""
setelement!(mvis::MechanismVisualizer, frame::CartesianFrame3D, geometry::GeometryLike, name::AbstractString="<element>") = setelement!(mvis, frame, Object(geometry), name)
function setelement!(mvis::MechanismVisualizer, frame::CartesianFrame3D, geometry::GeometryLike, name::AbstractString="<element>")
setelement!(mvis, frame, Object(geometry), name)
end

"""
setelement!(mvis::MechanismVisualizer, frame::CartesianFrame3D, geometry::GeometryLike, material::AbstractMaterial, name::AbstractString="<element>")

Construct an object with the given geometry and material and attach it to the visualizer
"""
setelement!(mvis::MechanismVisualizer, frame::CartesianFrame3D, geometry::GeometryLike, material::AbstractMaterial, name::AbstractString="<element>") = setelement!(mvis, frame, Object(geometry, material), name)
function setelement!(mvis::MechanismVisualizer, frame::CartesianFrame3D, geometry::GeometryLike, material::AbstractMaterial, name::AbstractString="<element>")
setelement!(mvis, frame, Object(geometry, material), name)
end

function setelement!(mvis::MechanismVisualizer, frame::CartesianFrame3D, geometry::MeshFile, args...)
setelement!(mvis, frame, MeshFileGeometry(geometry.filename), args...)
end

# Special cases for visualizing frames and points
"""
setelement!(mvis::MechanismVisualizer, frame::CartesianFrame3D, scale::Real=0.5, name::AbstractString="<element>")

Add a Triad geometry with the given scale to the visualizer at the specified frame
"""
setelement!(mvis::MechanismVisualizer, frame::CartesianFrame3D, scale::Real=0.5, name::AbstractString="<element>") = setelement!(mvis, frame, Triad(scale), name)
function setelement!(mvis::MechanismVisualizer, frame::CartesianFrame3D, scale::Real=0.5, name::AbstractString="<element>")
setelement!(mvis, frame, Triad(scale), name)
end

"""
setelement!(mvis::MechanismVisualizer, point::Point3D, radius::Real=0.05, name::AbstractString="<element>")

Add a HyperSphere geometry with the given radius to the visualizer at the given point
"""
setelement!(mvis::MechanismVisualizer, point::Point3D, radius::Real=0.05, name::AbstractString="<element>") = setelement!(mvis, point.frame, HyperSphere(Point(point.v[1], point.v[2], point.v[3]), convert(eltype(point.v), radius)), name)
function setelement!(mvis::MechanismVisualizer, point::Point3D, radius::Real=0.05, name::AbstractString="<element>")
setelement!(mvis, point.frame, HyperSphere(Point(point.v[1], point.v[2], point.v[3]), convert(eltype(point.v), radius)), name)
end

function _path(mechanism, body)
body_ancestors = ancestors(body, mechanism.tree)
Expand Down