Skip to content
GitLab
Menu
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
robotran
mbsysc
Commits
623c0ab0
Commit
623c0ab0
authored
Oct 06, 2016
by
Nicolas Docquier
Browse files
Add a readme file for building and using the Simulink interface
parent
4a89cfe8
Changes
1
Hide whitespace changes
Inline
Side-by-side
MBsysC/mbs_interface/mbs_simulink/ReadMe.md
0 → 100644
View file @
623c0ab0
# Simulink interface to Robotran/MBsysC modules
The Simulink/MBsysC interface enables to introduce a Robotran model
into a Simulink block diagram using a S-function. This document explains
how to compile and how to use this interface.
## Compiling the interface
*
First, the MBsysC momdules must be compiled already
*
Go to the
`MBsysC/mbs_interface/mbs_simulink`
folder
*
Create a
*build*
directory:
`mkdir build`
*
Configure the Cmake project:
`cmake ..`
*
Build the interface:
`make`
Those operations should produce a file
*MBsysC_SF_dirdyn.mexa64*
(the
extension will change depending on the OS). This file must be compiled
only once and can then be used for any project (assuming
FLAG_SEPARATE_BUILD was set to ON when building the project)
## Compiling the project
The project must be compiled as usual but
**
the FLAG_SEPARATE_BUILD
must be set to ON
**
.
## Building a Simulink block diagram with a Robotran model
*
Add the
`MBsysC/mbs_interface/mbs_simulink`
folder to your matlab path.
In matlab:
`addpath('paht/to/MBsysC/mbs_interface/mbs_simulink')`
*
Create a new Simulink block diagram or poen an existing one
*
Insert a S-function block from the Simulink library (it can be found in the
Simulink/User-Defined Functions). Alternatively, you can copy/paste
the block from an existing diagram such as the examples project availabl in
the
`MBsysC/mbs_interface/mbs_simulink`
folder.
*
Double-click on the S-function block and edit the propeties as follows:
*
**S-function name**
: type
`MBsysC_SF_dirdyn`
(the name of the compiled
file withou the extension)
*
**S-function parameters**
: enter the path to the
*
.mbs file surrounded
by single quotes
*
**S-function modules**
: keep the default setting
*
Connect the input/port of the block to the diagram:
*
1st input is ...
*
2nd input is ...
*
1st output contains the joint positions
*
2nd output contains the joint velocities
*
3rd output contains the joint accelerations
*
Complete the Simulink diagram as desired
*
Run the simulation
## Adding input/output ports
Custom input or output ports can be added to the block.
*
Define input/output (IO) by editing the
*
.mbs model with a text editor (this
can not be done in MBsysPad presently). Add a
*user_variables*
(with s!) section or
complete the existing one (after the user_models section). Add as many
user_variable (without s) section as IO number desired as illustrated
by the following example:
```
xml
<user_variable>
<user_variable>
<varname>
Fsusp
</varname>
<type>
out
</type>
<size>
4
</size>
</user_variable>
<user_variable>
<varname>
motorTorque
</varname>
<type>
in
</type>
<size>
1
</size>
</user_variable><user_variable>
```
*
**varname**
contains the name of the IO. The data will be
readable/editable in the code via
`mbs_data->userIO->varname`
.
*
**type**
determines wether it is an input or an output
*
**size**
defines the number of element in the IO. If size=1, the IO
will be a scalar (double). If size>1n the IO will be an array (double
*
)
*
(Re-)generate the userIO.c and userIO.h files. This is done via
MBsysPad using the menu
*Tools/Generate C-specific user files/All*
(check that the
*user_file_generation*
utility in the
`MBsysC/mbs_app`
folder has been compiled before)
*
Rebuild your project (the Simulink interface must NOT be rebuilt)
*
Reload the simulink diagram (or simply edit the properties of the
S-function block). The new ports will then be visible.
## Status
*
Simulation of several different model in the same diagram: OK
*
Platform
*
Linux: OK
*
Windows and MacOS: not tested
*
Type of building
*
Separate build: OK
*
Monolithic build: not tested
*
Realtime features
*
Not working. Should be implemented differently
*
To be done
*
improve integration with existing function (compute_model is duplicated)
*
improve user interface (cf JFC work in MBsysLab/mbs_simulink)
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment