MJUtils

namespace MJBasilisk
namespace detail

Typedefs

using mjModelDeleter = mjDeleter<mjModel, mj_deleteModel>
using mjDataDeleter = mjDeleter<mjData, mj_deleteData>
using mjSpecDeleter = mjDeleter<mjSpec, mj_deleteSpec>
using mjVFSDeleter = mjDeleter<mjVFS, mj_deleteVFS>

Functions

template<typename T>
inline std::string getSpecObjectName(T *object)

Returns the name of the given MuJoCo spec object.

template<typename T>
inline void setSpecObjectName(T *object, const std::string &name)

Sets the name of the given MuJoCo spec object.

template<typename ExceptionType = std::runtime_error>
inline void logAndThrow(const std::string &message)

Logs an error via BSKLogger then throws an exception of type ExceptionType.

Template Parameters:

ExceptionType – Exception to throw (default: std::runtime_error).

Parameters:

message – Human-readable error message.

template<typename Target>
inline Target checkedMjtSizeCast(mjtSize value, const std::string &quantityName)

Converts a nonnegative MuJoCo size to another integral size type.

Template Parameters:

Target – Destination integral type.

Parameters:
  • value – MuJoCo size to convert.

  • quantityName – Name used to identify the quantity in an error message.

Throws:

std::overflow_error – If value is negative or exceeds the destination range.

Returns:

The converted size.