Coder Social home page Coder Social logo

rsim's Introduction

RSim

rsim is simple, 2D robotic simulator. It is intended for testing implementations of trajectory tracking controllers.

While the simulator is built in Rust, it provides a simple C interface for implementing controllers and loading them in simulated robots.

Installation

First, you should have a working rust toolchain : https://doc.rust-lang.org/cargo/getting-started/installation.html

sudo apt install libasound2-dev libudev-dev   # install uncommon dependencies
git clone https://github.com/arthur-bit-monnot/rsim.git
cd rsim
cargo build --release       # build (might be long)
ln -s target/release/rsim . # link executable into the current directory

At this point you should have an executable called rsim in your current directory.

Running your first simulation

First you need to build your controller.

cd controller/
make

This should have created a shared library file controller/libdummy_controller.so. This implements a (not so smart) controller and provides it as a shared library.

Then you need your environment. An environment is a 2D image, where each pixel represents 10x10 centimeters. A black pixel is interpreted as an obstacle. Look at the prexisting maps in maps/ and choose one to use, for instance maps/base.jpg.

To run a simulation, you should provide rsim with a controller and a map. For instance:

./rsim --controller controller/libdummy_controller.so --map maps/base.jpg

The expected outcome is that the robot moves towards the target point (red cross). However, not being smart enough to avoid an obstacle it stops to avoid a collision. After one minute, the simulation will timeout (you can also exit early by closing the window or pressing escape).

The purple points on the visualisation depicts obstacles that are seen by the robot's laser scan.

You can change the target point (represented as a red cross) by clicking on the map.

You can look at all the available options of rsim with:

rsim -h

Making your own controller

To make you own controller you need to :

  • create a implementation of the controller's plugin interface. This interface is defined controller/controller.h and you can find an example implementation in controller/dummy_controller.c.
  • you need to compile this controller as a shared library (a .so file on linux). The Makefile in controller/ shows how to do this for the dummy controller.
  • You need to provide it to RSIM as a command line argument ./rsim --controller path/to/controller.so

The compiler interface defines common data types and a set of predefined functions that will be invoked when new sensor data is available.

Making you own map

A map is simply an image where a pixel represents a 10cm by 10cm area. We consider that a pixel is occupied if it is black. You can make your own maps and provide them to rsim with the -m option. Look into the maps/ directory for two example maps (note that empty.jpg contains no obstacles).

Vehicles models

The simulator supports the simple car model and the differential drive model for vehicles. For simplicity the robot is represented as a disc both for visualisation and collision checking.

The pose of the robot is given by a tuple (x, y, theta) where (x,y) represent its absolute position in a 2D space and theta is its orientation in radians. As command, the robots expects a tuple (u_v, u_rot) where u_v controls the velocity and u_rot controls the rotation.

rsim uses the simple car model as a default but the user can swith to a differential drive with --in-place command line option

Dynamics of simple car model

dx = u_v * cos(theta)
dy = u_v * sin(theta)
dtheta = u_v * u_theta  

Note that a simple car cannot turn in place.

Dynamics of differential drive model

dx = u_v * cos(theta)
dy = u_v * sin(theta)
dtheta = u_theta

Unlike a simple car, a robot with differential drive can turn in place.

rsim's People

Contributors

arbimo avatar emileseb avatar alexjavor avatar lancelotpoulin avatar

Watchers

James Cloos avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.