Skip to content

Commit a74e967

Browse files
committed
Fixes, add RectifiedSpring/RELUSpring to docs, remove from compliant_path_following.jl example. Fix URDF parsing mesh scaling.
1 parent 90ccc6c commit a74e967

File tree

5 files changed

+33
-6
lines changed

5 files changed

+33
-6
lines changed

docs/src/api/api.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -162,6 +162,7 @@ VMRobotControl.Storage
162162
LinearSpring
163163
TanhSpring
164164
GaussianSpring
165+
RectifiedSpring
165166
GravityCompensator
166167
ForceSource
167168
PowerSource

examples/compliant_path_following.jl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -128,8 +128,8 @@ add_component!(vm, LinearDamper(100.0, "CartPosition"); id="CartDamper");
128128
# the force will be reduced to ensure that the power does not exceed 10W.
129129
vms = VirtualMechanismSystem("System", robot, vm)
130130
err_coord = CoordDifference(".virtual_mechanism.CartPosition", ".robot.TCP")
131-
err_spring = LinearSpring(3000.0 * identity(3), "CartError")
132-
err_damper = LinearDamper(50.0 * identity(3), "CartError")
131+
err_spring = LinearSpring(3000.0, "CartError")
132+
err_damper = LinearDamper(50.0, "CartError")
133133

134134
add_coordinate!(vms, err_coord; id="CartError")
135135
add_component!(vms, err_spring; id="CartErrSpring")

src/components/storages.jl

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -300,7 +300,18 @@ end
300300
############################
301301
# ReLUSpring
302302
############################
303+
"""
304+
RectifiedSpring(stiffness, coord, flipped::Bool)
305+
ReLUSpring(stiffness, coord, flipped::Bool)
306+
307+
A linear spring which acts only when the coordinate is positive (flipped=false) or negative
308+
(flipped=true).
303309
310+
Check implementation details if applying to any coordinate larger than 1D, to ensure
311+
behaviour is as expected.
312+
313+
See also [`add_deadzone_springs`](@ref).
314+
"""
304315
@kwdef struct RectifiedSpring{T<:Real, K, C} <: Storage{T}
305316
stiffness::K
306317
coord::C

src/mesh_utils.jl

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,19 @@ end
66

77
transform_mesh(mesh, tf::Nothing) = mesh
88

9-
function rescale_mesh(mesh, scale)
9+
10+
function rescale_geometry(geom, scale)
11+
if typeof(geom) <: GeometryBasics.Mesh
12+
return rescale_mesh(geom, scale)
13+
elseif typeof(geom) <: Vector{<:Tuple{<:GeometryBasics.Mesh, <:Any}}
14+
return [(rescale_mesh(mesh, scale), kwargs) for (mesh, kwargs) in geom]
15+
else
16+
error("Unsupported geometry type: $(typeof(geom))")
17+
end
18+
end
19+
20+
21+
function rescale_mesh(mesh::GeometryBasics.Mesh, scale)
1022
c, f = GeometryBasics.coordinates(mesh), GeometryBasics.faces(mesh)
1123
if prod(scale)< 0
1224
# If scaling will turn the mesh inside out, then reverse the chirality of the faces by

src/urdf/parse_urdf.jl

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -150,7 +150,8 @@ function parse_link!(mechanism, link, cfg)
150150
end
151151

152152
function parse_inertial!(mechanism, inertial, link_frame, cfg)
153-
transform = nothing
153+
# Default to no transform
154+
transform = zero(Transform{cfg.element_type})
154155
mass = nothing
155156
inertia = nothing
156157
for node in eachelement(inertial)
@@ -287,11 +288,13 @@ function parse_geometry(geometry_node, cfg)
287288
geom = Sphere3{Float64}(SVector(0, 0, 0), r)
288289
elseif nn == "mesh"
289290
filename = node["filename"]
290-
geom = load_mesh(filename, cfg)
291+
geom = load_mesh(filename, cfg)
292+
# This will either be a mesh, or vector of tuples containing mesh and kwargs for
293+
# visual properties
291294
if haskey(node, "scale")
292295
scale_vec = parse_3vec(node["scale"], cfg)
293296
scale = GeometryBasics.Point{3, Float64}(scale_vec...)
294-
geom = VMRobotControl.rescale_mesh(geom, scale)
297+
geom = VMRobotControl.rescale_geometry(geom, scale)
295298
end
296299
else
297300
raise_not_recognized(nn, cfg)

0 commit comments

Comments
 (0)