[Last generated: Thu 07 Dec 2023 02:38:20 PM EST]
- Mujoco Simulation Packages
# Mujoco Simulation Packages
Mujoco Physics Simulation Package for Waterloo Steel Robot
- Launch Package (includes models) (This Package)
- Graphical User Interface / Direct OnOff-screen Render: uwarl-mujoco-python-viewer
- branching from jx-mujoco-python-viewer
- Main Engine Code uwarl-mujoco-python-engine
- branching from jx-mujoco-python-engine (similar to deepmind/dm_control)
- MuJoCo 2.2.x locking variants jx-mujoco
- [TODO: ROS Integration] for bridging SIL and HIL
- [TODO: Unity Integration] for rendering and realistic camera views
- [TODO: Migration to MuJoCo 3] for rendering higher simulation speeds
- Full Assembly
- Simulation setup
- Contact Physics [Last Edit: 15/Jun/2022]
- [WAM] Ensure Mechanical Params are Verified
- [BHAND] Ensure Mechanical Params are Verified
- [?] [SUMMIT] Ensure Mechanical Params are Verified
- Control Descriptors
- PID control for base
- ROS integration
- Real-time simulation synchronization
- Find solution for convex hull of wagon handle
- Passing all variables in highest level launch file
- ....
:announcement: Starting version 2.1.2, MuJoCo comes with python bindings, no need to look into mujoco_py package (which only works for 210) Migration notes: https://mujoco.readthedocs.io/en/latest/python.html#migration-notes-for-mujoco-py Right now, we will use mujoco-viewer based on https://github.com/rohanpsingh/mujoco-python-viewer TODO: We will migrate to the official viewer in python bindings later: Watch PR: google-deepmind/mujoco#201
- Submodule Update
$ cd submodules $ git submodule update
- Install editable python viewer:
$ cd uwarl-mujoco-python-viewer $ pip install -e .
- Install editable python engine:
$ cd uwarl-mujoco-python-engine $ pip install -e .
Launches the cart manipulation simulation with ROS integration. The launch file will launch:
- Clock publisher for simulation time
- Mujoco Engine and Viewer based on submodules
- ROS controllers which are used for trajectory control of the WAM
- Hardware simulation interface node to connect MuJoCo to ROS controllers
- Trajectory following action server for mobile base
- Rosbag recorder action server
Demo_V09_mujoco.py
node
$ roslaunch waterloo_steel_sim_bringup waterloo_steel_complete_cart_mujoco.launch
These variables can be changed depending on the simulation.
- In
launch/mujocolaunch.launch
paramsim_frequency_mujoco
. This changes the frequency of the node which updates the engine. It is synched to the simulation Hardware Simulation Interface for control of the WAM. - In
components/include_common.xml
paramtimestep
for changing the engines stepsize.
Important
Make sure 1/frequency of the ROS node updating the engine is equal to a multiple of the engine stepsize for real-time simulation.
- In
playground/playground_mobile_wagon_manipulation.xml
comment out the world body and the contact exclusions to simulate without a world. This increases the rendering performance.- You might want to compress the mesh to increase rendering performance, by using MeshLab for example.
- In
components/include_e7_3rd_floor_Dependencies.xml
, the world .stl file is defined. Change to simulate different world. - In
src/main.py
the MuJoCo viewer rate can be defined. - In
src/main.py
the onboard cameras of the Summit and WAM can be enabled. This can be done by passingTrue
in the Engine_update
function. Default value equalsFalse
.
When needing to change the map in which one is simulating in, follow the following path:
- In
playground/playground_mobile_wagon_manipulation.xml
file:
<!-- E7 3rd floor -->
<body name="environment" pos="-1.1 -1.35 -0.6" euler="0 0 0.03">
<include file="../components/include_e7_3rd_floor.xml"/>
</body>
edit the following line to point to the desired map description:
<include file="../components/include_e7_3rd_floor_Dependencies.xml"/>
-
In
.../include_e7_3rd_floor_Dependencies.xml
, you have to point to the stl-file representing the map. -
An stl-representation of a 2D-floor-map can be generated using the
map2gazebo.launch
launch file (instructions are here). -
The map mesh is associated with the name
map_e7_3rd_floor
, and this name is again referenced ininclude_e7_3rd_floor.xml
. -
Best that one creates seperate files for
include_e7_3rd_floor.xml
andinclude_e7_3rd_floor_Dependencies.xml
when switching to a new simulation map, for better readability.
Here, we detail out the process to be followed for carrying out Peg-in-Hole experiments in MuJoCo:
- In the same post as above, install the recommended repo called
obj2mjcf
, that can be found here. MuJoCo can use Wavefront OBJ.obj
files directly. - If you have the part as a CAD-file, you will need to sve it as either an
IGES
or.stp
format.- AutoDesk Fusion 360 has a paid add-on to perform the conversion directly. It does not support exporting
.obj
natively. - SolidWorks also cannot export it natively.
- AutoDesk Fusion 360 has a paid add-on to perform the conversion directly. It does not support exporting
- Use FreeCAD to convert to Wavefront OBJ
.obj
(there's apparently another.obj
format in the list which is not called Wavefront OBJ; have not tested the other one out). - In a folder, keep the
.obj
files (along with its corresponding.mtl
file; material description) in a folder. - The call to the
obj2mjcf
function can be made as follows:
obj2mjcf --obj-dir ~/folder/having/obj_files --save-mjcf --compile-model --decompose
- For every
.obj
file it finds, it will convert it into a set of convex-shapes that can be assembled together o get-back the original non-convex shape.
In order to test how does the mesh look like, set-up the .obj' files as demonstrated in this
.xml` file. Some things to keep in mind are as follows:
- Press
CTRL
+R
to check the shape of the mesh that MuJoCo used (after taking its convex-hull). This is a great-way of trouble-shooting the cause of possible no Peg-in-Hole action. - There are two sets of meshes that are being deployed: one under Group 0, and another under Group 1. By default, the MuJoCo viewer will only display (geom)etric-bodies that are labled as
1
(in-fact,geom
-tags will be labeled as0
by default, unless it is set to some other group-number). - The last thing that you need to be aware of is the effect of
contype
link andconaffinity
link. They are a 32-bit tag that helps pair what pair of bodies are allowed to collide based upon both having a common bit that is 1. So, acontype=1
(0x0001) is allowed to experience collisions with a body having aconaffinity=3
(0x0011) (a common 1 bit between 0x0001 and 0x0011), but not with a body havingconaffinity=2
(0x0010) (no common 1 bit between 0x0001 and 0x0010). This can become a source of headache if you use different meshes for visualization (MuJoCo has ended up transforming a part into its convex-hull) and collision (a se of bodies were provided by the user which were individually convex). Thus, while the later has a hole in it to perform Peg-in-Hole, the former does not. So, if we want to turn-off collisions between a set of meshes, especialyy ones that are just being used for visualization, setcontype=0
andconaffinity=0
.
If you have tried to place a robot or object between the walls of a map, you will have noticed that the said object disappears. That's because the corridor is not hollow and its convex-hull had been used by MuJoCo.
A corridor in a map, as the one shown above, is composed of walls. When you obtain an stl
file from the .pgm
file of the 2D-map, all the walls, whether disjoint or not, are stored together, as can be attested by the fact that when hovering the mouse over a segment of the corridor wall, all the walls (disjoint or not) get highlighted. It is not clear wheter the obj2mjcf
program can seperate out such disjoint objects, that were saved in the same stl
-file, or not. So, here, we highlight the steps needed to be followed for appropriately modelling the corridor-walls:
Upon opening FreeCAD,
- Import the corridor-mesh you want to split. When hovering the mouse over one of the walls, the whole corridor, which was earlier [unselected], becomes [selcted]. We need to partiotion these dis-joint walls so that we can convexify each dis-joint wall separately.
This way, we can split-apart rooms and other corridors so that we can convexify each cut segment. DO NOT attempt to cut for the sake of convexifying the corridor. That's this (link) procedure's job. Our job is only to split the corridor into disjoint continuous walls. In this example we may not need to convexify the walls, but in case of an L-shaped wall (as seen here), we will need to convexify that segment.
.
├── CITATION.cff
├── LICENSE
├── README.md
├── components
│ ├── meshes
│ │ ├── bases
│ │ ├── meshes_bhand
│ │ └── ...
│ ├── robots
│ │ ├── wam_7dof_wam_bhand.urdf.xacro
│ │ └── waterloo_steel_mujoco.urdf.xacro
│ ├── urdf
│ │ ├── bases
│ │ ├── wagon
│ │ ├── wam
│ │ └── wheels
│ ├── include_common.xml
│ ├── include_{assembly-name}_Chain.xml
│ ├── include_{assembly-name}_Dependencies.xml
│ ├── include_{assembly-name}_actuators.xml
│ └── ...
├── documentation
│ └── ...
├── include
│ └── mujoco_ros_control
│ │ ├── mujoco_ros_control.h
│ │ ├── robot_hw_sim_plugin.h
│ │ └── robot_hw_sim.h
├── meshes
│ ├── maps_thirdfloor
│ │ ├── map_e7_3_v6.stl
│ │ └── ...
│ ├── meshes_{module-name}
│ │ ├── {3D-model-component-name}.stl
│ │ └── ...
│ └── ...
├── playground
│ ├── playground_{playground-name}.xml
│ └── ...
├── src
│ ├── {scripts}.py # [launch files]
│ └── ...
├── submodules
│ ├── uwarl-mujoco-python-viewer # [Mujoco Render/Interaction GUI]
│ └── uwarl-mujoco-python-engine # [Main engine code]
└── textures
│ └── ...
x
[ 5 directories, # files ]
- WAM sim file is a CORRECTED and MODIFIED version based on the official archived MuJoCo model made by Vikash kumar
- Findings: The original model has collision disabled, and parameters are incorrectly populated
- Note: We have modified the original model based on the given stl files completely, and configured MoI based on the Official Barrett WAM Specification.
- Specifically, we made exactly the same as described in the document, and removed incorrect quaternion parameters for
inertial
, and populated theinertial
purely based on the centre of the mass and translated the coordinate frames to the stl model frame (manually)
- Specifically, we made exactly the same as described in the document, and removed incorrect quaternion parameters for
- Shall you have any concern with the parameters, kindly open an issue.
Joints | MOI |
---|---|
- Install MuJoCo 2.2.x via
$ sudo pip install mujoco
- Download MuJoCo 2.2.x release package from https://github.com/deepmind/mujoco/releases
- The package "opencv-python-headless", which is installed during the process of setting-up the workspace (see the list of commands execcuted during the process), must be replaced with "opencv-python" Source:
$ pip uninstall opencv-python-headless
$ pip install opencv-python
Otherwise, the window for MuJoCo will not open, and the simulation will crash.
- M1 Macbook Pro 14"
- Ubuntu 20.04
- [TBD] WINDOWS ---x
- Make directory
MuJoCo_v2.2
under/Applications
- Copy all files from MuJoCo 2.2.x release dmg into
/Applications/MuJoCo_v2.2
- The directory for the
.dylib
has been modified to/Applications/MuJoCo_v2.2/MuJoCo.app/Contents/Frameworks
under thissubmodules/jx-mujoco
The current MuJoCo-ROS integration is shown below:
In detail, zoomed in on the Hardware Simulation Interface:
To find more details on the ROS integration of the MuJoCo simulator, see the pdf file in the documentation folder.