Best way to plot an arrow in a MeshCatMechanisms visualizer?

I’d like to get a result similar to the force plotting done in this issue: Body wrench from forces applied at different points · Issue #589 · JuliaRobotics/RigidBodyDynamics.jl · GitHub. Unfortunately, the code for the actual visualization is not posted, so I’m trying to figure out how it was done.

I’ve been trying to use ArrowVisualizer from MeshCatMechanisms.jl:

using MeshCatMechanisms
using RigidBodyDynamics
using MeshCat
using GeometryBasics

vis = Visualizer()
render(vis)

mechanism = parse_urdf(urdf_file)

delete!(vis)

visuals = URDFVisuals(urdf_file)
mvis = MechanismVisualizer(mechanism, URDFVisuals(urdf_file), vis)

arrow_vis = ArrowVisualizer(vis)
setobject!(arrow_vis)
settransform!(arrow_vis, Point(0.0, 0.0, 0.0), Vec(0.5, 0.5, 0.0))

Without the last line, the robot arm is situated correctly on its axis, but there’s no arrow:

arm_no_arrow

But, after setting the transform, the arm AND the arrow are transformed.

arm_with_arrow

It seems like I’m transforming both the “meshcat” visualization and the “arrow” visualization, possibly because they’re both linked to “vis”. Is there a way to transform just one? Or a better way to draw arrows or move this visualizer? Thanks in advance for any help.

1 Like

My gues is to write your own function with

shaft = Cylinder(zero(Point{3, Float64}), Point(0.0, 0.0, 10.0), 0.1)
setobject!(vis, shaft)

and the cone. It seems that the actual implementation ```
settransform!(arrow_vis, Point(0.0, 0.0, 0.0), Vec(0.5, 0.5, 0.0))

similar question: Simple line and arrows · Issue #217 · rdeits/MeshCat.jl · GitHub