Skip to content

Tiny ROS 2 + Gazebo Classic robot with LiDAR and differential drive, designed for reinforcement learning experiments and autonomy demos.

License

Notifications You must be signed in to change notification settings

cvillanue/cubeBot

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

29 Commits
 
 
 
 
 
 

Repository files navigation

cubeBot: ROS 2 + Gazebo Classic

cubeBot2cubeBot1

A tiny cubeBot built for ROS 2 (Humble / Jazzy) with a differential-drive base and a 2D LiDAR - hoping to make this work well for reinforcement-learning experiments and robotics demos. If there's anything wonky please let me know ...it took me a long time to learn all this & getting the basic to work properly - ROS is no joke ya'll lol

It includes:

  • Gazebo Classic world & spawn launch
  • /cmd_vel -> differential-drive control plugin
  • /scan from simulated LiDAR (sensor_msgs/LaserScan)
  • Basic obstacle-avoidance node
  • Random-policy node + scan logger for quick RL prototyping

Quick Start

# 1️ Create a workspace and clone the repo
mkdir -p ~/ros2_ws/src
cd ~/ros2_ws/src
git clone https://github.com/YOUR_USERNAME/cubebot.git
cd ~/ros2_ws

# 2️Install dependencies (Ubuntu 22.04 + ROS 2 Humble)
sudo apt update
sudo apt install -y   ros-humble-gazebo-ros-pkgs   ros-humble-xacro   ros-humble-robot-state-publisher   ros-humble-joint-state-publisher-gui

# 3️Build & source
colcon build --symlink-install
source install/setup.bash

# 4️ Run the simulation 
ros2 launch cubebot cubebot_sim.launch.py

Tips

# If Gazebo says "Address already in use", free the port:
pkill -9 gazebo gzserver gzclient 2>/dev/null

# Switch to a random driving policy instead of obstacle avoidance:
ros2 run cubebot random_policy

Topics

Topic Type Description
/cmd_vel geometry_msgs/Twist velocity command
/odom nav_msgs/Odometry published by diff-drive plugin
/scan sensor_msgs/LaserScan LiDAR range data

TF Frames

odom → base_link - >lidar_link

Reinforcement Learning Notes

  • Observation (example): downsampled LiDAR scan (≈ 36 beams) + linear/angular speeds + previous action
  • Action: [linear_x, angular_z]
  • Reward suggestion:
    +v_forward * dtturn_penalty * |ω|collision_penalty (if min range < threshold)
  • For Gymnasium integration: wrap the environment to publish on /cmd_vel and read /scan + /odom or TF for pose.

Parameters (obstacle_avoider)

Parameter Default Description
linear_speed 0.4 forward velocity
turn_speed 0.8 angular speed when turning
min_range 0.6 minimum LiDAR range before turning
fov_deg 60.0 field of view used for obstacle check

Test Controls

# Move forward
ros2 topic pub -r 10 /cmd_vel geometry_msgs/Twist "{linear: {x: 0.5}, angular: {z: 0.0}}"

# Turn in place
ros2 topic pub -r 10 /cmd_vel geometry_msgs/Twist "{linear: {x: 0.0}, angular: {z: 1.0}}"

Notes

  • Requires Gazebo Classic, not Ignition Gazebo / Fortress.
  • Works with both ROS 2 Humble and ROS 2 Jazzy (update the ros-* package names accordingly).
  • For tele-operation:
    sudo apt install ros-humble-teleop-twist-keyboard
    ros2 run teleop_twist_keyboard teleop_twist-keyboard

❤️ Acknowledgments

About

Tiny ROS 2 + Gazebo Classic robot with LiDAR and differential drive, designed for reinforcement learning experiments and autonomy demos.

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages