raisim
namespace
The RaiSim physics engine: worlds, objects, articulated systems, contacts, sensors and the visualization server.
Namespaces
- raisim::ControlMode — Actuation modes of an ArticulatedSystem (see ArticulatedSystem::setControlMode()).
- raisim::Shape — Geometry shape types.
- raisim::contact
- raisim::mesh_files
- raisim::mjcf
- raisim::rscene
- raisim::server
- raisim::tcp
- raisim::urdf
Classes
Core
classAlignedAllocator — Standard allocator that returns memory aligned to RSALOCATOR_ALIGNMENT bytes (e.g. for vectors of fixed-size Eigen-backed types).structCoacdOptions — CoACD convex decomposition parameters for mesh collision approximation.structColorRGB — 8-bit RGB color (components 0-255).structColorRGBA — 8-bit RGBA color (components 0-255).classDynamicArray — Owning heap buffer of doubles; the common base of VecDyn and MatDyn.classMatDyn — Dynamically sized matrix of doubles, stored column-major: element (i, j) is v[i + j * rows()].classMaterialManager — Table of contact properties per material pair.structMaterialPairProperties — Contact properties of a pair of materials.classnoiseUtils — Internal: numeric helpers of the terrain noise generator.classPath — A file system path string using the platform separator.classPerlinNoise — 3D Perlin gradient noise with a seeded 256-entry permutation table (period 256 on each axis).classRaiSimMsg — Message printer behind the RSINFO / RSWARN / RSFATAL macros (raisim_message.hpp).classRaisimServer — Streams a raisim::World (plus server-side visual-only objects and charts) over TCP to a visualizer such as the rayrai TCP viewer, and accepts interaction / sim-control requests (pause, step,…classRaiSimTinyXmlWrapper — Read-only convenience wrapper around a TinyXML element, used by the RaiSim XML, URDF and MJCF loaders.classRaiSimTinyXmlWriter — Minimal XML document writer: add top-level elements with operator[] and write the file with saveFile().classRaiSimTinyXmlWriterElement — Builder for one element of an XML document written by RaiSimTinyXmlWriter (used by World::exportToXml()).structRasset — A reusable visual asset with collision shapes in the visual's local frame. .rasset files are XML; paths are relative to the descriptor, not the process.classRayCollisionItem — One ray hit returned by World::rayTest().classRayCollisionList — Hit list returned by World::rayTest().classScopedRaiSimFatalCallback — Restore-on-destruction wrapper for the calling thread's fatal callback.classSparseJacobian — Sparse Jacobian with three rows (e.g. of a point's position or of a body's angular velocity with respect to the generalized velocity) that stores only its non-zero columns.classSparseJacobian1D — Single-row counterpart of SparseJacobian: v holds the non-zero entries as a 1 x size row and entry i is column idx[i] of the full 1 x dof Jacobian.classStopWatch — Wall-clock timer based on std::chrono::steady_clock.classTerrainGenerator — Generates fractal Perlin-noise height samples from TerrainProperties.structTerrainProperties — Parameters of a fractal Perlin-noise terrain (see TerrainGenerator and World::addHeightMap()).classTimedLoop — Scope guard for fixed-rate loops: its destructor sleeps until loopTimeInUs after its construction.structTransformation — Rigid transformation stored as a rotation matrix and a translation.classVecDyn — Dynamically sized column vector of doubles (heap storage, see DynamicArray).classWorld — The simulation world.
Objects
classBox — A rigid box.classCapsule — A rigid capsule (a cylinder capped by two hemispheres) whose axis is the body z axis.classCompound — A rigid body composed of primitive children (BOX, CYLINDER, CAPSULE, SPHERE) with user-given mass properties.classCone — A cone. Not supported by the current collision engine: the constructor raises a fatal error.classCylinder — A rigid cylinder whose axis is the body z axis.classMesh — A rigid body defined by a triangle mesh (create it with World::addMesh()).classObject — Abstract base class of everything that can be added to a raisim::World: single bodies, terrains, articulated systems, deformable objects and granular systems.classSingleBodyObject — Base class of rigid single-body objects (Sphere, Box, Cylinder, Capsule, Mesh, Compound, Ground, ...).classSphere — A rigid sphere.
Articulated systems
structActuatorCoupling — A coupling of an actuator's motor to a joint other than the one the actuator drives (see ActuatorDefinition).structActuatorDefinition — An actuator: a DC/BLDC motor with its gear.structActuatorState — The state of an actuator in the last simulation step, with the motor quantities on the motor (rotor) side of its gear.classArticulatedSystem — A tree of rigid bodies connected by joints (robot), simulated in generalized coordinates.classArticulatedSystemOption — Options passed to the ArticulatedSystem constructors.classBody — Inertial, collision and visual properties of a link, used to build an articulated system (see Child).classChild — Node of a kinematic tree (a body plus the joint connecting it to its parent), used to build an ArticulatedSystem programmatically.structCollisionBody — Collision geometry description of a Body, used when building an articulated system (see Body::addCollisionObject()).structCollisionDefinition — collision definition that is stored in Articulated System (see ArticulatedSystem::getCollisionBodies()).classCoordinateFrame — A coordinate frame of an articulated system, defined at every joint (including fixed joints) and at sensors.structDcMotorParameters — Steady-state electrical model of the DC/BLDC motor inside an actuator, on the motor (rotor) side of the actuator's gear, in SI units.classJoint — Joint connecting a body to its parent; used to build an articulated system (see Child).structMotorTorqueBounds — admissible motor torque interval at a given motor speedstructTrack — A rigid track (continuous belt) of an articulated system, defined by a URDF <track> element.structTrackDefinition — Internal: a <track> as read by the URDF loader, with its belt geometry already added to the link.structTrackDrive — A joint that moves the belt of a track: it adds gain * (joint velocity) to the belt speed.structVisObject — visualization definition created by a user or URDF
Terrain
classDeformableTerrain — A triangulated soil surface with no particles or soil inertia.classGround — A static infinite ground plane (half-space) with normal +z. Create it with World::addGround().classHeightMap — A static terrain defined by a regular grid of heights (create it with World::addHeightMap()).
Deformable objects
classDeformableObject — A position-based (XPBD/PBD) deformable body made of particles connected by distance constraints (mesh edges plus optional extra edges) and, for cloth, bending constraints between adjacent triangles.
Granular media
classGranularPoolSleepController — Opt-in approximation for a settled pool.classGranularSystem — A discrete-element (DEM) system of spherical particles stepped as one object (create it with World::addGranularParticles() or World::addGranularBox()).
Constraints and tendons
classCompliantLengthConstraint — A length constraint that acts as a linear spring (created by World::addCompliantWire()).classConstraints — Base class of world-level constraints (see LengthConstraint). Holds the name, visualization color and a mutex.classCustomLengthConstraint — A length constraint that applies a user-specified tension (see setTension(); created by World::addCustomWire()).structEqualityConstraintDefinition — Description of an equality constraint inside an articulated system, as parsed from URDF.classLengthConstraint — Base class of the legacy distance constraints ("wires") between two points on two objects.structMimicConstraint — Internal: a resolved mimic constraint between two one-degree-of-freedom joints.structMimicConstraintDefinition — Description of a mimic constraint, as parsed from URDF (<mimic>) or MJCF (<equality><joint>): the follower joint's position is kept at multiplier * (leader position) + offset.classPinConstraint — Internal: a resolved point constraint between two bodies of one articulated system.structPinConstraintDefinition — Description of a pin (point-to-point) constraint inside an articulated system, as parsed from URDF/MJCF.classStiffLengthConstraint — A length constraint enforced as a hard limit (created by World::addStiffWire()).classTendon — A scalar transmission: routed spatial length or a weighted sum of scalar joints.classTendonCoupling — Constrains the length of one tendon to a polynomial of another tendon's length.
Contact and collision
structCollisionBodyHandle — Internal: per-body collision data registered with the contact engine (shape, owner, material).classContact — A contact point between two collision bodies, as stored in Object::getContacts().
Sensors
structCameraFisheyeDistortion — OpenCV-fisheye (Kannala-Brandt) distortion coefficients k1..k4.structCameraIntrinsics — Pinhole-style camera intrinsics in pixels.structCameraLensModel — Lens description of a camera sensor: projection model, intrinsics and fisheye distortion.classDepthCamera — Depth camera simulated by CPU ray casting against the collision geometry of the world.classInertialMeasurementUnit — An ideal or stochastic six-axis IMU.classRGBCamera — Color camera sensor.classSensor — Base class of all sensors attached to an ArticulatedSystem frame (RGBCamera, DepthCamera, InertialMeasurementUnit, SpinningLidar).classSensorSet — A named group of sensors that belongs to one body of an ArticulatedSystem (e.g., all sensors of one physical device).classSpinningLidar — Spinning (rotating-head) lidar simulated by CPU ray casting.
Server and visuals
structArticulatedSystemVisual — Visual-only articulated system (no physics) streamed by RaisimServer.classBarChart — Bar chart (histogram) with one bar per named category.classChart — Base class of the charts streamed by RaisimServer (TimeSeriesGraph, BarChart).structHeightMapVisual — Visual-only height map (no physics) streamed by RaisimServer.structInstancedVisuals — Many visual-only instances of one shape, drawn with per-instance pose, scale and a color interpolated between color1 and color2.structPointCloud — Point cloud streamed by RaisimServer.structPolyLine — Visual-only polyline streamed by RaisimServer.classTimeSeriesGraph — Line chart of one or more named series over time.structVisualMesh — Visual mesh created by RaisimServer::addVisualMesh(), either from a file or from raw arrays.structVisuals — Visual-only primitive (sphere, box, cylinder, capsule, arrow or mesh) streamed by RaisimServer.
Math
classBlockRef — Fixed-size n x m block view of a matrix, returned by Mat::segment(), Mat::head(), Mat::tail(), Mat::block() and the corner accessors.classColRef — View of one column (n elements) of a matrix, returned by Mat::col().classCrossProduct — Lazy 3D cross product u x v of two 3x1 expressions, returned by cross() on a 3D vector.classDiagonalRef — Placeholder proxy for a matrix diagonal. It has no accessors and no Mat method returns it.classDiv_SL_op — Lazy scalar / matrix element-wise expression (Div_SL_op), returned by operator/(double, MatExpr).classElementRef — Proxy returned by the comma initializers (Mat::operator<<() and DynamicArray::operator=(double)); each following , value writes the next element in linear (column-major) order.classMat — Fixed-size n x m matrix of doubles, stored column-major: element (i, j) is v[i + j * n].classMatExpr — CRTP base of all fixed-size matrix types and expression templates (Mat, the block views and the lazy arithmetic expressions).classProd_op — Lazy matrix-product expression returned by operator* on two fixed-size matrix expressions.classProd_op< Mat< 4, 4 >, Mat< 4, 4 > > — Specialization for the 4x4 by 4x4 product: it is evaluated eagerly (with Eigen) when constructed and stores the result.classRowRef — View of one row (m elements) of a matrix, returned by Mat::row().classSkewRef — Proxy returned by skew() on a 3D vector.classSub_SL_op — Lazy scalar - matrix expression (Sub_SL_op), returned by operator-(double, MatExpr).classTranspose — Lazy expression for the transpose of a fixed-size matrix expression, returned by Mat::transpose().
Enumerations
ObjectType
#include <raisim/configure.hpp>
enum ObjectType : intObject type identifiers.
| Enumerator | Value |
|---|---|
SPHERE | 0 |
BOX | |
CYLINDER | |
CONE | |
CAPSULE | |
MESH | |
HALFSPACE | |
COMPOUND | |
HEIGHTMAP | |
ARTICULATED_SYSTEM | |
DEFORMABLE | |
GRANULAR | |
UNRECOGNIZED |
MeshCollisionMode
#include <raisim/configure.hpp>
enum class MeshCollisionMode : intMesh collision handling modes.
| Enumerator | Value | Description |
|---|---|---|
ORIGINAL_MESH | 0 | keep the (possibly non-convex) triangle mesh |
CONVEX_HULL | use one convex hull of the mesh | |
CONVEXIFY | CoACD convex decomposition (see CoacdOptions). |
BodyType
#include <raisim/configure.hpp>
enum class BodyType : intBody type identifiers.
| Enumerator | Value | Description |
|---|---|---|
STATIC | 1 | not movable, infinite mass |
KINEMATIC | 2 | moves with its set velocity, infinite mass; ignores forces, gravity and contacts |
DYNAMIC | 3 | movable, finite mass |
MotorSaturation
#include <raisim/object/ArticulatedSystem/MotorOperatingRegion.hpp>
enum class MotorSaturation : intThe bound of the operating region that limits a motor torque.
| Enumerator | Value | Description |
|---|---|---|
NONE | 0 | the torque is inside the operating region |
PEAK_TORQUE | 1 | the torque is limited by the peak torque |
VOLTAGE | 2 | the torque is limited by the bus voltage (back EMF) |
GyroscopicMode
#include <raisim/object/singleBodies/SingleBodyObject.hpp>
enum GyroscopicModeHow single bodies integrate the gyroscopic term w x (I w). The default is IMPLICIT_GYROSCOPIC_FORCE_BODY (Sphere uses EXPLICIT_GYROSCOPIC_FORCE).
| Enumerator | Description |
|---|---|
IMPLICIT_GYROSCOPIC_FORCE_BODY | Implicit integration in the body frame (stable, more computation). |
IMPLICIT_GYROSCOPIC_FORCE_WORLD | Linearly implicit integration in the world frame (stable, more computation). |
EXPLICIT_GYROSCOPIC_FORCE | Explicit integration (can be unstable, less computation). |
NO_GYROSCOPIC_FORCE | The gyroscopic term is ignored. |
CameraProjectionType
#include <raisim/sensors/CameraLens.hpp>
enum class CameraProjectionType : intCamera projection model used by RGBCamera and DepthCamera.
| Enumerator | Value | Description |
|---|---|---|
PINHOLE | 0 | Rectilinear (perspective) projection. |
FISHEYE_EQUIDISTANT | 1 | Equidistant fisheye: image radius proportional to the ray angle (r = f * theta). |
Type aliases
CollisionBodyHandlePtr
#include <raisim/collision/CollisionBody.hpp>
using CollisionBodyHandlePtr = CollisionBodyHandle *CollisionBodyHandleConstPtr
#include <raisim/collision/CollisionBody.hpp>
using CollisionBodyHandleConstPtr = const CollisionBodyHandle *CollisionGroup
#include <raisim/configure.hpp>
typedef uint64_t CollisionGroupCollision group / mask bit set. Two bodies collide if each one's group intersects the other's mask.
Vec
#include <raisim/math.hpp>
template <size_t Size>
using Vec = Mat<Size, 1>Fixed-size column vector of doubles; Vec<Size> is an alias of Mat<Size, 1>.
ScalarType
#include <raisim/math/Matrix.hpp>
using ScalarType = doubleCollisionSet
#include <raisim/object/ArticulatedSystem/JointAndBodies.hpp>
typedef std::vector<CollisionDefinition> CollisionSetCollision bodies of an articulated system.
Functions
strtodClassic
#include <raisim/ClassicNumber.hpp>
double strtodClassic(const char *text, char **end)strtod() in the classic "C" locale, whatever locale the application set.
Parameters
| Parameter | Description |
|---|---|
text (in) | the number's text |
end (out) | receives the first character after the number (text when there is none); may be null |
Returns the value, setting errno as strtod() does
snprintfClassic
#include <raisim/ClassicNumber.hpp>
int snprintfClassic(char *buffer, std::size_t size, const char *format,...)snprintf() in the classic "C" locale, whatever locale the application set.
Parameters
| Parameter | Description |
|---|---|
buffer (out) | receives the text, always terminated when size > 0 |
size (in) | its size |
format (in) | printf format |
Returns the length of the whole text (which may not have fit), or a negative value on an error, as snprintf() returns
searchForFile
#include <raisim/Path.hpp>
static Path searchForFile(
const std::string &filename,
const Path &searchRoot,
const std::vector<std::string> &hints)Look for a file directly under a root directory, then under each hint subdirectory.
Parameters
| Parameter | Description |
|---|---|
filename (in) | file name (or relative path) to find |
searchRoot (in) | directory to search |
hints (in) | subdirectories of searchRoot to try, in order |
Returns the first existing searchRoot/filename or searchRoot/hint/filename, or Path("") if none exists
pathFromUtf8
#include <raisim/PathUtils.hpp>
std::filesystem::path pathFromUtf8(const std::string &text)Convert authored UTF-8 paths without relying on the Windows active code page.
pathUtf8
#include <raisim/PathUtils.hpp>
std::string pathUtf8(const std::filesystem::path &path)UTF-8 with generic separators, suitable for scene files and protocol messages.
validateTerrainProperties
#include <raisim/Terrain.hpp>
bool validateTerrainProperties(
const TerrainProperties &properties,
size_t minimumSamples,
std::string *reason=nullptr)Validate every property before terrain normalization, allocation, or noise sampling. The minimum sample count is one for a standalone TerrainGenerator and two for a HeightMap, whose interpolation requires one cell on each axis.
Parameters
| Parameter | Description |
|---|---|
properties (in) | properties to check |
minimumSamples (in) | minimum sample count per axis |
reason (out) | if not nullptr, receives the reason of a failure |
Returns true if the properties are valid
COLLISION
#include <raisim/World.hpp>
static CollisionGroup COLLISION(CollisionGroup group)Parameters
| Parameter | Description |
|---|---|
group (in) | Collision group ID |
Returns Collision group. Can also be used as a collision mask.
materialChangeCounter
#include <raisim/collision/material_dirty.hpp>
std::uint64_t materialChangeCounter()Returns Current material change counter value.
notifyMaterialChange
#include <raisim/collision/material_dirty.hpp>
void notifyMaterialChange()Increment the material change counter to invalidate caches.
isSingleBody
#include <raisim/configure.hpp>
bool isSingleBody(ObjectType type)Parameters
| Parameter | Description |
|---|---|
type (in) | Object type. |
Returns True if the type corresponds to a single-body object.
isMovableBody
#include <raisim/configure.hpp>
bool isMovableBody(ObjectType type)Parameters
| Parameter | Description |
|---|---|
type (in) | Object type. |
Returns True if the type is movable (finite mass or articulated).
isMovableSingleBody
#include <raisim/configure.hpp>
bool isMovableSingleBody(ObjectType type)Parameters
| Parameter | Description |
|---|---|
type (in) | Object type. |
Returns True if the type is a movable single body.
isSingleCollisionBody
#include <raisim/configure.hpp>
bool isSingleCollisionBody(ObjectType type)Parameters
| Parameter | Description |
|---|---|
type (in) | Object type. |
Returns True if the type maps to a single collision body.
isPrimitiveCollisionBody
#include <raisim/configure.hpp>
bool isPrimitiveCollisionBody(ObjectType type)Parameters
| Parameter | Description |
|---|---|
type (in) | Object type. |
Returns True if the type is a primitive collision shape.
isMustHaveInertiaDefined
#include <raisim/configure.hpp>
bool isMustHaveInertiaDefined(ObjectType type)Parameters
| Parameter | Description |
|---|---|
type (in) | Object type. |
Returns True if inertia must be specified explicitly for the type.
stringToObjectType
#include <raisim/configure.hpp>
ObjectType stringToObjectType(const std::string &typeName)Parameters
| Parameter | Description |
|---|---|
typeName (in) | Object type string ("sphere", "box", "cylinder", "cone", "capsule", "mesh", "ground", "compound", "heightmap", "articulatedSystem"/"articulated_system", "deformable" or "granular"). |
Returns Parsed ObjectType value, or UNRECOGNIZED.
objectTypeToString
#include <raisim/configure.hpp>
std::string objectTypeToString(ObjectType type)Inverse of stringToObjectType() (ARTICULATED_SYSTEM maps to "articulatedSystem").
Parameters
| Parameter | Description |
|---|---|
type (in) | Object type. |
Returns Lower-case type name, e.g. "sphere" or "ground" for HALFSPACE.
updateContactBodyTransform
#include <raisim/contact_engine/body_update.hpp>
void updateContactBodyTransform(
::contact::Body &body,
const Vec<3> &position,
const Mat<3, 3> &rotation)Set the pose of a collision body and refresh its cached rotation data (and, for planes, the world-frame plane). The rotation is stored as a matrix; transform.rotation is reset to identity.
Parameters
| Parameter | Description |
|---|---|
body (in, out) | Collision body. |
position (in) | World position. |
rotation (in) | World orientation (body-to-world rotation matrix). |
buildContactMeshConvexHull
#include <raisim/contact_engine/contact_build.hpp>
std::shared_ptr<::contact::Mesh> buildContactMeshConvexHull(const std::vector<float> &vertices)Build a convex collision mesh from the convex hull of a point set.
Parameters
| Parameter | Description |
|---|---|
vertices (in) | Packed xyz coordinates. |
Returns The hull mesh, or nullptr if no hull could be built.
validateContactMeshInput
#include <raisim/contact_engine/contact_build.hpp>
template <typename IndexT>
void validateContactMeshInput(
const std::vector<float> &vertices,
const std::vector<IndexT> &indices)Fatal error unless vertices is packed xyz with finite values and indices are triangles with in-range vertex indices.
buildContactMesh
#include <raisim/contact_engine/contact_build.hpp>
template <typename IndexT>
std::shared_ptr<::contact::Mesh> buildContactMesh(
const std::vector<float> &vertices,
const std::vector<IndexT> &indices)Build a collision mesh (with BVH and adjacency) from packed xyz vertices and triangle indices. Invalid input is a fatal error (see validateContactMeshInput()).
template <typename IndexT>
std::shared_ptr<::contact::Mesh> buildContactMesh(
const std::vector<float> &vertices,
const std::vector<IndexT> &indices,
bool convexify)Build a collision mesh, optionally convexified: with convexify the convex hull is used, falling back to the bounding box if the hull cannot be built.
buildContactMeshConvexAabb
#include <raisim/contact_engine/contact_build.hpp>
std::shared_ptr<::contact::Mesh> buildContactMeshConvexAabb(const std::vector<float> &vertices)Returns A box-shaped collision mesh spanning the bounding box of the packed xyz vertices (a zero box if there are none).
buildContactHeightmap
#include <raisim/contact_engine/contact_build.hpp>
std::shared_ptr<::contact::Heightmap> buildContactHeightmap(const raisim::HeightMap &hm)Returns The collision heightmap of a raisim::HeightMap (bounds and tiles built, no triangle mesh).
separator
#include <raisim/helper.hpp>
std::string separator()Returns the platform path separator ("\\" on Windows, "/" elsewhere)
MSLEEP
#include <raisim/helper.hpp>
void MSLEEP(int sleepMs)Sleep the calling thread. Non-positive values return immediately.
Parameters
| Parameter | Description |
|---|---|
sleepMs (in) | duration (ms) |
USLEEP
#include <raisim/helper.hpp>
void USLEEP(int sleepUs)Sleep the calling thread. Non-positive values return immediately.
Parameters
| Parameter | Description |
|---|---|
sleepUs (in) | duration (microseconds) |
getBaseFileName
#include <raisim/helper.hpp>
std::string getBaseFileName(const std::string &fullPath)Parameters
| Parameter | Description |
|---|---|
fullPath (in) | file path |
Returns the file name without directory and (last) extension
getTopDirectory
#include <raisim/helper.hpp>
std::string getTopDirectory(const std::string &fullPath)Parameters
| Parameter | Description |
|---|---|
fullPath (in) | file path |
Returns the name of the directory that contains the file (e.g. "b" for "/a/b/c.txt")
getFileName
#include <raisim/helper.hpp>
std::string getFileName(const std::string &fullPath)Parameters
| Parameter | Description |
|---|---|
fullPath (in) | file path |
Returns the file name including the extension
getFileExtension
#include <raisim/helper.hpp>
std::string getFileExtension(const std::string &fullPath)Parameters
| Parameter | Description |
|---|---|
fullPath (in) | file path |
Returns the last file extension without the dot, or an empty string
getPathName
#include <raisim/helper.hpp>
std::string getPathName(const std::string &fullPath)Parameters
| Parameter | Description |
|---|---|
fullPath (in) | file path |
Returns the full path containing the file (remove the file name in the full path)
fileExists
#include <raisim/helper.hpp>
bool fileExists(const std::string &name)Parameters
| Parameter | Description |
|---|---|
name (in) | file path |
Returns true if a regular file exists at the path
directoryExists
#include <raisim/helper.hpp>
bool directoryExists(const std::string &name)Parameters
| Parameter | Description |
|---|---|
name (in) | directory path |
Returns true if a directory exists at the path
read_png_file
#include <raisim/helper.hpp>
void read_png_file(
const char *file_name,
int &width,
int &height,
std::vector<double> &values,
double scale,
double zOffset)Internal: reads an 8- or 16-bit grayscale PNG as height values (value = pixel * scale + zOffset). Values are stored row by row; within a row the columns are stored from right to left. Fatal for a missing file, a non-grayscale image or another bit depth.
Parameters
| Parameter | Description |
|---|---|
file_name (in) | PNG file path |
width (out) | image width (pixels) |
height (out) | image height (pixels) |
values (out) | width * height values; cleared first |
scale (in) | scale applied to the raw pixel value |
zOffset (in) | offset added after scaling |
operator,
#include <raisim/math.hpp>
template <int n>
ElementRef<DynamicArray> operator,(ElementRef<DynamicArray> ref, double a)template <int n>
ElementRef<Vec<n>> operator,(ElementRef<Vec<n>> ref, double a)template <int n, int m>
ElementRef<Mat<n, m>> operator,(ElementRef<Mat<n, m>> ref, double a)operator<<
#include <raisim/math.hpp>
template <int n>
std::ostream &operator<<(std::ostream &os, const Vec<n> &m)Prints the elements of a vector on one line, separated by spaces.
template <size_t n, size_t m>
std::ostream &operator<<(std::ostream &os, const Mat<n, m> &mat)Prints a matrix row by row, one line per row.
std::ostream &operator<<(std::ostream &os, const VecDyn &m)Prints the elements on one line, separated by spaces.
std::ostream &operator<<(std::ostream &os, const MatDyn &mat)Prints a matrix row by row, one line per row.
cholInv
#include <raisim/math.hpp>
template <size_t n>
static bool cholInv(const double *A, double *AInv)Inverts a symmetric positive-definite n x n matrix using a Cholesky factorization.
Parameters
| Parameter | Description |
|---|---|
A (in) | input matrix, n*n doubles in column-major order |
AInv (out) | inverse of A (full symmetric matrix, column-major); must not overlap A |
Returns false when a pivot of the factorization is at most 1e-12 of its diagonal entry: A is not positive definite, or singular to working precision (a NaN pivot does not count), and AInv is then meaningless
cholInv2
#include <raisim/math.hpp>
template <size_t n>
static void cholInv2(const double *A, double *AInv)Inverts a symmetric positive-definite n x n matrix using a Cholesky factorization (alternative implementation of cholInv()).
Parameters
| Parameter | Description |
|---|---|
A (in) | input matrix, n*n doubles in column-major order |
AInv (out) | inverse of A (full symmetric matrix, column-major) |
quatToRotMat
#include <raisim/math.hpp>
void quatToRotMat(const Vec<4> &q, Mat<3, 3> &R)Converts a quaternion to a rotation matrix.
Parameters
| Parameter | Description |
|---|---|
q (in) | quaternion in (w, x, y, z) order. It must be normalized; a non-unit q yields a matrix scaled by its squared norm. |
R (out) | rotation matrix. If q is the orientation of a body frame B in frame W, then v_W = R * v_B. |
void quatToRotMat(const double *q, Mat<3, 3> &R)Converts a quaternion given as a raw array to a rotation matrix; otherwise identical to the Vec<4> overload.
Parameters
| Parameter | Description |
|---|---|
q (in) | four doubles in (w, x, y, z) order, normalized |
R (out) | rotation matrix |
rotMatToQuat
#include <raisim/math.hpp>
void rotMatToQuat(const Mat<3, 3> &R, Vec<4> &q)Converts a rotation matrix to a quaternion. Inverse of quatToRotMat().
Parameters
| Parameter | Description |
|---|---|
R (in) | proper rotation matrix (orthonormal, determinant +1) |
q (out) | quaternion in (w, x, y, z) order. Its sign is not normalized: w is positive when the trace of R is positive and may be negative otherwise. |
rpyToRotMat_intrinsic
#include <raisim/math.hpp>
void rpyToRotMat_intrinsic(const Vec<3> &rpy, Mat<3, 3> &R)Converts roll-pitch-yaw angles to the rotation matrix R = Rz(yaw) * Ry(pitch) * Rx(roll).
Parameters
| Parameter | Description |
|---|---|
rpy (in) | (roll, pitch, yaw) in radians |
R (out) | rotation matrix |
rpyToRotMat_extrinsic
#include <raisim/math.hpp>
void rpyToRotMat_extrinsic(const Vec<3> &rpy, Mat<3, 3> &R)Converts roll-pitch-yaw angles to the rotation matrix R = Rx(roll) * Ry(pitch) * Rz(yaw) (the reverse composition order of rpyToRotMat_intrinsic()).
Parameters
| Parameter | Description |
|---|---|
rpy (in) | (roll, pitch, yaw) in radians |
R (out) | rotation matrix |
angleAxisToRotMat
#include <raisim/math.hpp>
void angleAxisToRotMat(
const Vec<3> &a1,
const double theta,
Mat<3, 3> &rotMat)Rotation matrix of a rotation by theta about a1 (Rodrigues' formula).
Parameters
| Parameter | Description |
|---|---|
a1 (in) | rotation axis; must be a unit vector (not normalized here) |
theta (in) | rotation angle in radians |
rotMat (out) | rotation matrix |
angleAxisToQuaternion
#include <raisim/math.hpp>
void angleAxisToQuaternion(
const Vec<3> &a1,
const double theta,
Vec<4> &quaternion)Quaternion of a rotation by theta about a1.
Parameters
| Parameter | Description |
|---|---|
a1 (in) | rotation axis; must be a unit vector (not normalized here) |
theta (in) | rotation angle in radians |
quaternion (out) | result in (w, x, y, z) order |
quatMul
#include <raisim/math.hpp>
void quatMul(const Vec<4> &q, const Vec<4> &p, Vec<4> &pq)Hamilton product of two quaternions in (w, x, y, z) order. Despite the output's name, the result is q * p (the rotation p followed by q).
Parameters
| Parameter | Description |
|---|---|
q (in) | left factor |
p (in) | right factor |
pq (out) | the product q * p; must not alias q or p |
void quatMul(const double *q, const double *p, double *pq)Raw-array version of quatMul(): pq = q * p, (w, x, y, z) order; pq must not alias the inputs.
quatInvQuatMul
#include <raisim/math.hpp>
void quatInvQuatMul(const double *q, const double *p, double *pq)Computes pq = conj(q) * p for quaternions in (w, x, y, z) order (q^-1 * p for a unit q); pq must not alias the inputs.
matvecAddDiagonally
#include <raisim/math.hpp>
void matvecAddDiagonally(MatDyn &mat, const VecDyn &diag)Overwrites the diagonal of the square matrix mat with diag. Despite its name it does not add (see addToDiagonal() for that); off-diagonal entries are unchanged. The dimensions are checked only in debug builds.
eulerVecToQuat
#include <raisim/math.hpp>
void eulerVecToQuat(const Vec<3> &eulerVec, Vec<4> &quat)Converts a rotation vector (unit axis times angle in radians) to a quaternion.
Parameters
| Parameter | Description |
|---|---|
eulerVec (in) | rotation vector |
quat (out) | quaternion in (w, x, y, z) order; identity if |eulerVec| < 1e-12 |
quatToEulerVec
#include <raisim/math.hpp>
void quatToEulerVec(const double *quat, double *eulerVec)Converts a unit quaternion to a rotation vector (unit axis times angle). The angle is 2 * acos(w) in [0, 2*pi]; a quaternion with negative w is not flipped, so the angle can exceed pi.
Parameters
| Parameter | Description |
|---|---|
quat (in) | four doubles in (w, x, y, z) order |
eulerVec (out) | three doubles; zero if the norm of the quaternion's vector part is below 1e-12 |
matmul
#include <raisim/math.hpp>
void matmul(const Mat<3, 3> &mat1, const Mat<3, 3> &mat2, Mat<3, 3> &mat)mat = mat1 * mat2. mat may alias mat1 or mat2.
void matmul(const Mat<4, 4> &mat1, const Mat<4, 4> &mat2, Mat<4, 4> &mat)mat = mat1 * mat2. mat may alias mat1 or mat2.
template <size_t i, size_t j, size_t k>
void matmul(const Mat<i, j> &mat1, const Mat<j, k> &mat2, Mat<i, k> &mat)mat = mat1 * mat2 for fixed-size matrices. mat may alias mat1 or mat2.
void matmul(const MatDyn &mat1, const MatDyn &mat2, MatDyn &mat)mat = mat1 * mat2; mat is resized if needed and may alias mat1 or mat2.
void matmul(const MatDyn &mat1, const Mat<3, 3> &mat2, MatDyn &mat)mat = mat1 * mat2 with mat1 of size rows x 3; mat is resized to rows x 3 if needed and may alias mat1.
void matmul(const Mat<3, 3> &mat1, const MatDyn &mat2, MatDyn &mat)mat = mat1 * mat2 with mat2 of size 3 x cols; mat is resized to 3 x cols if needed and may alias mat2.
void matmul(const SparseJacobian &jaco, const VecDyn &vec, Vec<3> &result)result = J * vec, where J is the full 3 x dof Jacobian represented by jaco.
Parameters
| Parameter | Description |
|---|---|
jaco (in) | sparse Jacobian |
vec (in) | vector with dof elements, indexed by jaco.idx (e.g. the generalized velocity) |
result (out) | the 3D product |
matmattransposemul
#include <raisim/math.hpp>
void matmattransposemul(
const Mat<3, 3> &mat1,
const Mat<3, 3> &mat2,
Mat<3, 3> &mat)mat = mat1 * mat2^T. mat must not alias the inputs.
mattransposematmul
#include <raisim/math.hpp>
void mattransposematmul(
const Mat<3, 3> &mat1,
const Mat<3, 3> &mat2,
Mat<3, 3> &mat)mat = mat1^T * mat2. mat must not alias the inputs.
rotmatmul
#include <raisim/math.hpp>
void rotmatmul(const Mat<3, 3> &mat1, const Mat<3, 3> &mat2, Mat<3, 3> &mat)mat = mat1 * mat2 for rotation matrices. Only the first two columns are computed by multiplication; the third is their cross product, which keeps the result right-handed. mat must not alias the inputs.
matmul_fillBot3Rows
#include <raisim/math.hpp>
void matmul_fillBot3Rows(
const Mat<3, 3> &mat1,
const Mat<3, 3> &mat2,
Mat<6, 3> &mat)Writes mat1 * mat2 into rows 3 to 5 of mat; rows 0 to 2 are left untouched.
transposedMatMul
#include <raisim/math.hpp>
template <size_t n, size_t m, size_t l>
void transposedMatMul(
const Mat<m, n> &mat1,
const Mat<m, l> &mat2,
Mat<n, l> &mat)mat = mat1^T * mat2 (the first matrix is transposed). mat must not alias the inputs.
transposed2MatMul
#include <raisim/math.hpp>
template <size_t n, size_t m, size_t l>
void transposed2MatMul(
const Mat<n, m> &mat1,
const Mat<l, m> &mat2,
Mat<n, l> &mat)mat = mat1 * mat2^T (the second matrix is transposed). mat must not alias the inputs.
void transposed2MatMul(
const MatDyn &mat1,
const Mat<3, 3> &mat2,
MatDyn &mat)mat = mat1 * mat2^T with mat1 of size rows x 3. mat must already be rows x 3 (it is not resized) and must not alias mat1.
matScalarMul
#include <raisim/math.hpp>
template <size_t n, size_t l>
void matScalarMul(double scalar, Mat<n, l> &mat)mat *= scalar.
template <size_t n, size_t l>
void matScalarMul(double scalar, const Mat<n, l> &mat1, Mat<n, l> &mat)mat = scalar * mat1. Assigns; the destination's previous contents are irrelevant.
similarityTransform
#include <raisim/math.hpp>
void similarityTransform(
const Mat<3, 3> &R,
const Mat<3, 3> &I,
Mat<3, 3> &mat)mat = R * I * R^T, e.g. to rotate an inertia tensor. I must be symmetric; the result is written symmetric. mat must not alias R.
similarityTransform2
#include <raisim/math.hpp>
void similarityTransform2(
const Mat<3, 3> &R,
const Mat<3, 3> &I,
Mat<3, 3> &mat)mat = R^T * I * R. I must be symmetric; the result is written symmetric. mat must not alias R.
transpose
#include <raisim/math.hpp>
template <size_t n, size_t m>
void transpose(const Mat<n, m> &mat1, Mat<m, n> &mat)mat = mat1^T. mat must not alias mat1.
matvecmul
#include <raisim/math.hpp>
template <size_t n, size_t m>
void matvecmul(const Mat<n, m> &mat1, const Vec<m> &vec1, Vec<n> &vec)vec = mat1 * vec1. vec may alias vec1 only for square matrices.
void matvecmul(const MatDyn &mat1, const VecDyn &vec1, VecDyn &vec)vec = mat1 * vec1; vec is resized if needed and may alias vec1.
void matvecmul(const Mat<3, 3> &mat1, const Vec<3> &vec1, double *vec)vec = mat1 * vec1, written to a 3-element array that must not alias vec1.
void matvecmul(const Mat<3, 3> &mat1, const Vec<3> &vec1, Vec<3> &vec)vec = mat1 * vec1. vec may alias vec1.
matTransposevecmul
#include <raisim/math.hpp>
template <size_t n, size_t m>
void matTransposevecmul(
const Mat<n, m> &mat1,
const Vec<n> &vec1,
Vec<m> &vec)vec = mat1^T * vec1. vec must not alias vec1.
void matTransposevecmul(const MatDyn &mat1, const VecDyn &vec1, VecDyn &vec)vec = mat1^T * vec1; vec is resized if needed and may alias vec1.
matvecmulInvertSgn
#include <raisim/math.hpp>
void matvecmulInvertSgn(
const Mat<3, 3> &mat1,
const Vec<3> &vec1,
Vec<3> &vec)vec = -mat1 * vec1. vec must not alias vec1.
matvecmulThenAdd
#include <raisim/math.hpp>
template <size_t n, size_t m>
void matvecmulThenAdd(
const Mat<n, m> &mat1,
const Vec<m> &vec1,
Vec<n> &vec)vec += mat1 * vec1. vec must not alias vec1.
void matvecmulThenAdd(
const Mat<3, 3> &mat1,
const Vec<3> &vec1,
Vec<3> &vec)vec += mat1 * vec1. vec must not alias vec1.
void matvecmulThenAdd(
const Mat<3, 3> &mat1,
const Vec<3> *vec1,
Vec<3> &vec)vec += mat1 * (*vec1). vec must not alias vec1.
void matvecmulThenAdd(const MatDyn &mat1, const Vec<3> &vec1, VecDyn &vec)vec += mat1 * vec1 with mat1 of size rows x 3; vec must have at least mat1.rows() elements.
matvecmulThenSub
#include <raisim/math.hpp>
void matvecmulThenSub(const MatDyn &mat1, const Vec<3> &vec1, VecDyn &vec)vec -= mat1 * vec1 with mat1 of size rows x 3; vec must have at least mat1.rows() elements.
template <size_t n, size_t m>
void matvecmulThenSub(
const Mat<n, m> &mat1,
const Vec<m> &vec1,
Vec<n> &vec)vec -= mat1 * vec1. vec must not alias vec1.
matTransposeVecmulThenAdd
#include <raisim/math.hpp>
template <size_t m>
void matTransposeVecmulThenAdd(
const MatDyn &mat1,
const Vec<m> &vec1,
VecDyn &vec)vec += mat1^T * vec1. mat1 must have exactly m rows (used as its leading dimension) and vec at least mat1.cols() elements.
template <size_t n, size_t m>
void matTransposeVecmulThenAdd(
const Mat<n, m> &mat1,
const Vec<n> &vec1,
Vec<m> &vec)vec += mat1^T * vec1. vec must not alias vec1.
vecsub
#include <raisim/math.hpp>
template <size_t size>
void vecsub(const Vec<size> &vec1, const Vec<size> &vec2, Vec<size> &vec)vec = vec1 - vec2.
void vecsub(const VecDyn &vec1, const VecDyn &vec2, VecDyn &vec)vec = vec1 - vec2 over vec1.size() elements; vec must already have that size.
template <size_t size>
void vecsub(const Vec<size> &vec1, Vec<size> &vec)vec -= vec1.
productOfSkewMatrices
#include <raisim/math.hpp>
void productOfSkewMatrices(
const Vec<3> &vec1,
const Vec<3> &vec2,
Mat<3, 3> &mat)mat = [vec1]x * [vec2]x, the product of the skew-symmetric (cross-product) matrices of the two vectors.
vecadd
#include <raisim/math.hpp>
void vecadd(const VecDyn &vec1, const VecDyn &vec2, VecDyn &vec)vec = vec1 + vec2 over vec1.size() elements; vec must already have that size.
template <size_t size>
void vecadd(const Vec<size> &vec1, Vec<size> &vec)vec += vec1.
void vecadd(const VecDyn &vec1, VecDyn &vec)vec += vec1 over vec1.size() elements.
template <size_t size>
void vecadd(const Vec<size> &vec1, const Vec<size> &vec2, Vec<size> &vec)vec = vec1 + vec2.
matadd
#include <raisim/math.hpp>
template <size_t n, size_t m>
void matadd(const Mat<n, m> &mat1, Mat<n, m> &mat)mat += mat1.
void matadd(const MatDyn &mat1, MatDyn &mat)mat += mat1; both must have the same dimensions (not checked).
template <size_t n, size_t m>
void matadd(const Mat<n, m> &mat1, const Mat<n, m> &mat2, Mat<n, m> &mat)mat = mat1 + mat2.
matsub
#include <raisim/math.hpp>
template <size_t n, size_t m>
void matsub(const Mat<n, m> &mat1, Mat<n, m> &mat)mat -= mat1.
template <size_t n, size_t m>
void matsub(const Mat<n, m> &mat1, const Mat<n, m> &mat2, Mat<n, m> &mat)mat = mat1 - mat2.
mataddIdentity
#include <raisim/math.hpp>
template <size_t n>
void mataddIdentity(Mat<n, n> &mat)Adds one to every diagonal element of mat.
add_aX
#include <raisim/math.hpp>
template <size_t size>
void add_aX(double a, const Vec<size> &vec1, Vec<size> &vec)vec += a * vec1.
add_b_p_aX
#include <raisim/math.hpp>
template <size_t size>
void add_b_p_aX(
double a,
const Vec<size> &vec1,
const Vec<size> &vec2,
Vec<size> &vec)vec = vec2 + a * vec1.
vecDot
#include <raisim/math.hpp>
template <size_t size>
void vecDot(const Vec<size> &vec1, const Vec<size> &vec2, double &scalar)scalar = vec1 . vec2 (dot product).
template <size_t size>
void vecDot(const double *vec1, const Vec<size> &vec2, double &scalar)scalar = vec1 . vec2, where vec1 is an array of size doubles.
template <size_t size>
double vecDot(const double *vec1, const double *vec2)Returns dot product of two arrays of size doubles.
template <size_t size>
double vecDot(const Vec<size> &vec1, const Vec<size> &vec2)Returns dot product of vec1 and vec2.
double vecDot(const Vec<3> &vec1, const Vec<3> &vec2)Returns dot product of vec1 and vec2.
void vecDot(const VecDyn &vec1, const VecDyn &vec2, double &scalar)scalar = vec1 . vec2 over vec1.size() elements.
vecDivide
#include <raisim/math.hpp>
template <size_t size>
void vecDivide(const Vec<size> &vec1, const double scalar, Vec<size> &vec)vec = vec1 / scalar.
matDivide
#include <raisim/math.hpp>
template <size_t n, size_t m>
void matDivide(const Mat<n, m> &mat1, const double scalar, Mat<n, m> &mat)mat = mat1 / scalar.
cross
#include <raisim/math.hpp>
void cross(const Vec<3> &vec1, const Vec<3> &vec2, Vec<3> &vec)vec = vec1 x vec2 (cross product). vec must not alias the inputs.
void cross(const double *vec1, const Vec<3> &vec2, Vec<3> &vec)vec = vec1 x vec2 with vec1 given as a 3-element array. vec must not alias the inputs.
void cross(const Vec<3> &vec1, const Vec<3> &vec2, double *vec)vec = vec1 x vec2, written to a 3-element array that must not alias the inputs.
void cross(const double *vec1, const double *vec2, double *vec)vec = vec1 x vec2 on 3-element arrays. vec must not alias the inputs.
cross_skip3_skip3_negative
#include <raisim/math.hpp>
void cross_skip3_skip3_negative(
const double *vec1_skip,
const double *vec2,
double *vec)vec = -(vec1 x vec2), where vec1_skip and vec are strided by 3 (elements 0, 3 and 6, e.g. a row of a column-major 3x3 matrix) and vec2 is contiguous.
crossThenAdd
#include <raisim/math.hpp>
void crossThenAdd(const Vec<3> &vec1, const Vec<3> &vec2, Vec<3> &vec)vec += vec1 x vec2. vec must not alias the inputs.
void crossThenAdd(const Vec<3> &vec1, const Vec<3> &vec2, double *vec)vec += vec1 x vec2, accumulated into a 3-element array that must not alias the inputs.
void crossThenAdd(const double *vec1, const double *vec2, double *vec)vec += vec1 x vec2 on 3-element arrays. vec must not alias the inputs.
crossThenSub
#include <raisim/math.hpp>
void crossThenSub(const Vec<3> &vec1, const Vec<3> &vec2, Vec<3> &vec)vec -= vec1 x vec2. vec must not alias the inputs.
crossMulScalarThenAdd
#include <raisim/math.hpp>
void crossMulScalarThenAdd(
const double a,
const Vec<3> &vec1,
const Vec<3> &vec2,
Vec<3> &vec)vec += a * (vec1 x vec2). vec must not alias the inputs.
VecXMatVecThenAdd
#include <raisim/math.hpp>
void VecXMatVecThenAdd(
const Vec<3> &vec1,
const Mat<3, 3> &mat1,
const Vec<3> &vec2,
Vec<3> &vec)vec += vec1 x (mat1 * vec2). vec must not alias vec1.
VecXMatVec
#include <raisim/math.hpp>
void VecXMatVec(
const Vec<3> &vec1,
const Mat<3, 3> &mat1,
const Vec<3> &vec2,
Vec<3> &vec)vec = vec1 x (mat1 * vec2). vec must not alias vec1.
vecScalarMul
#include <raisim/math.hpp>
void vecScalarMul(const double scalar, const Vec<3> &vec, Vec<3> &product)product = scalar * vec.
template <size_t size>
void vecScalarMul(
const double scalar,
const Vec<size> &vec,
Vec<size> &product)product = scalar * vec.
void vecScalarMul(const double scalar, const VecDyn &vec, VecDyn &product)product = scalar * vec over vec.size() elements; product must already have that size.
void vecScalarMul(const double scalar, Vec<3> &product)product *= scalar.
void vecScalarMul(const double scalar, VecDyn &product)product *= scalar.
vecScalarMulThenAdd
#include <raisim/math.hpp>
template <size_t size>
void vecScalarMulThenAdd(
const double scalar,
const double *vec,
Vec<size> &sum)sum += scalar * vec, where vec is an array of size doubles.
void vecScalarMulThenAdd(
const double scalar,
const double *vec,
VecDyn &sum)sum += scalar * vec over sum.size() elements of the array vec.
void vecScalarMulThenAdd(
const double scalar,
const VecDyn &vec1,
const VecDyn &vec2,
VecDyn &sum)sum = scalar * vec1 + vec2 over sum.size() elements (assigns, despite the name).
void vecScalarMulThenAdd(
const double scalar,
const VecDyn &vec,
VecDyn &sum)sum += scalar * vec over sum.size() elements.
template <size_t size>
void vecScalarMulThenAdd(
const double scalar,
const Vec<size> &vec,
Vec<size> &sum)sum += scalar * vec.
vecScalarMulInPlaceThenAdd
#include <raisim/math.hpp>
void vecScalarMulInPlaceThenAdd(
const double scalar,
VecDyn &vec,
VecDyn &sum)Scales vec in place by scalar, then sum += vec, over sum.size() elements.
vecvecCwiseMulThenAdd
#include <raisim/math.hpp>
template <size_t size>
void vecvecCwiseMulThenAdd(
const Vec<size> &vec1,
const Vec<size> &vec2,
Vec<size> &sum)sum += vec1 .* vec2 (element-wise product).
void vecvecCwiseMulThenAdd(
const VecDyn &vec1,
const VecDyn &vec2,
VecDyn &sum)sum += vec1 .* vec2 (element-wise product) over vec1.size() elements.
vecvecCwiseMulThenSub
#include <raisim/math.hpp>
template <size_t size>
void vecvecCwiseMulThenSub(
const Vec<size> &vec1,
const Vec<size> &vec2,
Vec<size> &sum)sum -= vec1 .* vec2 (element-wise product).
void vecvecCwiseMulThenSub(
const VecDyn &vec1,
const VecDyn &vec2,
VecDyn &sum)sum -= vec1 .* vec2 (element-wise product) over vec1.size() elements.
vecvecScalarCwiseMulThenSub
#include <raisim/math.hpp>
template <size_t size>
void vecvecScalarCwiseMulThenSub(
double scalar,
const Vec<size> &vec1,
const Vec<size> &vec2,
Vec<size> &sum)sum -= scalar * (vec1 .* vec2) (element-wise product).
vecvecCwiseMul
#include <raisim/math.hpp>
template <size_t size>
void vecvecCwiseMul(
const Vec<size> &vec1,
const Vec<size> &vec2,
Vec<size> &sum)sum = vec1 .* vec2 (element-wise product).
void vecvecCwiseMul(const VecDyn &vec1, const VecDyn &vec2, VecDyn &sum)sum = vec1 .* vec2 (element-wise product) over vec1.size() elements.
vecScalarMulThenSub
#include <raisim/math.hpp>
template <size_t size>
void vecScalarMulThenSub(
const double scalar,
const Vec<size> &vec,
Vec<size> &sum)sum -= scalar * vec.
template <size_t size>
void vecScalarMulThenSub(
const double scalar,
const double *vec,
Vec<size> &sum)sum -= scalar * vec, where vec is an array of size doubles.
skewSymMat
#include <raisim/math.hpp>
void skewSymMat(const Vec<3> &vec, Mat<3, 3> &mat)mat = [vec]x, the skew-symmetric matrix with mat * a = vec x a.
vecTransposeMatVecMul
#include <raisim/math.hpp>
void vecTransposeMatVecMul(
const Vec<3> &vec,
const Mat<3, 3> &mat,
double &scalar)scalar = vec^T * mat * vec.
addCentrifugalTerm
#include <raisim/math.hpp>
void addCentrifugalTerm(
const Vec<3> &omega,
const Vec<3> &displacement,
Vec<3> &linAcc)linAcc += omega x (omega x displacement), the centripetal acceleration of a point at displacement.
rotationIntegration
#include <raisim/math.hpp>
void rotationIntegration(
Mat<3, 3> &rotationMatrix,
double dt,
const Vec<3> &angVel)Integrates an orientation over dt at a constant angular velocity using the exponential map: rotationMatrix = exp([angVel]x * dt) * rotationMatrix. The angular velocity is therefore expressed in the reference (world) frame. Nothing is done if |angVel| * dt < 1e-11. The result is not re-orthonormalized.
Parameters
| Parameter | Description |
|---|---|
rotationMatrix (in, out) | orientation to update |
dt (in) | time step |
angVel (in) | angular velocity |
void rotationIntegration(
const Mat<3, 3> &initial,
Mat<3, 3> &final,
double dt,
const Vec<3> &angVel)Like the in-place rotationIntegration() but writes final = exp([angVel]x * dt) * initial (a copy of initial if |angVel| * dt < 1e-11).
void rotationIntegration(
Mat<3, 3> &rotationMatrix,
double dt,
const double *angVel)In-place rotationIntegration() with angVel given as a 3-element array.
squaredNormOfDiff
#include <raisim/math.hpp>
template <size_t size>
double squaredNormOfDiff(const Vec<size> &vec1, const Vec<size> &vec2)Returns squared Euclidean norm of vec1 - vec2.
zaxisToRotMat
#include <raisim/math.hpp>
void zaxisToRotMat(const Vec<3> &zaxis, Mat<3, 3> &rotMat)Computes the rotation by the smallest angle that maps the z axis (0, 0, 1) onto zaxis.
Parameters
| Parameter | Description |
|---|---|
zaxis (in) | target direction; must be a unit vector |
rotMat (out) | identity if zaxis is (0, 0, 1), a rotation by pi about x if it is (0, 0, -1) |
addToDiagonal
#include <raisim/math.hpp>
void addToDiagonal(const VecDyn &vec, MatDyn &mat)Adds vec to the first vec.size() diagonal elements of mat. The dimensions are checked only in debug builds.
Prod_func
#include <raisim/math/Operation.hpp>
template <class T1, class T2>
double Prod_func(const T1 &exp1, const T2 &exp2, size_t i, size_t j)Evaluates element (i, j) of the matrix product exp1 * exp2.
Sum_func
#include <raisim/math/Operation.hpp>
template <class T1, class T2>
double Sum_func(const T1 &exp1, const T2 &exp2, size_t i, size_t j)Evaluates element (i, j) of exp1 + exp2.
Sub_func
#include <raisim/math/Operation.hpp>
template <class T1, class T2>
double Sub_func(const T1 &exp1, const T2 &exp2, size_t i, size_t j)Evaluates element (i, j) of exp1 - exp2.
Div_func
#include <raisim/math/Operation.hpp>
template <class T1, class T2>
double Div_func(const T1 &exp1, const T2 &exp2, size_t i, size_t j)Evaluates element (i, j) of the element-wise quotient exp1 / exp2.
Div_S_func
#include <raisim/math/Operation.hpp>
template <class T>
double Div_S_func(const T &exp1, double scalar, size_t i, size_t j)Evaluates element (i, j) of exp1 / scalar.
Prod_S_func
#include <raisim/math/Operation.hpp>
template <class T>
double Prod_S_func(const T &exp1, double scalar, size_t i, size_t j)Evaluates element (i, j) of exp1 * scalar.
Sum_S_func
#include <raisim/math/Operation.hpp>
template <class T>
double Sum_S_func(const T &exp1, double scalar, size_t i, size_t j)Evaluates element (i, j) of exp1 + scalar.
Sub_S_func
#include <raisim/math/Operation.hpp>
template <class T>
double Sub_S_func(const T &exp1, double scalar, size_t i, size_t j)Evaluates element (i, j) of exp1 - scalar.
Sub_SL_func
#include <raisim/math/Operation.hpp>
template <class T>
double Sub_SL_func(double scalar, const T &exp1, size_t i, size_t j)Evaluates element (i, j) of scalar - exp1. Left-scalar evaluators exist because - and / do not commute.
Div_SL_func
#include <raisim/math/Operation.hpp>
template <class T>
double Div_SL_func(double scalar, const T &exp1, size_t i, size_t j)Evaluates element (i, j) of scalar / exp1.
operator-
#include <raisim/math/Operation.hpp>
template <typename T>
Sub_S_op<T> operator-(MatExpr<T> const &u, double scalar)template <typename T>
Sub_SL_op<T> operator-(double scalar, MatExpr<T> const &u)operator/
#include <raisim/math/Operation.hpp>
template <typename T>
Div_S_op<T> operator/(MatExpr<T> const &u, double scalar)template <typename T>
Div_SL_op<T> operator/(double scalar, MatExpr<T> const &u)getInertialAssumingUniformDensity
#include <raisim/object/ArticulatedSystem/JointAndBodies.hpp>
void getInertialAssumingUniformDensity(
Shape::Type shape,
const Vec<4> &shapeParam,
const Mat<3, 3> &rot,
double density,
double &mass,
Mat<3, 3> &inertia)Compute the mass and inertia of a primitive with uniform density. Mass is 0 for other shapes.
Parameters
| Parameter | Description |
|---|---|
shape (in) | Sphere, Box, Capsule or Cylinder (the cylinder/capsule axis is the local z axis) |
shapeParam (in) | sphere {radius}, box {lx, ly, lz}, cylinder/capsule {radius, length of the cylindrical part} [m] |
rot (in) | orientation of the shape; the inertia is returned as rot * I * rot^T |
density (in) | density [kg/m^3] |
mass (out) | mass [kg] |
inertia (out) | inertia about the shape center [kg m^2] |
motorTorqueBounds
#include <raisim/object/ArticulatedSystem/MotorOperatingRegion.hpp>
MotorTorqueBounds motorTorqueBounds(
double stallTorque,
double backEmfDamping,
double peakTorque,
double speed)motorTorqueBounds() with the motor constants evaluated once: both voltage limits are lines of slope -backEmfDamping through +/-stallTorque.
Parameters
| Parameter | Description |
|---|---|
stallTorque (in) | DcMotorParameters::stallTorque() [Nm] |
backEmfDamping (in) | DcMotorParameters::backEmfDamping() [Nm s/rad] |
peakTorque (in) | DcMotorParameters::peakTorque [Nm] |
speed (in) | motor (rotor-side) speed [rad/s] |
Returns the admissible torque interval and the bound that limits each side
MotorTorqueBounds motorTorqueBounds(
const DcMotorParameters &motor,
double speed)Admissible motor torque at motor speed speed [rad/s]. Above the speed at which even full reverse voltage cannot keep the current below the peak, the voltage band no longer reaches the peak-torque band: every admissible voltage drives more than the peak current against the back EMF. The saturated core caps the torque at the peak torque, so the interval collapses to the peak torque that opposes the motion (-peak above the forward overspeed, +peak below the reverse one).
Parameters
| Parameter | Description |
|---|---|
motor (in) | motor parameters |
speed (in) | motor (rotor-side) speed [rad/s] |
Returns the admissible torque interval and the bound that limits each side
clipMotorTorque
#include <raisim/object/ArticulatedSystem/MotorOperatingRegion.hpp>
double clipMotorTorque(
const DcMotorParameters &motor,
double speed,
double torque,
MotorSaturation *saturation=nullptr)Clips a motor torque request to the operating region at motor speed speed.
Parameters
| Parameter | Description |
|---|---|
motor (in) | motor parameters |
speed (in) | motor (rotor-side) speed [rad/s] |
torque (in) | requested motor torque [Nm] |
saturation (out) | the bound that limited the torque (NONE if the request was admissible) |
Returns the admissible motor torque closest to the request
motorOperatingRegionViolation
#include <raisim/object/ArticulatedSystem/MotorOperatingRegion.hpp>
double motorOperatingRegionViolation(
const DcMotorParameters &motor,
double speed,
double torque)Parameters
| Parameter | Description |
|---|---|
motor (in) | motor parameters |
speed (in) | motor (rotor-side) speed [rad/s] |
torque (in) | motor torque [Nm] |
Returns how far [Nm] the torque lies outside the operating region at speed (zero inside)
toString
#include <raisim/sensors/CameraLens.hpp> #include <raisim/sensors/Sensors.hpp>
std::string toString(CameraProjectionType projection)Returns "pinhole" or "fisheye_equidistant".
static std::string toString(Sensor::Type type)Returns Lower-case name of a sensor type ("rgb", "depth", "imu", "spinning_lidar", or "unknown").
cameraDistortionModel
#include <raisim/sensors/CameraLens.hpp>
std::string cameraDistortionModel(CameraProjectionType projection)Returns The distortion-model name for a projection: "equidistant" for fisheye, "none" for pinhole.
cameraLensLowerAscii
#include <raisim/sensors/CameraLens.hpp>
std::string cameraLensLowerAscii(std::string value)Returns A copy of the string with ASCII letters converted to lower case.
cameraProjectionTypeFromString
#include <raisim/sensors/CameraLens.hpp>
CameraProjectionType cameraProjectionTypeFromString(const std::string &value)Parse a projection name (case-insensitive).
Parameters
| Parameter | Description |
|---|---|
value (in) | "fisheye", "fisheye_equidistant", "equidistant", "opencv_fisheye" or "kannala_brandt" select FISHEYE_EQUIDISTANT; anything else selects PINHOLE. |
Returns The parsed projection type.
resolveCameraIntrinsics
#include <raisim/sensors/CameraLens.hpp>
CameraIntrinsics resolveCameraIntrinsics(
const CameraLensModel &lens,
int width,
int height,
double hFOV)Fill in the intrinsics that the lens leaves unset. Missing focal lengths become fx = fy = (width/2) / tan(hFOV/2) for pinhole and (width/2) / (hFOV/2) for fisheye; a missing principal point becomes the image center.
Parameters
| Parameter | Description |
|---|---|
lens (in) | Lens model. |
width (in) | Image width in pixels. |
height (in) | Image height in pixels. |
hFOV (in) | Horizontal field of view in radians. |
Returns The resolved intrinsics in pixels.
cameraMatrix
#include <raisim/sensors/CameraLens.hpp>
std::array<double, 9> cameraMatrix(
const CameraLensModel &lens,
int width,
int height,
double hFOV)Returns The 3x3 camera matrix K of the resolved intrinsics (see resolveCameraIntrinsics()), stored row-major: {fx, 0, cx, 0, fy, cy, 0, 0, 1}.
fisheyeDistortionCoefficients
#include <raisim/sensors/CameraLens.hpp>
std::array<double, 4> fisheyeDistortionCoefficients(const CameraLensModel &lens)Returns The fisheye distortion coefficients {k1, k2, k3, k4}.
Variables
gMaterialChangeCounter
#include <raisim/collision/material_dirty.hpp>
std::uint64_t gMaterialChangeCounterGlobal material change counter used to invalidate cached material data.
RSEVERITY_INFO
#include <raisim/raisim_message_logger.hpp>
constexpr int RSEVERITY_INFOInformational message severity.
RSEVERITY_WARN
#include <raisim/raisim_message_logger.hpp>
constexpr int RSEVERITY_WARNWarning message severity.
RSEVERITY_FATAL
#include <raisim/raisim_message_logger.hpp>
constexpr int RSEVERITY_FATALFatal message severity (invokes the fatal callback).