bysenseSim

bysenseSim is an open toolset designed to help you gain hands-on experience with bysense. Built on Gazebo, ROS2, and RViz, it provides a comprehensive simulation environment, allowing you to get bysense up and running without requiring physical hardware. Whether you're a beginner exploring robotics or an experienced developer creating complex applications, this repository offers everything you need to start quickly and efficientlyβ€” we bring sensors to walk!

E-mail: welcome@bywerks.com Discord : https://discord.gg/3cqSVjfBsY

Core structure

bysensesim_ws/                      the workspace
β”œβ”€β”€ src/                            Gazebo, ROS2 control, and RViz configuration
β”‚   β”œβ”€β”€ bysense_controller/         low level controller in C++
β”‚   β”œβ”€β”€ bysense_highlevel/          high level control in python, inverse kinematic, IMU, 
β”‚   β”œβ”€β”€ bysensesim/                 Gazebo, Rviz, ROS2 launch files, urdf, yaml control, meshes etc.
β”‚   β”œβ”€β”€ ros2_packages.txt           the packages we use

Getting Started

This repo was tested on the following setup:

- ROS2 Humble 
- Gazebo classic 11+
- Rviz
- Ubuntu 22.04.5 LTS (Release 22.04 Jammy)

Features

bysenseSim features three core components:

bysenseSim

Purpose: Provides a Gazebo simulation environment with full setup, ROS2 control integration, and RViz visualization capabilities.

Features: - Gazebo Integration: Tailored for quadruped robots, including custom world files, optimized update frequency, and seamless functionality. - ROS2 Control Interface: Enables smooth interaction with simulated quadruped components. - Real-Time Visualization: Offers high-performance visualization of robot states and movements in RViz. - URDF and Plugins: Includes an adapted URDF model with plugins, specifically configured to meet Gazebo’s requirements, incorporating friction, IMU, and other essential parameters and plugins.

bysense Controller

Purpose: A low-level C++ controller responsible for fast actuation and stability

Features: - High-Frequency PD Control: Operates at 1 kHz to ensure stable and accurate movements, with customizable PD gains for specific applications. - Real-Time Updates: Enables fast data exchange with the high-level controller for responsive and dynamic performance.

High-Level Controller

Purpose: A Python-based module for controlling the quadruped’s high-level actions, empowering users to design and execute robot missions in simulation.

Features: - RL-Based Walking Policy: Integrates a reinforcement learning policy within the repository, enabling autonomous quadruped walking with pre-trained, adaptive behaviors. - Built-In Actions: Provides essential actions like standup, sit down, and walk, streamlining mission creation. - Flexible Mission Creation: Allows for user-defined mission scripts, ensuring an easy transition from simulation to real hardware.

This dev kit's modularity empowers robotics enthusiasts and professionals alike to design, refine, and execute custom quadruped missions. The inclusion of an RL-based walking policy highlights its advanced capabilities, making it an excellent framework for both learning and high-level development.

Installation

After you have installed the required Ubuntu, ROS2 version with Gazebo and Rviz, we recommend to check if the versions are correct in your terminal and compare it with our txt: ros2_packages.txt

Check if all packages are installed

ros2 pkg list

If the list of the items is the same or similar, continue.

Create a workspace

mkdir -p ~/bysenseSim_ws/src
cd bysenseSim_ws/src

Clone the repository and switch into the workspace bysensesim_ws:

git clone https://github.com/bywerks/bysensesim
cd bysensesim

Build the Package

colcon build --symlink-install

Once this step is done, lets move on.

Launch files: Open Rviz, Joint Publisher and Gazebo

You can find the launch files under bysensesim/launch. We will go now through the most important files:

Source the workspace

If you are already in the workspace folder (bysensesim_ws) run:

source install/setup.bash 

Start Gazebo and RViz

Switch folder into bysense_highlevel.

Use this line of code to start gazebo and RViz next to each other:

ros2 launch bysensesim sim.launch.py 

If no errors pop up in the terminal, you should then get this view:

The first time you start, double check if following are green:

joint_state_broadcaster
effort_controller

If yes, they are loaded and ready to be used in our scripts later.

Start only Gazebo

Use this method if you are only interested to use gazebo alone:

ros2 launch bysensesim gazebo.launch.py

To double check if all is working fine when coding, run in a second terminal in the same folder:

ros2 topic list

as a result you should get:

/clock
/dynamic_joint_states
/effort_controller/commands
/effort_controller/transition_event
/high_level/setpoints
/imu_plugin/out
/joint_state_broadcaster/transition_event
/joint_states
/parameter_events
/performance_metrics
/robot_description
/ros2_grasp/link_states
/ros2_grasp/model_states
/rosout
/tf
/tf_static

once this list is the same you can assume all is loaded and you can continue with use cases below.

Start only RViz

For specific purposes, it makes sense to only start RViz with its link controller:

ros2 launch bysensesim display.launch.py 

You can use this to check joint positions, configurations and read out positions which you would need in your custom scripts.

Run custom code

After you opened Gazebo or RViz it's time to work with custom code. First we switch into the bysense_highlevel folder:

cd src/bysense_highlevel/bysense_highlevel

As mentioned before, the low level in bysense_controller runs at 1kHz in background. Over the ROS2 nodes we will communicate inputs for joints, directions, angles, IMU etc. Many of those examples you find the scripts within the folder above.

Standup and Sitdown Actions

After you opened and run Gazebo open a second terminal and type:

python3 standup.py

Watch the quadruped move from its initial spawn position to perform standup .

Once your mission is done you can sitdown:

python3 sitdown.py

Walk

One of the most important parts of a legged robot are its walking skills. For the initial release we added a kinematic based walking which can be found under:

python3 walk_kinbased.py

The input to this file can be a direction vector to x, y and, if needed, in z. The walking is based on inverse kinematic and the steps are generated in Bezier curves. The walk gait is pretty basic and we plan to extend this in near future.

Change the kp/kd

Go to main.cpp file under bysense controller. Change there the kp/kd values. Close the running apps like Gazebo and/or RViz and rebuild:

colcon build --symlink-install

Would you wish to have yaml file as parameter to change those values? - Let us know!

Next steps

Modular Integration of Sensors

the current robot description file will be wrapped into a more modular approach. This will ensure a easy integration of your sensor and various other payloads.

Bringing a pre-trained policy to walk within Gazebo

Under the high level controller, we are working to get a pre-trained policy to walk within gazebo. The input to this policy is an observation vector based on multiple input parameters like: linear velocity, projected gravity vector, position and velocity of the joints. Next step is to get the policy to run in Gazebo like in here:

This simulation is based on our urdf which is provided in this repo too! So far we experimented with various parameters and could not find the optimal solution to get it to walk optimally in Gazebo. More updates will follow!

Uneven terrain/ground

Initially we started with a ground plane to showcase the base functions. To take full advantage of walking robots we plan to add a uneven terrain/ground

Turn around robot after it has fallen

Another feature we plan to add is to bring the robot to standup back after it has fallen.

Migration to higher Gazebo Version

We plan to upgrade to another Gazebo Version. Let us know which one you prefer!

Extension of Visualization Tools

We do think of adding other tools to visualize parameters in the simulation.

If you have further idea/wishes let us know and join our discord server: https://discord.gg/3cqSVjfBsY

Last updated