Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
54 changes: 40 additions & 14 deletions A_Getting_started/intro.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,24 +21,50 @@ the model view window
This tutorial relies heavily on using the AnyBody Managed Model Repository (AMMR).
Follow the steps below to unpack a local version of the AMMR.

## Setup the AMMR

Before you continue, you must unpack the entire repository and save it on your
hard disk. To get a copy of the AMMR, press the Demo tab in the AnyBody
assistant dialog box.

![...](_static/intro/image1.png)

Following the instructions in the Demo tab will install a copy of the AMMR in
your documents folder by default. It is good practice to create a second local
copy of the AMMR so that you do not overwrite the original AMMR folder by
accident.
(SettingUpAMMR)=
## Setting Up the AMMR

The *AnyBody Managed Model Repository* (AMMR) is a comprehensive open library of
musculoskeletal models and examples designed to use with the AnyBody Modeling
System. It allows users to configure and combine different body models, which
can be easily integrated into their own simulations and analyses.

The AnyBody Managed Model Repository (AMMR) is included with the AnyBody
Modeling System, but it needs to be manually installed or unpacked after
installing AnyBody. You can install the AMMR from the AnyBody Assistant dialog
that appears when AnyBody starts.

To get a copy of the latest AMMR files, press the Demo tab in the AnyBody
assistant dialog box. Then select the *“Install the demo repository by clicking*
*this link”*

```{figure} _static/intro/image1.png
:alt: AMMR setup
:class: bg-primary
:align: center
```

This installs a copy of the AMMR locally in your documents folder by default (e.g.
{{AMMR_DEMO_INST_DIR}}). If
there are multiple users using your computer, each of them will have to follow
this guide. It is good practice to create a second local copy of the AMMR so
that you do not overwrite the original AMMR folder by accident. There you can
initialise a git repository in which you can version you models, keep a backup,
or share them easily with the community.

:::{important}
AnyBody Modelling System comes with a version of AMMR (not necessarily the
latest) placed in the installation folder of the software. Do not directly use
these files for your actual work as updates or reinstallation of AnyBody can
overwrite your changes. So always **copy the files from the AMMR folder to your**
**working folder** before using them.
:::

## AMMR structure

Open a file manager and navigate to the directory where you unpacked the
repository. You should see a folder structure that includes the following
subfolders:
repository (default is your documents folder). You should see a folder structure
that includes the following subfolders:

- **Application**: Includes demo simulations of activities such as cycling,
lifting a box, or propelling a wheelchair.
Expand Down
155 changes: 153 additions & 2 deletions A_Getting_started/lesson1.md
Original file line number Diff line number Diff line change
Expand Up @@ -60,9 +60,16 @@ location of the file is shown in the title bar:
```

:::{warning}
If you saved your model in an other location be
If you saved your model in another location be
sure to modify the {file}`../libdef.any` file so it points
to AMMR repository you want to use.

The following line should always refer correctly to the libdef file
regardless of where you save your model.

```AnyScriptDoc
#include "<ANYBODY_PATH_INSTALLDIR>/AMMR/libdef.any"
```
:::

(loading-a-model)=
Expand All @@ -88,7 +95,7 @@ another file loading priority by right-clicking its tab and select “Load Model
## The model view

When loading is completed, the Model View window opens and shows the standing
model: (You can open it manually from View -> Model Views).
model. You can open it manually from View -> Model Views.

```{image} _static/lesson1/image_5.png
:alt: Model view
Expand All @@ -110,5 +117,149 @@ functions, so keyboard shortcuts have been provided:
- If you have a scrolling wheel on your mouse, this will zoom the model
in and out.

## Understanding the AnyScript Model Structure

This Human Standing Model is a model from the AnyBody Managed Model Repository
(AMMR). It uses the [Human Model](https://anyscript.org/ammr/beta/body/models.html#the-body-model)
from the AMMR, which is used by most models you will encounter when using the AMMR.
Regardless of complexity, all models share a common structure used to set them
up.

The models will typically have the following overall structure (*notice*, the
AnyScript below is not excatly the same as the Standing Model used in this
tutorial, but contains the same overall structure):

```AnyScriptDoc
// Include the libdef file from the AMMR
#include "libdef.any"

Main =
{
// Define the BodyModel configuration
#include "Model/BodyModelConfiguration.any"

// Include the Human model from AMMR
#include "<ANYBODY_PATH_BODY>/HumanModel.any"

// Define desired posture or movement of the model
#include "Model\Mannequin.any"

// Compose the model
AnyFolder Model =
{
AnyFolder &BodyModel = .HumanModel.BodyModel;
AnyFolder Drivers = {...};
AnyFolder Environment = {...};
};

// Configuring the Study
AnyBodyStudy Study =
{
AnyFolder &Model= .Model;
Gravity = {0.0, -9.81,0.0}; // Gravity Vector
nStep = 10; // Number of steps
tStart = 0; // Start time
tEnd = 10.0; // End time
};
};
```

Let us go through the different components of this structure to understand how they work.

### Path to AMMR:

:::{note}
:class: margin
You can open a file by double-clicking on its name in the AnyScript.
:::

```AnyScriptDoc
#include "libdef.any"
```

This means your model will include the content of the file called `libdef.any`.
This file references to another `libdef.any` file located at the top-level
folder of the AMMR, which specifies the AMMR directories to use in your model.
You can have multiple versions of AMMR available on your computer, and this
points to the version you wish to use. This line should be at the very beginning
of your `main.any` file.

### Configuring the Human Model:

```AnyScriptDoc
Main =
{
// Define the BodyModel configuration
#include "Model/BodyModelConfiguration.any"
```

Here, the main declaration of the model, `Main = {}`, is initiated, and this file now
becomes the main model file. All basic AnyScript contains a main file that
defines the model’s structure, contents and the operations to be performed.

The file `BodyModelConfiguration.any` is included, which defines what parts of the
human body model are included, through a number of switches called Body Model
(BM) parameters. BM parameters are always prefixed with `BM_` inside AnyScript.
The values of these parameters are defined by `#define` and `#path` statements.

### Including the Human Model

```AnyScriptDoc
#include "<ANYBODY_PATH_BODY>/HumanModel.any"
```

The AMMR contains multiple musculoskeletal models. The above line includes the
Human Model from the AMMR. The file path `<ANYBODY_PATH_BODY>` is defined in
`libdef.any`.

It is important that the above configuration statements are placed
before this line.

### Defining the Posture and Movement

```AnyScriptDoc
#include "Model\Mannequin.any"
```

This includes the file `Mannequin.any` which defines the posture and movement of
the human body model.

### Composing the Model

```AnyScriptDoc
AnyFolder Model =
{
AnyFolder &BodyModel = .HumanModel.BodyModel;
AnyFolder Drivers = {...};
AnyFolder Environment = {...};
};
```

This is where we combine the `Body` from the Human Model with extra things like
drivers, external loads, and constraints. It could also be any models of the
environment which the body interacts with or many other things.

### The Study section

```AnyScriptDoc
AnyBodyStudy Study =
{
AnyFolder &Model= .Model;
Gravity = {0.0, -9.81,0.0}; // Gravity Vector
nStep = 10; // Number of steps
tStart = 0; // Start time
tEnd = 10.0; // End time
};
```

The `AnyBodyStudy` is where you configure and define your simulation. It
specifies start and end times of the simulation, and the number of steps. It also
configures which solvers are used.

Only the model elements which are referenced to within the Study will be
included in the simulation. In this case, the line `AnyFolder &Model= .Model;`
references to the Model folder, meaning everything in the Model folder is part of the
simulation.

You can now proceed to {doc}`lesson2`.

11 changes: 5 additions & 6 deletions A_Getting_started/lesson2.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,9 @@ The script editor currently shows the main file of the model, which includes the
line of code `Main = {}`. Any basic AnyScript contains a main file that defines
the model's structure and the operations to be performed on the model.

The `Mannequin.any` file, included in the main file, determines the posture of
the Standing Model by specifying the angles at the anatomical joints.

Scroll down to the line that says `#include "Model\Mannequin.any"`.
Scroll down to the line that says `#include "Model\Mannequin.any"`. This line
means that your model will include the content of the file called
`Mannequin.any` located in the Model folder, within the main file.

## Mannequin file structure

Expand All @@ -20,8 +19,8 @@ Scroll down to the line that says `#include "Model\Mannequin.any"`.
:end-before: //# END SNIPPET 1
```

**This line means that your model will include the content of the
"Mannequin.any" file located in the Model folder, within the main file.**
The `Mannequin.any` file determines the posture of the Standing Model by
specifying the angles at the anatomical joints.

Double-clicking the file name in the editor window after loading
your model opens the mannequin file in a new tab. Then you see the
Expand Down
Loading
Loading