Artful Bytes

A blog about building and programming hardware.

Bots2D

A C++ framework for simulating robotics in 2D.

Background

While building my sumobot I found myself wanting to simulate my driving strategy. My sumobot is simple, so I didn't need a fancy 3D-simulator, and I went looking for a 2D-simulator instead. To my surprise, I couldn't find an obvious candidate, so I decided to build my own.

Features

My initial plan was to build a 2D-simulator only for simulating sumobots, but I ended up creating a more general 2D simulation framework featuring:

  • Open-source (MIT license)
  • C++
  • Linux and Windows support
  • Physics based on Box2D
    • Top-view and side-view
  • Lightweight rendering using OpenGL, GLFW, GLAD and ImGui
    • Basic shapes, Texture, Sprite animation
  • Robotics assets
    • Complete robots (sumobot and line-follower)
    • Sensors (range sensor, line detector)
    • Actuators (DC-motor)
    • Playgrounds (Sumobot dohyo, Line follower path)
    • Isolated controller code (easy to transfer to a real MCU)
    • It's easy to add new assets...

You can read more about the project in my lengthy blog post.

Source code

You find the code over at Github.

Images