Class MuJoCoSimulator
Defined in File mujoco_simulator.h
Class Documentation
-
class MuJoCoSimulator
MuJoCo’s physics engine with rendering and basic window mouse interaction.
It’s implemented as a singleton class, which circumvents the problem of using global function pointers for the control callback.
User code interfaces this class by getting an instance and calling static functions on it. It’s designed to run with an independent simulation rate, disjoint from ROS2-control in a separate thread.
Public Functions
-
MuJoCoSimulator(const MuJoCoSimulator&) = delete
-
MuJoCoSimulator &operator=(const MuJoCoSimulator&) = delete
-
MuJoCoSimulator(MuJoCoSimulator&&) = delete
-
MuJoCoSimulator &operator=(MuJoCoSimulator&&) = delete
-
void keyboardCBImpl(GLFWwindow *window, int key, int scancode, int act, int mods)
-
void mouseButtonCBImpl(GLFWwindow *window, int button, int act, int mods)
-
void mouseMoveCBImpl(GLFWwindow *window, double xpos, double ypos)
-
void scrollCBImpl(GLFWwindow *window, double xoffset, double yoffset)
-
void controlCBImpl(const mjModel *m, mjData *d)
-
int simulateImpl(const std::string &model_xml, const std::string &mesh_dir)
-
void read(std::vector<double> &pos, std::vector<double> &vel, std::vector<double> &eff, std::vector<double> &curr)
-
void write(const std::vector<double> &pos)
Public Members
-
mjModel *m = NULL
-
mjData *d = NULL
-
mjvCamera cam
-
mjvOption opt
-
mjvScene scn
-
mjrContext con
-
bool button_left = false
-
bool button_middle = false
-
bool button_right = false
-
double lastx = 0
-
double lasty = 0
-
const int svh_dof = 9
-
std::vector<double> pos_cmd
-
std::vector<double> pos_state
-
std::vector<double> vel_state
-
std::vector<double> eff_state
-
std::vector<double> curr_state
-
std::map<int, int> mujoco_idx = {{0, 1}, {1, 0}, {2, 6}, {3, 5}, {4, 9}, {5, 8}, {6, 17}, {7, 13}, {8, 12},}
-
std::map<int, std::pair<double, int>> transmissions = {{0, {1.0, 1}}, {1, {1.0, 0}}, {2, {1.01511, 0}}, {3, {1.44889, 0}}, {4, {0.5, 8}}, {5, {1.0, 3}}, {6, {1.0, 2}}, {7, {1.0450, 2}}, {8, {1.0, 5}}, {9, {1.0, 4}}, {10, {1.0454, 4}}, {11, {1.0, 1}}, {12, {1.0, 8}}, {13, {1.0, 7}}, {14, {1.35880, 7}}, {15, {1.42307, 7}}, {16, {0.5, 8}}, {17, {1.0, 6}}, {18, {1.3588, 6}}, {19, {1.42093, 6}},}
-
std::mutex state_mutex
-
std::mutex command_mutex
Public Static Functions
-
static inline MuJoCoSimulator &getInstance()
-
static void keyboardCB(GLFWwindow *window, int key, int scancode, int act, int mods)
-
static void mouseButtonCB(GLFWwindow *window, int button, int act, int mods)
-
static void mouseMoveCB(GLFWwindow *window, double xpos, double ypos)
-
static void scrollCB(GLFWwindow *window, double xoffset, double yoffset)
-
static void controlCB(const mjModel *m, mjData *d)
-
static int simulate(const std::string &model_xml, const std::string &mesh_dir)
-
MuJoCoSimulator(const MuJoCoSimulator&) = delete