Mujoco KDL Wrapper  0.1.0
MuJoCo + KDL bridge for robot kinematics and dynamics
Loading...
Searching...
No Matches
mj_kdl Namespace Reference

Classes

struct  AttachmentSpec
 
struct  CameraSpec
 
struct  Env
 
struct  ResetContext
 
struct  ResetInfo
 
struct  ResetOptions
 
struct  Robot
 
struct  RobotSpec
 
struct  SceneObject
 
struct  SceneSpec
 
struct  ToolFrameSpec
 
struct  VideoRecorder
 
struct  Viewer
 

Typedefs

using ResetHook = std::function< void(ResetContext *)>
 

Enumerations

enum class  LogLevel { LogLevel::NONE = 0 , LogLevel::INFO = 1 , LogLevel::WARN = 2 , LogLevel::ERROR = 3 }
 
enum class  Shape { Shape::BOX , Shape::SPHERE , Shape::CYLINDER }
 
enum class  CtrlMode { CtrlMode::POSITION , CtrlMode::TORQUE }
 
enum class  VideoResolution {
  VideoResolution::R360p = 360 , VideoResolution::R480p = 480 , VideoResolution::R720p = 720 , VideoResolution::R1080p = 1080 ,
  VideoResolution::R2K = 1440 , VideoResolution::R4K = 2160
}
 

Functions

void set_log_level (LogLevel level)
 
LogLevel get_log_level ()
 
bool save_model_xml (const mjModel *model, const char *path)
 
bool init_robot_from_mjcf (Robot *r, mjModel *model, mjData *data, const char *base_body, const char *tip_body, const char *prefix="", const ToolFrameSpec *tool=nullptr)
 
bool attach_to_spec (mjSpec *robot_spec, const AttachmentSpec *a)
 
bool build_scene (mjModel **out_model, mjData **out_data, const SceneSpec *spec)
 
void destroy_scene (mjModel *model, mjData *data)
 
bool init_env (Env *env, const SceneSpec *spec)
 
void env_add_robot (Env *env, Robot *robot)
 
ResetInfo reset (Env *env, const ResetOptions *options=nullptr)
 
bool init_window (Viewer *v, Robot *r, const char *title="MuJoCo", int width=1280, int height=720)
 
bool init_window_sim (Viewer *v, Robot *r, const char *title="MuJoCo")
 
void cleanup (Robot *r)
 
void cleanup (Env *env)
 
void cleanup (Viewer *v)
 
bool init_video_recorder (VideoRecorder *vr, mjModel *model, const char *out_path, int width=1280, int height=720, int fps=60)
 
bool init_video_recorder (VideoRecorder *vr, mjModel *model, const char *out_path, VideoResolution resolution, int fps=60)
 
bool record_frame (VideoRecorder *vr, mjModel *model, mjData *data)
 
void cleanup (VideoRecorder *vr)
 
bool step (Robot *s)
 
bool step_n (Robot *s, int n)
 
bool step (Viewer *v, mjModel *m, mjData *d)
 
bool is_running (const Viewer *v)
 
bool render (Viewer *v, const Robot *r)
 
bool render (Viewer *v, mjModel *m, mjData *d)
 
void update (Robot *r)
 
void set_joint_pos (Robot *r, const KDL::JntArray &q, bool call_forward=true)
 
void set_body_pose (mjModel *model, mjData *data, const char *body_name, const double pos[3], const double *quat=nullptr)
 
bool scene_add_object (mjModel **model, mjData **data, SceneSpec *spec, const SceneObject &obj)
 
bool scene_add_object (Env *env, const SceneObject &obj)
 
bool scene_remove_object (mjModel **model, mjData **data, SceneSpec *spec, const std::string &name)
 
bool scene_remove_object (Env *env, const std::string &name)
 
std::string scene_object_site_name (const SceneObject &obj, const char *site_name)
 
bool get_site_frame (const mjModel *model, mjData *data, const char *site_name, KDL::Frame *out)
 
bool get_body_frame (const mjModel *model, mjData *data, const char *body_name, KDL::Frame *out)
 
std::vector< std::string > get_camera_names (const mjModel *model)
 
bool use_camera (Viewer *v, const mjModel *model, const char *name)
 
bool use_camera (VideoRecorder *vr, const mjModel *model, const char *name)
 
void add_skybox_to_spec (mjSpec *spec)
 
void add_floor_to_spec (mjSpec *spec)
 
void add_objects_to_spec (mjSpec *spec, const std::vector< SceneObject > &objects)
 
void configure_spec (mjSpec *spec, const SceneSpec *sc)
 
bool compile_and_make_data (mjSpec *spec, mjModel **out_model, mjData **out_data)
 
void ensure_plugins_loaded ()
 

Variables

LogLevel g_log_level = LogLevel::ERROR
 

Typedef Documentation

◆ ResetHook

using mj_kdl::ResetHook = typedef std::function<void(ResetContext *)>

Definition at line 305 of file mj_kdl_wrapper.hpp.

Function Documentation

◆ cleanup()

void mj_kdl::cleanup ( Env env)

Destroy model/data owned by Env and clear borrowed Robot registrations. Registered Robot objects are not deleted.

◆ env_add_robot()

void mj_kdl::env_add_robot ( Env env,
Robot robot 
)

Register a Robot handle to be synchronised after environment reset. The robot is borrowed; the Env does not delete or clean it up.

Referenced by main(), main(), TEST_F(), TEST_F(), TEST_F(), TEST_F(), TEST_F(), and TEST_F().

◆ init_env()

bool mj_kdl::init_env ( Env env,
const SceneSpec spec 
)

Build a runtime environment from a declarative SceneSpec. The resulting model/data are owned by env and freed by cleanup(Env *).

◆ reset()

ResetInfo mj_kdl::reset ( Env env,
const ResetOptions options = nullptr 
)

Reset the whole environment to a keyframe/default state, call Env::on_reset for user-specific robot/object/task restoration, then sync all registered Robot command ports and clear stale robot forces.

Referenced by main(), main(), TEST_F(), TEST_F(), TEST_F(), TEST_F(), and TEST_F().