Skip to content

phamthekhang632/simple_humanoid_controller

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

37 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Simple Humanoid Controller

This is a simple controller example for the JVRC-1 robot using mc_rtc framework.

The controller achieves the following:

  1. The left-hand moves to (0.5, 0.25, 1.1) with orientation (0, 0.7, 0, 0.7) (w, x, y, z)
  2. The left-hand moves back to its initial position
  3. The right-hand moves to (0.5, -0.25, 1.1) with orientation (0, 0.7, 0, 0.7)
  4. The right-hand moves back to its initial position
  5. Both hands move to their respective specified position
  6. Both hands go back to their initial position
  7. Repeat steps 1 to 6

While a single hand is moving, the robot looks at the moving hand. When both hands are moving, the robot looks forward.

Demo video

Demo

Requirements

  • mc_rtc
    • mc_rtc_superbuild is provided with mc_rtc. "It will clone, update, build, install all of mc_rtc dependencies, mc_rtc itself and downstream projects."
  • RViZ: This is technically preinstalled by mc_rtc_superbuild. However, if you are cloning from the link above, you will need to turn on ROS support
    // .\CMakePresets.json - inside your preset of choice
    "WITH_ROS_SUPPORT": "ON"
  • X11
    • Linux/Ubuntu: Ubuntu LTS should already come bundled with X11. Other distributions of Linux should also come with it pre-installed; if not, install it using your package manager.
    • Macos: Install XQuartz and set it up
    • Windows: Install VcXsrv. Run XLaunch:

RViZ and X11 are not required if you are using other methods for visualization.

Windows

If you are on Windows, you can use jammy container from this repository. There are some adjustments to make the installation smoother. You still need to install Docker and VcXsrv. Check the branch installation for more details.

Usage

The following instructions assume you are using mc_rtc_superbuild in a devcontainer.

If this is your first time opening the container, configure git

git config --global user.name "Full Name"
git config --global user.email "your.email@provider.com"

After installing mc_rtc_superbuild, clone this repository in extensions

cd extensions
git clone https://github.com/phamthekhang632/simple_humanoid_controller.git

Building mc_rtc environment. The preset name might be different depending on which preset you have ROS support turned on.

cd ..
cmake --preset relwithdebinfo

Build the projects

cmake --build --preset relwithdebinfo -j

Running controller

source /home/vscode/workspace/install/setup_mc_rtc.sh
mc_rtc_ticker -f extensions/simple_humanoid_controller/etc/SimpleHumanoidController.in.yaml

You should have a working controller and its visualization similar to the demo. For more instructions on how to install mc_rtc, please refer to the official website or mc_rtc_superbuild GitHub repo.

For more options, you can run mc_rtc_ticker --help

mc_rtc_ticker --help                                                                        

mc_rtc_ticker options:
  --help                           Show this help message
  -f [ --mc-config ] arg           Configuration given to mc_rtc
  -S [ --step-by-step ]            Start the ticker in step-by-step mode
  --run-for arg                    Run for the specified time (seconds)
  -s [ --no-sync ]                 Synchronize ticker time with real time
  -r [ --sync-ratio ] arg          Sim/real ratio for synchronization purpose
  -l [ --replay-log ] arg          Log to replay
  -m [ --datastore-mapping ] arg   Mapping of log keys to datastore
  -g [ --replay-gui-inputs-only ]  Only replay the GUI inputs
  -c [ --continue-after-replay ]   Continue after log replay
  -e [ --exit-after-replay ]       Exit after log replay
  --replay-outputs                 Enable outputs replay (override controller)

Visualization

In another terminal, open RViZ window

source /home/vscode/workspace/install/setup_mc_rtc.sh
ros2 launch mc_rtc_ticker display.launch

If you have an error here:

  • Fails because ROS is missing → ensure "WITH_ROS_SUPPORT": "ON"
  • RViZ cannot connect to X11 → check DISPLAY variable and X server in devcontainer.json

Summary

# clone mc_rtc_superbuild
git clone https://github.com/mc-rtc/mc-rtc-superbuild.git
# clone simple_humanoid_controller
cd extensions
git clone https://github.com/phamthekhang632/simple_humanoid_controller.git
cd ..
# building
cmake --preset relwithdebinfo
cmake --build --preset relwithdebinfo -j
# running
source /home/vscode/workspace/install/setup_mc_rtc.sh
mc_rtc_ticker -f extensions/simple_humanoid_controller/etc/SimpleHumanoidController.in.yaml
# for visualization
source /home/vscode/workspace/install/setup_mc_rtc.sh
ros2 launch mc_rtc_ticker display.launch

FSM

mc_rtc provides a finite-state machine (FSM) for managing controller logic through states and transitions. An FSM-based version of this controller is available in the fsm branch.

To try the FSM version, switch to fsm branch:

git checkout fsm

Then rebuild and run the controller as before.

Demo video

Demo

About

Building a simple humanoid controller based mc_rtc framework.

Topics

Resources

Stars

Watchers

Forks