Skip to content

Commit

Permalink
MTKstdlib 2 and JSComp
Browse files Browse the repository at this point in the history
  • Loading branch information
baggepinnen committed Sep 28, 2023
1 parent d6d4445 commit 1d22777
Show file tree
Hide file tree
Showing 8 changed files with 12 additions and 14 deletions.
2 changes: 1 addition & 1 deletion docs/src/examples/free_motion.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ This example demonstrates how a free-floating [`Body`](@ref) can be simulated. T
using Multibody
using ModelingToolkit
using Plots
using SymbolicIR
using JuliaSimCompiler
using OrdinaryDiffEq
t = Multibody.t
Expand Down
2 changes: 1 addition & 1 deletion docs/src/examples/gearbox.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ The [`GearConstraint`](@ref) has two rotational axes which do not have to be par
using Multibody
using ModelingToolkit
using Plots
using SymbolicIR
using JuliaSimCompiler
using OrdinaryDiffEq
t = Multibody.t
Expand Down
7 changes: 3 additions & 4 deletions docs/src/examples/pendulum.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ This beginners tutorial will model a pendulum pivoted around the origin in the w
To start, we load the required packages
```@example pendulum
using ModelingToolkit
using Multibody, SymbolicIR
using Multibody, JuliaSimCompiler
using OrdinaryDiffEq # Contains the ODE solver we will use
using Plots
```
Expand Down Expand Up @@ -94,8 +94,8 @@ A mass suspended in a spring can be though of as a linear pendulum (often referr
![Spring with mass](https://doc.modelica.org/Modelica%203.2.3/Resources/Images/Mechanics/MultiBody/Examples/Elementary/SpringWithMass.png)

```@example pendulum
@named damper = Translational.Damper(0.5)
@named spring = Translational.Spring(1)
@named damper = Translational.Damper(d=0.5)
@named spring = Translational.Spring(c=1)
@named joint = Prismatic(n = [0, 1, 0], isroot = true, useAxisFlange = true)
connections = [connect(world.frame_b, joint.frame_a)
Expand All @@ -117,7 +117,6 @@ As is hopefully evident from the little code snippet above, this linear pendulum
### Why do we need a joint?
In the example above, we introduced a prismatic joint to model the oscillating motion of the mass-spring system. In reality, we can suspend a mass in a spring without any joint, so why do we need one here? The answer is that we do not, in fact, need the joint, but if we connect the spring directly to the world, we need to make the body (mass) the root object of the kinematic tree instead:
```@example pendulum
using SymbolicIR
@named root_body = Body(; m = 1, isroot = true, r_cm = [0, 1, 0], phi0 = [0, 1, 0])
@named multibody_spring = Multibody.Spring(c=1)
Expand Down
1 change: 0 additions & 1 deletion docs/src/examples/sensors.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ The example below adds a force and a torque sensor to the pivot point of a pendu
using Multibody
using ModelingToolkit
using Plots
using SymbolicIR
using OrdinaryDiffEq
using LinearAlgebra
Expand Down
2 changes: 1 addition & 1 deletion docs/src/examples/spherical_pendulum.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ This example models a spherical pendulum. The pivot point is modeled using a [`S
using Multibody
using ModelingToolkit
using Plots
using SymbolicIR
using JuliaSimCompiler
using OrdinaryDiffEq
t = Multibody.t
Expand Down
2 changes: 1 addition & 1 deletion docs/src/examples/three_springs.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ The example connects three springs together in a single point. The springs are a
using Multibody
using ModelingToolkit
using Plots
using SymbolicIR
using JuliaSimCompiler
using OrdinaryDiffEq
t = Multibody.t
Expand Down
2 changes: 1 addition & 1 deletion src/Multibody.jl
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ module Multibody

using LinearAlgebra
using ModelingToolkit
using SymbolicIR
using JuliaSimCompiler
import ModelingToolkitStandardLibrary.Mechanical.Rotational
import ModelingToolkitStandardLibrary.Mechanical.TranslationalModelica as Translational

Expand Down
8 changes: 4 additions & 4 deletions test/runtests.jl
Original file line number Diff line number Diff line change
Expand Up @@ -269,7 +269,7 @@ connections = [connect(damper1.flange_b, rev1.axis)
damper2,
])
modele = ModelingToolkit.expand_connections(model)
ssys = structural_simplify(model, allow_parameter = false)
# ssys = structural_simplify(model, allow_parameter = false)

irsys = IRSystem(modele)
ssys = structural_simplify(irsys, alias_eliminate = false)
Expand All @@ -294,8 +294,8 @@ isinteractive() &&
## Linear mass-spring-damper ===================================================
# ==============================================================================

@named damper = Translational.Damper(0.5)
@named spring = Translational.Spring(1)
@named damper = Translational.Damper(d=0.5)
@named spring = Translational.Spring(c=1)
@named joint = Prismatic(n = [0, 1, 0], isroot = true, useAxisFlange = true)

connections = [connect(world.frame_b, joint.frame_a)
Expand Down Expand Up @@ -433,7 +433,7 @@ equation
connect(spring2.frame_a, spring1.frame_b);
end ThreeSprings;
=#

##
using Multibody
using ModelingToolkit
using JuliaSimCompiler
Expand Down

0 comments on commit 1d22777

Please sign in to comment.