rdeits / MeshCat.jl

WebGL-based 3D visualizer in Julia
MIT License
233 stars 42 forks source link

LineString Support for visualizing Trajectories #202

Closed MAminSFV closed 3 years ago

MAminSFV commented 3 years ago

Thank you for your amazing work.

I think a critical feature is to be able to visualize trajectories of robots and tracking frames.

I suggest adding support of the LineString primitive from GeometryBasics.jl will help using that functionality in other packages like MeshCatMechanism.jl and RigidBodySim.jl.

I appreciate your work and would like your input on this. ( @rdeits , @tkoolen )

Many Thanks.

ferrolho commented 3 years ago

Are you looking for something like this? E.g., the yellow circle path shown here?

MAminSFV commented 3 years ago

Yes, exactly. I was hoping to find the same functionality both in the loop and once the simulation is done. I see that PointCloud geometry is used. That is something that I was looking for.

Is there also the possibility to draw the trajectory in real-time? I think that is the part that might take a little bit of work on the MeshCat side of things. Or maybe by appending new points to the pointcloud array for every animation frame and then resetting that object. What do you think?

Thank you for sharing this example and TORA.jl. I will take a deeper look into this package.

ferrolho commented 3 years ago

Hi, @MAminSFV. You can update the object repeatedly with the setobject! method. You don't have to use TORA.jl to achieve this. Just add a function to your project similar to the one below, and call it whenever you want to update the points that make up the path you want to show.

function display_path(vis::Visualizer, path_points::Matrix{Float64};
                      color=colorant"yellow", linewidth=2.0, objname="my_path")
    points = collect(eachcol(path_points))
    material = LineBasicMaterial(color=color, linewidth=linewidth)
    setobject!(vis[objname], Object(PointCloud(points), material, "Line"))
    nothing
end
MAminSFV commented 3 years ago

Thank you for your help!

I will try this out in my project.