Skip to content

Commit 50ab484

Browse files
JacobAdamsenmelundJacob Hilmar Adamsen
authored
Tutorial 'How To Write AnyScript' Lesson 2 updates (#22)
* First attempt at moving snippets to sepearate files * Lesson 2 updates * Only test snippets * Alias pytest task to pytest in the test environment * Setup automatic testing on GitHub * run test on windows * Only run test if it is not a fork and add license secreets * Clean up dependencies between gh action jobs * Ensure new push cancels previous running workflows * Updated lesson 3 snippets --------- Co-authored-by: Morten Enemark Lund <mel@anybodytech.com> Co-authored-by: Jacob Hilmar Adamsen <jha@anybodytech.com>
1 parent b04f260 commit 50ab484

31 files changed

Lines changed: 2878 additions & 533 deletions

.github/workflows/build.yaml

Lines changed: 24 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,9 @@ on:
1010
workflow_dispatch:
1111

1212

13+
concurrency:
14+
group: ${{ github.workflow }}-${{ github.ref }}
15+
1316
jobs:
1417

1518
find-tag:
@@ -56,12 +59,32 @@ jobs:
5659
- run: pixi run sphinx-build -M linkcheck . _build -W --keep-going -a -q
5760
continue-on-error: true
5861

62+
test-latest:
63+
runs-on: windows-latest
64+
65+
steps:
66+
- uses: actions/checkout@v4
67+
with:
68+
fetch-depth: 0
5969

70+
- uses: prefix-dev/setup-pixi@v0.8.1
71+
with:
72+
cache: true
73+
cache-write: ${{ github.event_name == 'push' && github.ref_name == 'master' }}
74+
environments: test
75+
activate-environment: true
76+
77+
- name: Test Snippets
78+
if: ${{ !github.event.pull_request.head.repo.fork && github.repository == 'anybody/tutorials' }}
79+
run: pytest
80+
env:
81+
RLM_LICENSE: ${{ secrets.LICENSE_TEST_SERVER }}
82+
RLM_LICENSE_PASSWORD: ${{ secrets.LICENSE_TEST_SERVER_PASSWORD }}
6083

6184
build-latest:
6285

6386
runs-on: ubuntu-latest
64-
needs: [find-tag, link-check]
87+
needs: [link-check, test-latest]
6588

6689
steps:
6790
- uses: actions/checkout@v4

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,4 +3,5 @@ _build/
33
*.docx
44
*.pyc# pixi environments
55
.pixi
6+
__pycache__
67

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
// Todo: Write a small description of your model here
22

33
Main = {
4-
54
// The actual body model goes in this folder
65
AnyFolder ArmModel = {
76

@@ -10,17 +9,16 @@ Main = {
109

1110
// Todo: Add points for grounding of the model here
1211

13-
}; // Global reference frame
14-
15-
// Todo. Add the model elements such as
12+
};
13+
14+
// Todo: Add the model elements such as
1615
// segments, joints, and muscles here.
1716

18-
}; // ArmModel
19-
17+
};
2018
// The study: Operations to be performed on the model
2119
AnyBodyStudy ArmStudy = {
2220
AnyFolder &Model = .ArmModel;
2321
Gravity = {0.0, -9.81, 0.0};
2422
};
2523

26-
}; // Main
24+
};
Lines changed: 72 additions & 80 deletions
Original file line numberDiff line numberDiff line change
@@ -1,95 +1,87 @@
1-
// Todo: Write a small description of your model here
1+
// Todo: Write a small description of your model here
22

33
Main = {
4-
54
// The actual body model goes in this folder
65
AnyFolder ArmModel = {
7-
6+
87
// Global Reference Frame
98
AnyFixedRefFrame GlobalRef = {
10-
119
// Todo: Add points for grounding of the model here
1210

13-
}; // Global reference frame
14-
// Segments
15-
AnyFolder Segs = {
16-
AnySeg UpperArm =
17-
{
18-
r0 = {0.3, 0, 0};
19-
//rDot0 = {0, 0, 0};
20-
//Axes0 = {{0, 0, 0}, {0, 0, 0}, {0, 0, 0}};
21-
//omega0 = {0, 0, 0};
22-
Mass = 2;
23-
Jii = {0.001, 0.01, 0.01};
24-
//Jij = {0, 0, 0};
25-
//sCoM = {0, 0, 0};
26-
AnyDrawSeg drw = {};
27-
AnyRefNode ShoulderNode = {
28-
sRel = {-0.2,0,0};
29-
};
30-
AnyRefNode ElbowNode = {
31-
sRel = {0.2,0,0};
32-
};
33-
AnyRefNode DeltodeusA = {
34-
sRel = {-0.1,0,0.02};
35-
};
36-
AnyRefNode DeltodeusB = {
37-
sRel = {-0.1,0,-0.02};
38-
};
39-
AnyRefNode Brachialis = {
40-
sRel = {0.1,0,0.01};
41-
};
42-
AnyRefNode BicepsShort = {
43-
sRel = {-0.1,0,0.03};
44-
};
45-
AnyRefNode Brachioradialis = {
46-
sRel = {0.05,0,0.02};
47-
};
48-
AnyRefNode TricepsShort = {
49-
sRel = {-0.1,0,-0.01};
50-
};
51-
52-
}; //UpperArm
53-
AnySeg ForeArm = {
54-
r0 = {0, 0.3, 0};
55-
Axes0 =RotMat(-90*pi/180, z);
11+
}; // Global Reference Frame
5612

57-
Mass = 2.0;
58-
Jii = {0.001,0.01,0.01};
59-
AnyRefNode ElbowNode = {
60-
sRel = {-0.2,0,0};
61-
};
62-
AnyRefNode HandNode = {
63-
sRel = {0.2,0,0};
64-
};
65-
AnyRefNode Brachialis = {
66-
sRel = {-0.1,0,0.02};
67-
};
68-
AnyRefNode Brachioradialis = {
69-
sRel = {0.0,0,0.02};
70-
};
71-
AnyRefNode Biceps = {
72-
sRel = {-0.15,0,0.01};
73-
};
74-
AnyRefNode Triceps = {
75-
sRel = {-0.25,0,-0.05};
76-
};
77-
AnyDrawSeg DrwSeg = {};
78-
}; // ForeArm
79-
80-
}; // Segs folder
81-
82-
// Todo. Add the model elements such as
83-
// segments, joints, and muscles here.
13+
// Segments
14+
AnyFolder Segs = {
8415

85-
}; // ArmModel
86-
87-
// The study: Operations to be performed on the model
16+
//UpperArm
17+
AnySeg UpperArm = {
18+
r0 = {0.0, 0.3, 0.0};
19+
Axes0 = RotMat(-90*pi/180, z);
20+
Mass = 2;
21+
Jii = {0.001, 0.01, 0.01};
22+
AnyDrawSeg drw = {};
23+
AnyRefNode ShoulderNode = {
24+
sRel = {-0.2,0,0};
25+
};
26+
AnyRefNode ElbowNode = {
27+
sRel = {0.2,0,0};
28+
};
29+
AnyRefNode DeltodeusA = {
30+
sRel = {-0.1,0,0.02};
31+
};
32+
AnyRefNode DeltodeusB = {
33+
sRel = {-0.1,0,-0.02};
34+
};
35+
AnyRefNode Brachialis = {
36+
sRel = {0.1,0,0.01};
37+
};
38+
AnyRefNode BicepsShort = {
39+
sRel = {-0.1,0,0.03};
40+
};
41+
AnyRefNode Brachioradialis = {
42+
sRel = {0.05,0,0.02};
43+
};
44+
AnyRefNode TricepsShort = {
45+
sRel = {-0.1,0,-0.01};
46+
};
47+
}; //UpperArm
48+
49+
// ForeArm
50+
AnySeg ForeArm = {
51+
r0 = {0.3, 0.0, 0.0};
52+
Mass = 2.0;
53+
Jii = {0.001,0.01,0.01};
54+
AnyRefNode ElbowNode = {
55+
sRel = {-0.2,0,0};
56+
};
57+
AnyRefNode HandNode = {
58+
sRel = {0.2,0,0};
59+
};
60+
AnyRefNode Brachialis = {
61+
sRel = {-0.1,0,0.02};
62+
};
63+
AnyRefNode Brachioradialis = {
64+
sRel = {0.0,0,0.02};
65+
};
66+
AnyRefNode Biceps = {
67+
sRel = {-0.15,0,0.01};
68+
};
69+
AnyRefNode Triceps = {
70+
sRel = {-0.25,0,-0.05};
71+
};
72+
AnyDrawSeg DrwSeg = {};
73+
}; // ForeArm
74+
75+
// Todo: Add the model elements such as
76+
// segments, joints, and muscles here.
77+
78+
}; // Segs folder
79+
80+
}; // The study: Operations to be performed on the model
81+
// ArmModel
8882
AnyBodyStudy ArmStudy = {
8983
AnyFolder &Model = .ArmModel;
9084
Gravity = {0.0, -9.81, 0.0};
9185
};
92-
93-
}; // Main
94-
9586

87+
};

A_Getting_started_anyscript/Downloads/demo.lesson4.any

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -91,8 +91,8 @@ Main = {
9191

9292
}; // Segs folder
9393

94+
// Joints
9495
AnyFolder Jnts = {
95-
9696
//---------------------------------
9797
AnyRevoluteJoint Shoulder = {
9898
Axis = z;
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
// Todo: Write a small description of your model here
2+
3+
Main = {
4+
//# BEGIN SNIPPET 1
5+
// The actual body model goes in this folder
6+
AnyFolder §ArmModel§ = {
7+
8+
// Global Reference Frame
9+
AnyFixedRefFrame GlobalRef = {
10+
11+
// Todo: Add points for grounding of the model here
12+
13+
};
14+
15+
// Todo: Add the model elements such as
16+
// segments, joints, and muscles here.
17+
18+
};
19+
//# END SNIPPET 1
20+
// The study: Operations to be performed on the model
21+
AnyBodyStudy ArmStudy = {
22+
AnyFolder &Model = .ArmModel;
23+
Gravity = {0.0, -9.81, 0.0};
24+
};
25+
26+
};
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
// Todo: Write a small description of your model here
2+
3+
Main = {
4+
//# BEGIN SNIPPET 1
5+
// The actual body model goes in this folder
6+
AnyFolder ArmModel = {
7+
8+
// Global Reference Frame
9+
AnyFixedRefFrame GlobalRef = {
10+
// Todo: Add points for grounding of the model here
11+
};
12+
13+
§// Segments
14+
AnyFolder Segs = {
15+
}; // Segs folder §
16+
17+
};
18+
//# END SNIPPET 1
19+
// The study: Operations to be performed on the model
20+
AnyBodyStudy ArmStudy = {
21+
AnyFolder &Model = .ArmModel;
22+
Gravity = {0.0, -9.81, 0.0};
23+
};
24+
25+
};
Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
//expect_errors = ["'<ObjectName>'", "Model loading skipped"]
2+
3+
// Todo: Write a small description of your model here
4+
5+
Main = {
6+
// The actual body model goes in this folder
7+
AnyFolder ArmModel = {
8+
9+
// Global Reference Frame
10+
AnyFixedRefFrame GlobalRef = {
11+
// Todo: Add points for grounding of the model here
12+
};
13+
14+
//# BEGIN SNIPPET 1
15+
// Segments
16+
AnyFolder Segs = {
17+
§AnySeg <ObjectName> = {
18+
//viewRefFrame.Visible = Off;
19+
//viewNodes.Visible = Off;
20+
//r0 = {0.0, 0.0, 0.0};
21+
//rDot0 = {0.0, 0.0, 0.0};
22+
//Axes0 = {{1.0, 0.0, 0.0}, {0.0, 1.0, 0.0}, {0.0, 0.0, 1.0}};
23+
//omega0 = {0.0, 0.0, 0.0};
24+
Mass = 0.0;
25+
Jii = {0.0, 0.0, 0.0};
26+
//Jij = {0.0, 0.0, 0.0};
27+
//sCoM = {0.0, 0.0, 0.0};
28+
//JaboutCoMOnOff = Off;
29+
//viewInertia.Visible = Off;
30+
//AnyInertia &<Insert name0> = <Insert object reference (or full object definition)>;
31+
//AnyInertia &<Insert name1> = <Insert object reference (or full object definition)>; You can make any number of AnyInertia objects!
32+
};§
33+
}; // Segs folder
34+
//# END SNIPPET 1
35+
36+
};
37+
// The study: Operations to be performed on the model
38+
AnyBodyStudy ArmStudy = {
39+
AnyFolder &Model = .ArmModel;
40+
Gravity = {0.0, -9.81, 0.0};
41+
};
42+
43+
};
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
// Todo: Write a small description of your model here
2+
3+
Main = {
4+
// The actual body model goes in this folder
5+
AnyFolder ArmModel = {
6+
7+
// Global Reference Frame
8+
AnyFixedRefFrame GlobalRef = {
9+
// Todo: Add points for grounding of the model here
10+
};
11+
12+
13+
// Segments
14+
AnyFolder Segs = {
15+
//# BEGIN SNIPPET 1
16+
AnySeg §UpperArm§ = {
17+
//r0 = {0.0, 0.0, 0.0};
18+
//Axes0 = {{1.0, 0.0, 0.0}, {0.0, 1.0, 0.0}, {0.0, 0.0, 1.0}};
19+
Mass = §2§;
20+
Jii = {§0.001, 0.01, 0.01§};
21+
}; §//UpperArm§
22+
//# END SNIPPET 1
23+
}; // Segs folder
24+
25+
};
26+
// The study: Operations to be performed on the model
27+
AnyBodyStudy ArmStudy = {
28+
AnyFolder &Model = .ArmModel;
29+
Gravity = {0.0, -9.81, 0.0};
30+
};
31+
32+
};

0 commit comments

Comments
 (0)