Skip to content

Commit e6a0431

Browse files
authored
Merge pull request #116 from ModiaSim/hidden_states
Object3D that is fixed or freely moving with respect to parent and other improvements.
2 parents 0327746 + 1db3c36 commit e6a0431

File tree

76 files changed

+2233
-1475
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

76 files changed

+2233
-1475
lines changed

.github/workflows/test.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ jobs:
1414
fail-fast: false
1515
matrix:
1616
version:
17-
- '1.7.2'
17+
- '1.7.3'
1818
os:
1919
- ubuntu-latest
2020
- windows-latest

Manifest.toml

Lines changed: 248 additions & 219 deletions
Large diffs are not rendered by default.

Project.toml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
authors = ["Andrea Neumayr <andrea.neumayr@dlr.de>", "Martin Otter <Martin.Otter@dlr.de>", "Gerhard Hippmann <gerhard.hippmann@dlr.de>"]
22
name = "Modia3D"
33
uuid = "07f2c1e0-90b0-56cf-bda7-b44b56e34eed"
4-
version = "0.10.4"
4+
version = "0.11.0"
55

66
[compat]
77
Colors = "0.12, 0.11, 0.10"
@@ -12,7 +12,7 @@ HTTP = "0.9"
1212
JSON = "0.21"
1313
Measurements = "2"
1414
MeshIO = "0.4.10"
15-
Modia = "0.8.3"
15+
Modia = "0.9.1"
1616
MonteCarloMeasurements = "1"
1717
OrderedCollections = "1"
1818
Reexport = "1.0"

README.md

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ Note, Modia3D reexports the following definitions
2929
- `using Modia`
3030
- `using Unitful`
3131
- `using DifferentialEquations`
32+
- `using SignalTables`
3233
- and exports functions `CVODE_BDF` and `IDA` of [Sundials.jl](https://github.com/SciML/Sundials.jl).
3334

3435
As a result, it is usually sufficient to have `using Modia3D` in a model to utilize the relevant
@@ -57,7 +58,8 @@ Modia3D has various *3D animation features*:
5758

5859
## Faster Startup
5960

60-
In order to speed up startup, it is adviced to generate a sysimage by executing the following commands:
61+
In order to speed up startup, a sysimage can be generated by executing the following commands
62+
(may take several minutes):
6163

6264
```julia
6365
julia
@@ -66,7 +68,7 @@ include("$(Modia3D.path)/create_Modia3D_sysimage.jl")
6668
exit()
6769
```
6870

69-
This will include a file `Modia3D_sysimage.dll` (on Windows) or `Modia3D_sysimage.so` (otherwise) in your
71+
This will generate a file `Modia3D_sysimage.dll` (on Windows) or `Modia3D_sysimage.so` (otherwise) in your
7072
current working directory that includes all packages of your current project and the following packages
7173
(these packages are added to your current project, if not yet included):
7274

@@ -79,6 +81,10 @@ julia -JModia3D_sysimage.dll (on Windows)
7981
julia -JModia3D_sysimage.so (otherwise)
8082
```
8183

84+
The benefit is that `using Modia3D` is nearly immediatedly executed (instead of > 30 seconds).
85+
The drawback is that `create_Modia3D_sysimage.jl` has to be newly executed, whenever
86+
new package versions are used in your environment.
87+
8288
## Main Developers and License
8389

8490
[Andrea Neumayr](mailto:andrea.neumayr@dlr.de),

create_Modia3D_sysimage.jl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
# to generate a sysimage of your current project and store it in your current working directory.
1010
# Before generating the sysimage, the following packages are added to your current project (if not yet included):
1111
#
12-
# Modia, Modia3D, ModiaPlot_PyPlot, PackageCompiler, Revise
12+
# Modia, Modia3D, SignalTablesInterface_PyPlot, PackageCompiler, Revise
1313
#
1414
module Create_Modia3D_sysimage
1515

@@ -21,7 +21,7 @@ import Pkg
2121
project = Pkg.project()
2222
projectPath = project.path
2323
availablePackages = keys(project.dependencies)
24-
addPackages = setdiff!(["Modia", "Modia3D", "ModiaPlot_PyPlot", "PackageCompiler", "Revise"], availablePackages)
24+
addPackages = setdiff!(["Modia", "Modia3D", "SignalTablesInterface_PyPlot", "PackageCompiler", "Revise"], availablePackages)
2525
println("!!! Creating sysimage for Modia3D (executing: $file)")
2626
println("!!! This will include all packages from project $projectPath")
2727
if length(addPackages) > 0

docs/make.jl

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ makedocs(
2222
"Components/GravityField.md"
2323
"Components/ForceElements.md"
2424
],
25+
"Functions" => "Functions.md",
2526
"Internal" => [
2627
"internal/Profiling.md"
2728
"internal/DynamicDispatch.md"
362 Bytes
Loading

docs/src/Components/Joints.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,9 @@ Prismatic
1919

2020

2121

22-
## FreeMotion
22+
## FreeMotion (deprecated)
23+
24+
Do no longer use FreeMotion joints, but instead use [`Object3D`](@ref) with `fixedToParent=false`.
2325

2426
```@docs
2527
FreeMotion

docs/src/Functions.md

Lines changed: 137 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,137 @@
1+
# Functions
2+
3+
```@meta
4+
CurrentModule = Modia3D
5+
```
6+
7+
## 3D Vectors
8+
9+
Functions to construct 3D vectors `v::SVector{3,F}`.
10+
11+
```@docs
12+
ZeroVector3D
13+
axisValue
14+
```
15+
16+
## Rotation Matrices
17+
18+
Functions to construct rotation matrices `R::SMatrix{3,3,F,9}` rotating a
19+
coordinate-system/frame 1 into a coordinate-system/frame 2.
20+
21+
| Function | Description |
22+
|:-------------------------------------------------|:---------------------------------------------------|
23+
| [`Modia3D.NullRotation`](@ref)(::Type{F}) | No rotation from frame 1 to frame 2 |
24+
| [`Modia3D.assertRotationMatrix`](@ref)(R) | Assert that R is a rotation matrix |
25+
| [`Modia3D.rot1`](@ref)(angle) | Rotate around `angle` along x-axis |
26+
| [`Modia3D.rot2`](@ref)(angle) | Rotate around `angle` along y-axis |
27+
| [`Modia3D.rot3`](@ref)(angle) | Rotate around `angle` along z-axis |
28+
| [`Modia3D.rot123`](@ref)(angle1, angle2, angle3) | Rotate around angles along x,y,z-axes |
29+
| [`Modia3D.rot123`](@ref)(angles) | Rotate around angles along x,y,z-axes |
30+
| [`Modia3D.rotAxis`](@ref)(axis,angle) | Rotate around `angle` along `axis` (= 1,2,3) |
31+
| [`Modia3D.rotAxis`](@ref)(axis,positive,angle) | Rotate around `angle` if `positive`, else `-angle` |
32+
| [`Modia3D.rot_e`](@ref)(e, angle) | Rotate around `angle` along unit vector `e` |
33+
| [`Modia3D.rot_nxy`](@ref)(nx, ny) | `nx`/`ny` are in x/y-direction of frame 2 |
34+
| [`Modia3D.from_q`](@ref)(q) | Return rotation matrix from quaternion `q` |
35+
36+
37+
Examples
38+
39+
```julia
40+
using Modia3D
41+
42+
# R1,R2,R3 are the same RotationMatrices
43+
R1 = Modia3D.rot1(pi/2)
44+
R2 = Modia3D.rot1(90u"°")
45+
R3 = Modia3D.rot_e([1,0,0], pi/2)
46+
```
47+
48+
```@docs
49+
NullRotation
50+
assertRotationMatrix
51+
rot1
52+
rot2
53+
rot3
54+
rot123
55+
rotAxis
56+
rot_e
57+
rot_nxy
58+
from_q
59+
```
60+
61+
## Quaternions
62+
63+
Functions to construct quaternions `q::SVector{4,F}` rotating a
64+
coordinate-system/frame 1 into a coordinate-system/frame 2.
65+
66+
| Function | Description |
67+
|:--------------------------------------------------|:-------------------------------------------|
68+
| [`Modia3D.NullQuaternion`](@ref)(::Type{F}) | No rotation from frame 1 to frame 2 |
69+
| [`Modia3D.assertQuaternion`](@ref)(q) | Assert that q is a quaternion |
70+
| [`Modia3D.qrot1`](@ref)(angle) | Rotate around `angle` along x-axis |
71+
| [`Modia3D.qrot2`](@ref)(angle) | Rotate around `angle` along y-axis |
72+
| [`Modia3D.qrot3`](@ref)(angle) | Rotate around `angle` along z-axis |
73+
| [`Modia3D.qrot123`](@ref)(angle1, angle2, angle3) | Rotate around angles along x,y,z-axes |
74+
| [`Modia3D.qrot_e`](@ref)(e, angle) | Rotate around `angle` along unit vector `e`|
75+
| [`Modia3D.qrot_nxy`](@ref)(nx, ny) | `nx`/`ny` are in x/y-direction of frame 2 |
76+
| [`Modia3D.from_R`](@ref)(R) | Return `q` from rotation matrix `R` |
77+
78+
79+
```@docs
80+
NullQuaternion
81+
assertQuaternion
82+
qrot1
83+
qrot2
84+
qrot3
85+
qrot123
86+
qrot_e
87+
qrot_nxy
88+
from_R
89+
```
90+
91+
## Frame Transformations
92+
93+
Functions to transform vectors, rotation matrices, quaternions between coordinate systems
94+
and functions to determine properties from coordinate system transformations.
95+
96+
| Function | Description |
97+
|:-------------------------------------------------|:----------------------------------------------|
98+
| [`Modia3D.resolve1`](@ref)(rot, v2) | Transform vector `v` from frame 2 to frame 1 |
99+
| [`Modia3D.resolve2`](@ref)(rot, v1) | Transform vector `v` from frame 1 to frame 2 |
100+
| [`Modia3D.absoluteRotation`](@ref)(rot01, rot12) | Return rotation 0->2 from rot. 0->1 and 1->2 |
101+
| [`Modia3D.relativeRotation`](@ref)(rot01, rot02) | Return rotation 1->2 from rot. 0->1 and 0->2 |
102+
| [`Modia3D.inverseRotation`](@ref)(rot01) | Return rotation 1->0 from rot, 0->1 |
103+
| [`Modia3D.planarRotationAngle`](@ref)(e,v1,v2) | Return angle of planar rotation along `e` |
104+
| [`Modia3D.eAxis`](@ref)(axis) | Return unit vector `e` in direction of `axis` |
105+
| [`Modia3D.skew`](@ref)(v) | Return skew-symmetric matrix of vector v |
106+
107+
```@docs
108+
resolve1
109+
resolve2
110+
absoluteRotation
111+
relativeRotation
112+
inverseRotation
113+
planarRotationAngle
114+
eAxis
115+
skew
116+
```
117+
118+
## Frame Interpolations
119+
120+
Given a set of coordinate-systems/frames by a vector `r` of position vectors (to their origins) and
121+
and an optional vector `q` of Quaternions (of their absolute orientations), then
122+
the following functions interpolate linearly in these frames:
123+
124+
| Function | Description |
125+
|:------------------------------------------------|:-----------------------------------------------|
126+
| [`Modia3D.Path`](@ref)(r,q) | Return path defined by a vector of frames |
127+
| [`Modia3D.t_pathEnd`](@ref)(path) | Return path parameter `t_end` of last frame |
128+
| [`Modia3D.interpolate`](@ref)(path,t) | Return `(rt,qt)` of Path at path parameter `t` |
129+
| [`Modia3D.interpolate_r`](@ref)(path,t) | Return `rt` of Path at path parameter `t` |
130+
131+
132+
```@docs
133+
Path
134+
t_pathEnd
135+
interpolate
136+
interpolate_r
137+
```

docs/src/index.md

Lines changed: 55 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ Modia3D has various *3D animation features*:
5454

5555
## Faster Startup
5656

57-
In order to speed up startup, it is adviced to generate a sysimage by executing the following commands:
57+
In order to speed up startup a sysimage can be generated by executing the following commands:
5858

5959
```julia
6060
julia
@@ -67,7 +67,7 @@ This will include a file `Modia3D_sysimage.dll` (on Windows) or `Modia3D_sysimag
6767
current working directory that includes all packages of your current project and the following packages
6868
(these packages are added to your current project, if not yet included):
6969

70-
- Modia, Modia3D, ModiaPlot_PyPlot, PackageCompiler, Revise
70+
- Modia, Modia3D, SignalTablesInterface_PyPlot, PackageCompiler, Revise
7171

7272
Start julia with this sysimage in the following way:
7373

@@ -93,6 +93,59 @@ julia -JModia3D_sysimage.so (otherwise)
9393

9494
## Release Notes
9595

96+
97+
### Version 0.11.0
98+
99+
- Requires Modia 0.9.1 or later.
100+
101+
- Additional keyword arguments of Object3D: `Object3D(..., fixedInParent=true, velocity=[0.0, 0.0, 0.0], angularVelocity=[0.0, 0.0, 0.0])`,
102+
besides the existing `parent, translation, rotation, feature`. A freely moving Object3D is defined with
103+
`Object3D(..., fixedInParent=false, ...)`, where `velocity=.., angularVelocity=..`
104+
are the initial conditions (resolved in the parent frame). For more details, see [`Object3D`](@ref).\
105+
The states and other code for such Object3Ds are *not* part of the generated code
106+
(so compilation is faster, and the objects can be changed after code generation).
107+
108+
- The `FreeMotion` joints in all test models have been removed and replaced by Object3Ds with `fixedInParent=false`.
109+
A new test model test/Basic/FreeShaftAdaptiveRotSequenceWithFreeMotion.jl has been introduced with a `FreeMotion`
110+
joint, to still have one test for a `FreeMotion` joint.
111+
112+
- `Revolute(..)` and `Prismatic(..)` joints can define axis of rotation/translation optionally as vector, e.g., `axis = [1.0, 2.0, 3.0]`.
113+
114+
- New function `Modia3D.rot1(angle,v)` which is an efficient implementation of `Modia3D.rot1(angle)*v` where `rot1(angle)` returns
115+
a transformation matrix and `v` is a vector and `rot1(angle,v)` returns the product of the transformation matrix and a vector
116+
in an efficient way. Correspondingly, there are new functions
117+
`Modia3D.rot2(angle,v), Modia3D.rot3(angle,v), Modia3D.resolve1(rotation,v2), Modia3D.resolve2(rotation,v1)`.
118+
119+
- Simulation speed improved, if contact of FileMesh objects.
120+
121+
- contactPairMaterials.json updated with more material pairs (e.g. results in less warning messages for runtests).
122+
123+
- New file `Modia3D.create_Modia3D_sysimage.jl` to create a *sysimage*. Using this sysimage has the
124+
advantage that `using Modia3D` is nearly immediatedly executed (instead of > 30 seconds).
125+
For details, see README.md file.
126+
127+
- Internal: Timer included in Scene (scene.timer), so that a timer is more easily accessible for debugging.
128+
129+
- Internal: Cleanup and improvements of Modia3D/src/Frames.jl
130+
131+
132+
**Deprecated**
133+
134+
- Joint `FreeMotion` is **deprecated**. Use instead `Object3D(..., fixedInParent=false, ...)`.
135+
Note, Object3D has variables `translation, rotation, velocity, angularVelocity, rotationXYZ` instead of
136+
`r, rot, v, w, isrot123` of `FreeMotion`.
137+
Furthermore, `angularVelocity` is resolved in the parent `Object3D` whereas `w` in `FreeMotion(obj1=.., obj2=..., ..)` is resolved in
138+
`obj2` and not in `obj1`. This means in particular that the init/start value `FreeMotion(.., w=Var(start=w_start)...)` needs
139+
to be transformed in Object3D with `Object3D(..., fixedInParent=false, rotation=XXX, angularVelocity = Modia3D.resolve1(XXX,w_start))`
140+
and the results of `angularVelocity` will be different to `w` because resolved in different coordinate systems.
141+
142+
**Non-backwards compatible changes**
143+
144+
- Since Modia3D 0.11.0 is based on Modia 0.9.0, the non-backwards compatible changes of Modia have also an effect on Modia3D
145+
(for details, see the [release notes of Modia 0.9.0](https://github.com/ModiaSim/Modia.jl/releases/tag/v0.9.0)).
146+
Typically, this should give problems only in seldomly occuring corner cases.
147+
148+
96149
### Version 0.10.4
97150

98151
- Script `Modia3D/create_Modia3D_sysimage.jl` improved.

0 commit comments

Comments
 (0)