Skip to content

Xianqi-Zhang/FLAM

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

19 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

FLAM: Foundation Model-Based Body Stabilization for Humanoid Locomotion and Manipulation

Installation

  • Create a conda environment:

    conda env create -f environment.yaml
    conda activate humanoid
    
  • Install HumanoidBench benchmark.

    cd src/env
    pip install -e .
    
  • Download data.zip, unzip, and put it in src/pkgs/RoHM/data. (You can directly download data.zip, or download each part from the following links.)

    The directory structure of /src/pkgs/RoHM/data is - body_models: SMPL-X body model - checkpoints: RoHM checkpoints - eval_noise_smplx: Pre-computed motion noise for RoHM - smplx_vert_segmentation.json: SMPL-X vertices segmentation

  • NOTE:

    • More info can be found in HumanoidBench and RoHM.
    • If you download the environment from HumanoidBench, please replace robots.py and wrapper.py, since they have been modified to get camera pose and robot global info, specifically,
      class H1 in robots.py
      - camera_pose()
      - global_positioin()
      - global_orientation()
      
      class ObservationWrapper in wrapper.py
      - observation_space()
      - get_obs() 
      
    • The interface of RoHM has been modified to facilitate calling.

Training

  • Fill in your WANDB_API_KEY in the train.py. (wandb related settings can be found in config_model.py.)

    os.environ['WANDB_API_KEY'] = 'xxxx'
    
  • The humanoid task is set in src/config/config_env.py, and can be changed according to choices.

    group.add_argument('--env', default='h1hand-run-v0', help='e.g. h1hand-walk-v0')
    
  • Finally, just python script.

    python train.py
    
  • NOTE:

    • config_env.py: environment related.
    • config_model.py: the proposed method FLAM and the basic policy TD-MPC2 related.
    • config_rohm.py: the foundation model RoHM related. Just leave it alone.

Training Curves

  • Training curves can be found in results/data_vis.
  • The results of baselines are taken from Humanoid-Bench and CQN-AS.
  • The results of CQN-AS on h1hand-sit_hard-v0, h1hand-balance_hard-v0, h1hand-stair-v0, h1hand-slide-v0, and h1hand-pole-v0, are reproduced accroding to the official implemention of CQN-AS.
  • For visualization, just python *.py.

Possible Problems and Solutions

1. 'GLIBCXX_3.4.30' not found.

conda install -c conda-forge libstdcxx-ng

2. MESA-LOADER: failed to open swrast/zink.

sudo apt install libgl1 libglx-mesa0 libgl1-mesa libgl1-mesa-glx
sudo apt install libgl1-mesa-dev libgl1-mesa-dri
sudo mkdir /usr/lib/dri
sudo ln -s /usr/lib/x86_64-linux-gnu/dri/swrast_dri.so /usr/lib/dri/swrast_dri.so
sudo ln -s /usr/lib/x86_64-linux-gnu/dri/zink_dri.so /usr/lib/dri/zink_dri.so

3. Failed to initialize OpenGL.

  • Could not get EGL display.
  • Cannot initialize a EGL device display.
  • AttributeError: module 'OpenGL.EGL' has no attribute 'EGLDeviceEXT'.
# * Reference: https://github.com/saqib1707/RL-Robot-Manipulation
conda install -c conda-forge glew
pip install pyrender PyOpenGL-accelerate
pip install pyopengl==3.1.4

4. AttributeError: 'mujoco._structs.MjModel' object has no attribute 'cam_orthographic'.

pip install dm-control==1.0.19

5. 'isnan' not supported for the input types, and the inputs could not be safely coerced to any supported types according to the casting rule ''safe'.

# * Please uninstall numpy and reinstall.
conda remove --force numpy
pip uninstall numpy
pip install numpy==1.23.4

6. AttributeError: 'TensorWrapper' object has no attribute 'seed'.

pip install gymnasium==0.29.1

7. ERROR: ld.so: object '/usr/lib/x86_64-linux-gnu/libGLEW.so' from LD_PRELOAD cannot be preloaded (cannot open shared object file): ignored.

sudo apt install mesa-utils glew-utils libglew-dev

8. Fatal error: GL/osmesa.h: No such file or directory

sudo apt install libosmesa6-dev
  • NOTE:
    • The code is tested on Ubuntu 20.04 and Linux Mint 22, packages maybe not found in your OS. apt-cache search package-name can be used to search relative packages.

Misc: Code Insights, Lessons, and Suggestions

  1. To simplify implementation, the robot's global orientation is replaced with that of the pelvis joint. As a result, when visualizing long trajectory, you may notice a gradual deviation in their global orientation.
  2. The foundation model RoHM appears to be sensitive to certain random seeds. In other words, if a result from [0, 1, 2] is suboptimal, you can try 10.
  3. TD-MPC2 is an excellent method, but it is extremely slow. Our experiments, including parameter tuning and formal evaluations, took over two months using four RTX 3090 GPUs (and even stronger). You can attempt to speed up the algorithm, but avoid using env parallelism, whether with AsyncVectorEnv or SubprocVecEnv, as it tends to flatten the learning curve. Don't waste time on this, this is the biggest lesson I learned from this work. At least, that was the outcome of my attempts.
  4. TODO. (I'll provide updates if I recall anything else.)

Citation

@article{zhang2025flam,
  title={FLAM: Foundation Model-Based Body Stabilization for Humanoid Locomotion and Manipulation},
  author={Zhang, Xianqi and Wei, Hongliang and Wang, Wenrui and Wang, Xingtao and Fan, Xiaopeng and Zhao, Debin},
  journal={arXiv preprint arXiv:2503.22249},
  year={2025}
}

References

This implementation is based on the following repo:

Releases

No releases published

Packages

No packages published

Languages