Getting Started with Residual Force Control (RFC)

Jul 8, 2021 | Data Science

Welcome to the exhilarating world of Residual Force Control (RFC)! This guide aims to walk you through the essential steps to implement RFC for agile human behavior imitation and extended motion synthesis, as laid out in the research paper from NeurIPS 2020.

Understanding the Basics of RFC

Imagine RFC as a skilled dancer who, based on a few specific moves, can mimic countless intricate performances. Just like that dancer learns from each performance, the RFC framework uses motion data to replicate agile behaviors seamlessly, allowing for the synthesis of complex motions. Whether it’s a ballet pirouette or an impressive backflip, RFC empowers machines to deliver truly captivating movements.

Installation Process

Before diving into the implementation, let’s ensure you have all the required components set up on your machine.

Dataset and Pretrained Models

  • The CMU mocap data is included in the datacmu_mocap folder.
  • Pretrained models are stored in resultsmotion_im, where each subfolder corresponds to a training configuration file.
  • The configs you can choose from include:
    • 0506 (ballet1)
    • 0507 (ballet2)
    • 0513 (ballet3)
    • 8801 (backflip)
    • 9002 (cartwheel)
    • 9005 (jumpkick)
    • 9008 (side flip)
    • 9011 (handspring)

Environment Requirements

  • Tested OS: MacOS, Linux
  • Python: Version 3.6

Step-by-step Installation

  1. Install the dependencies:
    pip install -r requirements.txt
  2. Install MuJoCo by following the steps here. Note that the mujoco-py binding is installed in step 1.
  3. Set the following environment variable to improve multi-threaded sampling performance:
    export OMP_NUM_THREADS=1

Quick Demo

Once installed, you can visualize the pretrained policy using the following command:

python motion_imitation/vis_im.py --cfg 0506 --iter 1000

Here, 0506 corresponds to the configuration file motion_imitationcfg0506.yml, which uses motion data from the CMU mocap database. For a full list of configurations, see the motion_imitationcfg folder.

Keyboard Shortcuts for GUI

Key Functionality
spacePause/Resume animation
weGo to first/last frame
leftrightPrevious/next frame
dfSlow down/speed up
gToggle loop
sToggle reverse

Training Your RFC Policy

To train your own policies using other motion clips, you first need to prepare your training data.

Preparing Training Data

For motion clips used in the paper, the data has already been processed. If you want to use additional motion clips from the CMU mocap database:

  1. Download the .amc mocap file and place it inside datacmu_mocap/amc.
  2. Run the following script:
    python motion_imitation/data_process_convert_cmu_mocap.py --amc_id 05_06 --out_id 05_06_test --render

This command will launch a GUI to visualize the motion clip, where you can adjust it and save the training pickle file (05_06_test.p) in datacmu_mocap/motion.

Training the RFC Policy

Create your configuration file using 0506.yml as a template, ensuring to set motion_id to the processed motion. Run the command:

python motion_imitation/motion_im.py --cfg 0506 --num_threads max_num_CPU_threads_you_have

This will save your models and logs into resultsmotion_im/0506.

Troubleshooting

If you encounter issues during the installation or running of the code, here are some troubleshooting tips:

  • Ensure all dependencies are correctly installed, particularly MuJoCo.
  • Double-check that the environment variable for multi-threading is set.
  • If the GUI does not display properly, check your graphics drivers.

For more insights, updates, or to collaborate on AI development projects, stay connected with fxis.ai.

Conclusion

At fxis.ai, we believe that such advancements are crucial for the future of AI, as they enable more comprehensive and effective solutions. Our team is continually exploring new methodologies to push the envelope in artificial intelligence, ensuring that our clients benefit from the latest technological innovations.

Stay Informed with the Newest F(x) Insights and Blogs

Tech News and Blog Highlights, Straight to Your Inbox