writeAsFunction
Create rigidBodyTree code generating function
Description
writeAsFunction(
creates a function file that constructs the robot,filename)rigidBodyTree object. The created function supports code generation.
Examples
Load a robot model as a rigidBodyTree object.
robot = loadrobot("kinovaGen3")robot =
rigidBodyTree with properties:
NumBodies: 8
Bodies: {[1×1 rigidBody] [1×1 rigidBody] [1×1 rigidBody] [1×1 rigidBody] [1×1 rigidBody] [1×1 rigidBody] [1×1 rigidBody] [1×1 rigidBody]}
Base: [1×1 rigidBody]
BodyNames: {'Shoulder_Link' 'HalfArm1_Link' 'HalfArm2_Link' 'ForeArm_Link' 'Wrist1_Link' 'Wrist2_Link' 'Bracelet_Link' 'EndEffector_Link'}
BaseName: 'base_link'
Gravity: [0 0 0]
DataFormat: 'struct'
FrameNames: {'base_link' 'Shoulder_Link' 'HalfArm1_Link' 'HalfArm2_Link' 'ForeArm_Link' 'Wrist1_Link' 'Wrist2_Link' 'Bracelet_Link' 'EndEffector_Link'}
Show the robot model in a figure.
show(robot);

Create a code generating function that constructs the rigidBodyTree object.
writeAsFunction(robot,'KG3Codegen')Construct the robot model using the generated function.
rbt = KG3Codegen
rbt =
rigidBodyTree with properties:
NumBodies: 8
Bodies: {[1×1 rigidBody] [1×1 rigidBody] [1×1 rigidBody] [1×1 rigidBody] [1×1 rigidBody] [1×1 rigidBody] [1×1 rigidBody] [1×1 rigidBody]}
Base: [1×1 rigidBody]
BodyNames: {'Shoulder_Link' 'HalfArm1_Link' 'HalfArm2_Link' 'ForeArm_Link' 'Wrist1_Link' 'Wrist2_Link' 'Bracelet_Link' 'EndEffector_Link'}
BaseName: 'base_link'
Gravity: [0 0 0]
DataFormat: 'struct'
FrameNames: {'base_link' 'Shoulder_Link' 'HalfArm1_Link' 'HalfArm2_Link' 'ForeArm_Link' 'Wrist1_Link' 'Wrist2_Link' 'Bracelet_Link' 'EndEffector_Link'}
Show the robot model in a figure.
show(rbt);

Input Arguments
Robot model, specified as a rigidBodyTree object.
Name of the function file, specified as a string scalar or character vector. The name must be a valid MATLAB® name (must start with a letter and contain only letters, numbers and underscores).
Example: "iiwa14Codegen"
Data Types: char | string
Version History
Introduced in R2021aThe generated function file now constructs rigid body trees that include all root and nonroot frames defined in the original rigidBodyTree object. In prior releases, the generated function file includes only root frames from the original rigidBodyTree object.
MATLAB Command
You clicked a link that corresponds to this MATLAB command:
Run the command by entering it in the MATLAB Command Window. Web browsers do not support MATLAB commands.
Website auswählen
Wählen Sie eine Website aus, um übersetzte Inhalte (sofern verfügbar) sowie lokale Veranstaltungen und Angebote anzuzeigen. Auf der Grundlage Ihres Standorts empfehlen wir Ihnen die folgende Auswahl: .
Sie können auch eine Website aus der folgenden Liste auswählen:
So erhalten Sie die bestmögliche Leistung auf der Website
Wählen Sie für die bestmögliche Website-Leistung die Website für China (auf Chinesisch oder Englisch). Andere landesspezifische Websites von MathWorks sind für Besuche von Ihrem Standort aus nicht optimiert.
Amerika
- América Latina (Español)
- Canada (English)
- United States (English)
Europa
- Belgium (English)
- Denmark (English)
- Deutschland (Deutsch)
- España (Español)
- Finland (English)
- France (Français)
- Ireland (English)
- Italia (Italiano)
- Luxembourg (English)
- Netherlands (English)
- Norway (English)
- Österreich (Deutsch)
- Portugal (English)
- Sweden (English)
- Switzerland
- United Kingdom (English)