Skip to content

Commit 3e615f4

Browse files
committed
tweak rope and chain appearance
1 parent 96fa1d0 commit 3e615f4

File tree

2 files changed

+16
-15
lines changed

2 files changed

+16
-15
lines changed

docs/src/examples/ropes_and_cables.md

Lines changed: 7 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ t = Multibody.t
2222
2323
world = Multibody.world
2424
number_of_links = 6
25-
@named rope = Rope(l = 1, m = 1, n=number_of_links, c=0, d=0, air_resistance=0, d_joint=1, radius=0.03, color=[0.5, 0.4, 0.4, 1])
25+
@named rope = Rope(l = 1, m = 1, n=number_of_links, c=0, d=0, air_resistance=0, d_joint=1, radius=0.03, color=[0.5, 0.4, 0.4, 1], dir=[0.05, 1, 0])
2626
@named body = Body(; m = 1, radius=0.2)
2727
2828
connections = [connect(world.frame_b, rope.frame_a)
@@ -31,11 +31,8 @@ connections = [connect(world.frame_b, rope.frame_a)
3131
@named stiff_rope = ODESystem(connections, t, systems = [world, body, rope])
3232
3333
ssys = structural_simplify(IRSystem(stiff_rope))
34-
prob = ODEProblem(ssys, [
35-
collect(body.r_0) .=> [1,1,1];
36-
collect(body.w_a) .=> [1,1,1]
37-
], (0, 5))
38-
sol = solve(prob, Rodas4(autodiff=false); u0 = prob.u0 .+ 0.1);
34+
prob = ODEProblem(ssys, [], (0, 5))
35+
sol = solve(prob, Rodas4(autodiff=false))
3936
@test SciMLBase.successful_retcode(sol)
4037
4138
import CairoMakie
@@ -48,7 +45,7 @@ Next up we model an elastic rope, we do this by setting `c > 0`. We also introdu
4845
```@example ropes_and_cables
4946
world = Multibody.world
5047
number_of_links = 6
51-
@named rope = Rope(l = 1, m = 5, n=number_of_links, c=800.0, d=0.01, d_joint=0.1, air_resistance=0.2)
48+
@named rope = Rope(l = 1, m = 5, n=number_of_links, c=800.0, d=0.01, d_joint=0.1, air_resistance=0.2, dir=[0.2, 1, 0])
5249
@named body = Body(; m = 300, radius=0.2)
5350
5451
connections = [connect(world.frame_b, rope.frame_a)
@@ -57,12 +54,8 @@ connections = [connect(world.frame_b, rope.frame_a)
5754
@named flexible_rope = ODESystem(connections, t, systems = [world, body, rope])
5855
5956
ssys = structural_simplify(IRSystem(flexible_rope))
60-
prob = ODEProblem(ssys, [
61-
collect(body.r_0) .=> [1,1,1];
62-
collect(body.w_a) .=> [1,1,1];
63-
collect(body.v_0) .=> [10,10,10]
64-
], (0, 8))
65-
sol = solve(prob, Rodas4(autodiff=false); u0 = prob.u0 .+ 0.5);
57+
prob = ODEProblem(ssys, [], (0, 8))
58+
sol = solve(prob, Rodas4(autodiff=false));
6659
@test SciMLBase.successful_retcode(sol)
6760
6861
Multibody.render(flexible_rope, sol, y = -3, x = -6, z = -6, lookat=[0, -3, 0], filename = "flexible_rope.gif") # May take long time for n>=10
@@ -73,7 +66,7 @@ Multibody.render(flexible_rope, sol, y = -3, x = -6, z = -6, lookat=[0, -3, 0],
7366

7467

7568
## A chain suspended in two points
76-
When a [`Rope`](@ref) component is used to model a chain that is suspended between two fixed points, a kinematic loop (kinematic chain) is formed. To break this loop, we introduce a spring in one end.
69+
When a [`Rope`](@ref) component is used to model a chain that is suspended between two fixed points, a kinematic loop is formed. To break this loop, we introduce a spring in one end.
7770

7871
```@example ropes_and_cables
7972
number_of_links = 8

src/components.jl

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -414,8 +414,14 @@ There are three different methods of adding damping to the rope:
414414
- Damping in the stretching direction of the rope, controlled by the parameter `d`.
415415
- Damping in flexing of the rope, modeled as viscous friction in the joints between the links, controlled by the parameter `d_joint`.
416416
- Air resistance to the rope moving through the air, controlled by the parameter `air_resistance`. This damping is quadratic in the velocity (``f_d ~ -||v||v``) of each link relative to the world frame.
417+
418+
## Rendering
419+
- `color = [255, 219, 120, 255]./255`
420+
- `radius = 0.05f0`
421+
- `jointradius=0`
422+
- `jointcolor=color`
417423
"""
418-
function Rope(; name, l = 1, dir = [0,-1, 0], n = 10, m = 1, c = 0, d=0, air_resistance=0, d_joint = 0, cutspherical = false, cutprismatic=false, color = [255, 219, 120, 255]./255, radius = 0.05f0, kwargs...)
424+
function Rope(; name, l = 1, dir = [0,-1, 0], n = 10, m = 1, c = 0, d=0, air_resistance=0, d_joint = 0, cutspherical = false, cutprismatic=false, color = [255, 219, 120, 255]./255, radius = 0.05f0, jointradius=0, jointcolor=color, kwargs...)
419425

420426
@assert n >= 1
421427
systems = @named begin
@@ -433,6 +439,8 @@ function Rope(; name, l = 1, dir = [0,-1, 0], n = 10, m = 1, c = 0, d=0, air_res
433439
iscut = cutspherical && i == 1,
434440
# state=!(cutspherical && i == 1),
435441
state=true,
442+
color=jointcolor,
443+
radius=jointradius,
436444
d = d_joint) for i = 1:n+1]
437445

438446
eqs = [

0 commit comments

Comments
 (0)