Code Monkey home page Code Monkey logo

jyrobot's Introduction

jyrobot

PyPI version CI build status

A lightweight Python robot simulator for Jupyter Lab, Notebooks, and other environments.

Goals

  1. A lightweight mobile robotics simulator
  2. Usable in the classroom, research, or exploration
  3. Explore wheeled robots with range, cameras, and light sensors
  4. Operate quickly without a huge amount of resources
  5. Create reproducible experiments
  6. Designed for exposition, experimentation, and analysis
  7. Sensors designed for somewhat realistic problems (such as image recognition)
  8. Especially designed to work easily with Machine Learning and Artificial Intelligence systems

A duck robot

Examples

There are pre-designed simulations ready to run, like this:

import jyrobot
import random

world = jyrobot.load("two-scribblers")

for robot in world.robots:
    # Give each robot a desired speed:
    robot.forward(1)

def control(world):
    for robot in world.robots:
        if robot.stalled:
	    # If stuck, just reverse:
            robot.reverse()
	# Turn randomly:
        robot.turn(1 - random.random() * 2)

# Watch the robots move in real time, or faster:
world.watch()
world.run(control, show=True, real_time=False)
# Press Control+C or interrupt the kernel to stop

You can also easily assemble your own simulations, robots, and sensors.

import jyrobot

world = jyrobot.World(width=100, height=100)
world.watch()

robot = jyrobot.Scribbler()

world.add_robot(robot)

robot.add_device(jyrobot.RangeSensor())
robot.add_device(jyrobot.Camera())

world.save_as("world-1")

Installation

For the core operations, you will need to install just jyrobot:

pip install jyrobot

For just image processing on top of of the core, you will need:

  • Pillow - Python Image Library (PIL)

For the full set of options, you will need:

  • Pillow - Python Image Library (PIL)
  • ipywidgets
  • IPython
  • bqplot

There are three different backends:

  • "pil" - requires Pillow (Python Image Library, PIL), the default; best tested
  • "canvas" - requires ipycanvas and numpy; some issues
  • "svg" - requires svgwrite and cairosvg (for backend.take_picture()); some issues

You can install all of the above with conda or pip.

To use the Jupyter enhancements, you'll also need the browser-based extensions. You can install those with:

jupyter labextension install @jupyter-widgets/jupyterlab-manager ipycanvas bqplot

If not in a conda environment, then you will also need to:

jupyter nbextension enable --py widgetsnbextension

jyrobot's People

Watchers

 avatar  avatar  avatar  avatar

Forkers

hashb tce

jyrobot's Issues

enable look up of robot devices by user-defined names

I have a robot with 2 RangeSensors and 2 LightSensors, here's what the info() method returns:
robot.info()
device[0 or 'ir']: <RangeSensor 'left-ir' direction=0.0, range=20, width=57.3>
device[1 or 'ir']: <RangeSensor 'right=ir' direction=0.0, range=20, width=57.3>
device[2 or 'light']: <LightSensor 'left-light' position=(6, -6)>
device[3 or 'light']: <LightSensor 'right-light' position=(6, 6)>

Could we allow lookup by the user-defined name?

world.steps prints stop message after each execution

In doing nnet experiments with robots, the typical workflow will be to call world.steps repeatedly, these stop messages become unwieldy in the jupyter notebook. For example:

Simulation stopped at: 00:00:01.0; speed 18.83 x real time
Simulation stopped at: 00:00:02.0; speed 71.27 x real time
Simulation stopped at: 00:00:03.0; speed 76.6 x real time
Simulation stopped at: 00:00:04.0; speed 59.33 x real time
Simulation stopped at: 00:00:05.0; speed 76.48 x real time
Simulation stopped at: 00:00:06.0; speed 21.17 x real time
...

RangeSensor should show it's position

When you print a RangeSensor it only shows it's angle, range, and width. But the position is important to determining which of the possible multiple range sensors this represents,

Triggered error, robot not in world, is incorrect

When executing the following code I get an error message: This robot is not in the world

world = jyrobot.World(width=250, height=100)
robot = jyrobot.Scribbler()
robot.add_device(jyrobot.RangeSensor(width=0, max=100))
robot.set_pose(120, 50, 180)
world.add_robot(robot)

But the x, y, direction of the set_pose command are within the boundaries of the world

world.watch() doesn't show robot until world.reset() is done

Whenever I try to watch a world, the robot doesn't show up until I do world.resetI(). Here's an example world definition:

Create a world with one wall and a robot

world = jyrobot.World(width=200, height=200)
world.add_wall("blue", 80, 50, 100, 150)
robot = jyrobot.Scribbler(x=50, y=100, direction=0)
robot.add_device(jyrobot.RangeSensor(position=(6,-6),width=57.3,max=20,angle=90,name="left-ir"))
robot.add_device(jyrobot.RangeSensor(position=(6,6),width=57.3,max=20,angle=90,name="right=ir"))
world.add_robot(robot)
world.update()
world.save()

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.