M-File Help: CodeGenerator View code for CodeGenerator

CodeGenerator

Class for code generation

Objects of the CodeGenerator class automatcally generate robot specific code, as either M-functions or real-time capable SerialLink blocks.

The various methods return symbolic expressions for robot kinematic and dynamic functions, and optionally support side effects such as:

Example

% load robot model
mdl_twolink
cg = CodeGenerator(twolink);
cg.geneverything();
% a new class has been automatically generated in the robot directory.
addpath robot
tl = @robot();
% this class is a subclass of SerialLink, and thus polymorphic with
% SerialLink but its methods have been overloaded with robot-specific code,
% for example
T = tl.fkine([0.2 0.3]);
% uses concise symbolic expressions rather than the generalized A-matrix
% approach
% The Simulink block library containing robot-specific blocks can be
% opened by
open robot/robotslib.slx
% and the blocks dragged into your own models.

Methods

gencoriolis generate Coriolis/centripetal code
genfdyn generate forward dynamics code
genfkine generate forward kinematics code
genfriction generate joint frictionc code
gengravload generarte gravity load code
geninertia general inertia matrix code
geninvdyn generate forward dynamics code
genjacobian generate Jacobian code
geneverything generate code for all of the above

Properties (read/write)

basepath basic working directory of the code generator
robjpath subdirectory for specialized MATLAB functions
sympath subdirectory for symbolic expressions
slib filename of the Simulink library
slibpath subdirectory for the Simulink library
verbose print code generation progress on console (logical)
saveresult save symbolic expressions to .mat-files (logical)
logfile print modeling progress to specified text file (string)
genmfun generate executable M-functions (logical)
genslblock generate Embedded MATLAB Function blocks (logical)

Object properties (read only)

rob SerialLink object to generate code for (1x1).

Notes

Author

Joern Malzahn 2012 RST, Technische Universitaet Dortmund, Germany. http://www.rst.e-technik.tu-dortmund.de

See also

SerialLink, Link


CodeGenerator.CodeGenerator

Construct a code generator object

cGen = CodeGenerator(rob) is a code generator object for the SerialLink object rob.

cGen = CodeGenerator(rob, options) as above but with options described below.

Options

The following option sets can be passed as an optional parameter:

'default' set the options: verbose, saveResult, genMFun, genSLBlock
'debug' set the options: verbose, saveResult, genMFun, genSLBlock and create a logfile named 'robModel.log' in the working directory
'silent' set the options: saveResult, genMFun, genSLBlock
'disk' set the options: verbose, saveResult
'workspace' set the option: verbose; just outputs symbolic expressions to workspace
'mfun' set the options: verbose, saveResult, genMFun
'slblock' set the options: verbose, saveResult, genSLBlock

If 'optionSet' is ommitted, then 'default' is used. The options control the code generation and user information:

'verbose' write code generation progress to command window
'saveResult save results to hard disk (always enabled, when genMFun and genSLBlock are set)
'logFile', logfile write code generation progress to specified logfile
'genMFun' generate robot specific m-functions
'genSLBlock' generate real-time capable robot specific Simulink blocks

Any option may also be modified individually as optional parameter value pairs.

Author

Joern Malzahn 2012 RST, Technische Universitaet Dortmund, Germany. http://www.rst.e-technik.tu-dortmund.de


CodeGenerator.addpath

Adds generated code to search path

cGen.addpath() adds the generated m-functions and block library to the MATLAB function search path.

Author

Joern Malzahn 2012 RST, Technische Universitaet Dortmund, Germany. http://www.rst.e-technik.tu-dortmund.de

See also

addpath


CodeGenerator.gencoriolis

Generate code for Coriolis force

coriolis = cGen.gencoriolis() is a symbolic matrix (NxN) of centrifugal and Coriolis forces/torques.

Notes

Author

Joern Malzahn 2012 RST, Technische Universitaet Dortmund, Germany. http://www.rst.e-technik.tu-dortmund.de

See also

CodeGenerator.CodeGenerator, CodeGenerator.geninertia, CodeGenerator.genfkine


CodeGenerator.genfdyn

Generate code for forward dynamics

Iqdd = cGen.genfdyn() is a symbolic vector (1xN) of joint inertial reaction forces/torques.

Notes

Author

Joern Malzahn 2012 RST, Technische Universitaet Dortmund, Germany. http://www.rst.e-technik.tu-dortmund.de

See also

CodeGenerator.CodeGenerator, CodeGenerator.geninertia, CodeGenerator.genfkine


CodeGenerator.genfkine

Generate code for forward kinematics

T = cGen.genfkine() generates a symbolic homogeneous transform matrix (4x4) representing the pose of the robot end-effector in terms of the symbolic joint coordinates q1, q2, ...

[T, allt] = cGen.genfkine() as above but also generates symbolic homogeneous transform matrices (4x4xN) for the poses of the individual robot joints.

Notes

Author

Joern Malzahn 2012 RST, Technische Universitaet Dortmund, Germany. http://www.rst.e-technik.tu-dortmund.de

See also

CodeGenerator.CodeGenerator, CodeGenerator.geninvdyn, CodeGenerator.genjacobian


CodeGenerator.genfriction

Generate code for joint friction

f = cGen.genfriction() is the symbolic vector (1xN) of joint friction forces.

Notes

Author

Joern Malzahn 2012 RST, Technische Universitaet Dortmund, Germany. http://www.rst.e-technik.tu-dortmund.de

See also

CodeGenerator.CodeGenerator, CodeGenerator.geninvdyn, CodeGenerator.genfdyn


CodeGenerator.gengravload

Generate code for gravitational load

g = cGen.gengravload() is a symbolic vector (1xN) of joint load forces/torques due to gravity.

Notes

Author

Joern Malzahn 2012 RST, Technische Universitaet Dortmund, Germany. http://www.rst.e-technik.tu-dortmund.de

See also

codegenerator, CodeGenerator.geninvdyn, CodeGenerator.genfdyn


CodeGenerator.geninertia

Generate code for inertia matrix

i = cGen.geninertia() is the symbolic robot inertia matrix (NxN).

Notes

Author

Joern Malzahn 2012 RST, Technische Universitaet Dortmund, Germany. http://www.rst.e-technik.tu-dortmund.de

See also

CodeGenerator.CodeGenerator, CodeGenerator.geninvdyn, CodeGenerator.genfdyn


CodeGenerator.geninvdyn

Generate code for inverse dynamics

tau = cGen.geninvdyn() is the symbolic vector (1xN) of joint forces/torques.

Notes

Author

Joern Malzahn 2012 RST, Technische Universitaet Dortmund, Germany. http://www.rst.e-technik.tu-dortmund.de

See also

CodeGenerator.CodeGenerator, CodeGenerator.genfdyn, CodeGenerator.genfkine


CodeGenerator.genjacobian

Generate code for robot Jacobians

j0 = cGen.genjacobian() is the symbolic expression for the Jacobian matrix (6xN) expressed in the base coordinate frame.

[j0, Jn] = cGen.genjacobian() as above but also returns the symbolic expression for the Jacobian matrix (6xN) expressed in the end-effector frame.

Notes

Author

Joern Malzahn 2012 RST, Technische Universitaet Dortmund, Germany. http://www.rst.e-technik.tu-dortmund.de

See also

CodeGenerator.CodeGenerator, CodeGenerator.genfkine


CodeGenerator.genmfuncoriolis

Generate M-functions for Coriolis matrix

cGen.genmfuncoriolis() generates a robot-specific M-function to compute the Coriolis matrix.

Notes

Author

Joern Malzahn 2012 RST, Technische Universitaet Dortmund, Germany. http://www.rst.e-technik.tu-dortmund.de

See also

CodeGenerator.CodeGenerator, CodeGenerator.gencoriolis, CodeGenerator.geninertia


CodeGenerator.genmfunfdyn

Generate M-function for forward dynamics

cGen.genmfunfdyn() generates a robot-specific M-function to compute the forward dynamics.

Notes

Author

Joern Malzahn 2012 RST, Technische Universitaet Dortmund, Germany. http://www.rst.e-technik.tu-dortmund.de

See also

CodeGenerator.CodeGenerator, CodeGenerator.geninvdyn


CodeGenerator.genmfunfkine

Generate M-function for forward kinematics

cGen.genmfunfkine() generates a robot-specific M-function to compute forward kinematics.

Notes

Author

Joern Malzahn 2012 RST, Technische Universitaet Dortmund, Germany. http://www.rst.e-technik.tu-dortmund.de

See also

CodeGenerator.CodeGenerator, CodeGenerator.genjacobian


CodeGenerator.genmfunfriction

Generate M-function for joint friction

cGen.genmfunfriction() generates a robot-specific M-function to compute joint friction.

Notes

Author

Joern Malzahn 2012 RST, Technische Universitaet Dortmund, Germany. http://www.rst.e-technik.tu-dortmund.de

See also

CodeGenerator.CodeGenerator, CodeGenerator.gengravload


CodeGenerator.genmfungravload

Generate M-functions for gravitational load

cGen.genmfungravload() generates a robot-specific M-function to compute gravitation load forces and torques.

Notes

Author

Joern Malzahn 2012 RST, Technische Universitaet Dortmund, Germany. http://www.rst.e-technik.tu-dortmund.de

See also

CodeGenerator.CodeGenerator, CodeGenerator.geninertia


CodeGenerator.genmfuninertia

Generate M-function for robot inertia matrix

cGen.genmfuninertia() generates a robot-specific M-function to compute robot inertia matrix.

Notes

Author

Joern Malzahn 2012 RST, Technische Universitaet Dortmund, Germany. http://www.rst.e-technik.tu-dortmund.de

See also

CodeGenerator.CodeGenerator, CodeGenerator.gencoriolis


CodeGenerator.genmfuninvdyn

Generate M-functions for inverse dynamics

cGen.genmfuninvdyn() generates a robot-specific M-function to compute inverse dynamics.

Notes

Author

Joern Malzahn 2012 RST, Technische Universitaet Dortmund, Germany. http://www.rst.e-technik.tu-dortmund.de

See also

CodeGenerator.CodeGenerator, CodeGenerator.geninvdyn


CodeGenerator.genmfunjacobian

Generate M-functions for robot Jacobian

cGen.genmfunjacobian() generates a robot-specific M-function to compute robot Jacobian.

Notes

Author

Joern Malzahn 2012 RST, Technische Universitaet Dortmund, Germany. http://www.rst.e-technik.tu-dortmund.de

See also

CodeGenerator.CodeGenerator, CodeGenerator.gencoriolis


CodeGenerator.genslblockcoriolis

Generat Simulink block for Coriolis matrix

cGen.genslblockcoriolis() generates a robot-specific Simulink block to compute Coriolis/centripetal matrix.

Notes

Author

Joern Malzahn 2012 RST, Technische Universitaet Dortmund, Germany. http://www.rst.e-technik.tu-dortmund.de

See also

CodeGenerator.CodeGenerator, CodeGenerator.gencoriolis


CodeGenerator.genslblockfdyn

Generate Simulink block for forward dynamics

cGen.genslblockfdyn() generates a robot-specific Simulink block to compute forward dynamics.

Notes

Author

Joern Malzahn 2012 RST, Technische Universitaet Dortmund, Germany. http://www.rst.e-technik.tu-dortmund.de

See also

CodeGenerator.CodeGenerator, CodeGenerator.genfdyn


CodeGenerator.genslblockfkine

Generate Simulink block for forward kinematics

cGen.genslblockfkine() generates a robot-specific Simulink block to compute forward kinematics.

Notes

Author

Joern Malzahn 2012 RST, Technische Universitaet Dortmund, Germany. http://www.rst.e-technik.tu-dortmund.de

See also

CodeGenerator.CodeGenerator, CodeGenerator.genfkine


CodeGenerator.genslblockfriction

Generate Simulink block for joint friction

cGen.genslblockfriction() generates a robot-specific Simulink block to compute the joint friction model.

Notes

Author

Joern Malzahn 2012 RST, Technische Universitaet Dortmund, Germany. http://www.rst.e-technik.tu-dortmund.de

See also

CodeGenerator.CodeGenerator, CodeGenerator.genfriction


CodeGenerator.genslblockgravload

Generate Simulink block for gravitational load

cGen.genslblockgravload() generates a robot-specific Simulink block to compute gravitational load.

Notes

Author

Joern Malzahn 2012 RST, Technische Universitaet Dortmund, Germany. http://www.rst.e-technik.tu-dortmund.de

See also CodeGenerator.CodeGenerator, CodeGenerator.gengravload


CodeGenerator.genslblockinertia

Generate Simulink block for inertia matrix

cGen.genslbgenslblockinertia() generates a robot-specific Simulink block to compute robot inertia matrix.

Notes

Author

Joern Malzahn 2012 RST, Technische Universitaet Dortmund, Germany. http://www.rst.e-technik.tu-dortmund.de

See also

CodeGenerator.CodeGenerator, CodeGenerator.geninertia


CodeGenerator.genslblockinvdyn

Generate Simulink block for inverse dynamics

cGen.genslblockinvdyn() generates a robot-specific Simulink block to compute inverse dynamics.

Notes

Author

Joern Malzahn 2012 RST, Technische Universitaet Dortmund, Germany. http://www.rst.e-technik.tu-dortmund.de

See also

CodeGenerator.CodeGenerator, CodeGenerator.geninvdyn


CodeGenerator.genslblockjacobian

Generate Simulink block for robot Jacobians

cGen.genslblockjacobian() generates a robot-specific Simulink block to compute robot Jacobians (world and tool frame).

Notes

Author

Joern Malzahn 2012 RST, Technische Universitaet Dortmund, Germany. http://www.rst.e-technik.tu-dortmund.de

See also

CodeGenerator.CodeGenerator, CodeGenerator.genjacobian


CodeGenerator.logmsg

Print CodeGenerator logs.

count = CGen.logmsg( FORMAT, A, ...) is the number of characters written to the CGen.logfile. For the additional arguments see fprintf.

Note

Matlab ships with a function for writing formatted strings into a text file or to the console (fprintf). The function works with single target identifiers (file, console, string). This function uses the same syntax as for the fprintf function to output log messages to either the Matlab console, a log file or both.

Authors

Joern Malzahn 2012 RST, Technische Universitaet Dortmund, Germany http://www.rst.e-technik.tu-dortmund.de

See also

multidfprintf, fprintf, sprintf


CodeGenerator.purge

Cleanup generated files

cGen.purge() deletes all generated files, first displays a question dialog to make sure the user really wants to delete all generated files.

cGen.purge(1) as above but skips the question dialog.

Author

Joern Malzahn 2012 RST, Technische Universitaet Dortmund, Germany. http://www.rst.e-technik.tu-dortmund.de


CodeGenerator.rmpath

Removes generated code from search path

cGen.rmpath() removes generated m-functions and block library from the MATLAB function search path.

Author

Joern Malzahn 2012 RST, Technische Universitaet Dortmund, Germany. http://www.rst.e-technik.tu-dortmund.de

See also

rmpath


 

© 1990-2012 Peter Corke.