Git Product home page Git Product logo

bots's Introduction

Bots

A simple library for controlling robots using Ruby.

What is this?

Bots is a simple library for controlling robots. You can use the library to create controller scripts that manipulate robots. The current version only controls legged robots. The example hex.rb controller script allow you to control a hexapod robot.

Bots has a built-in simulator created using the Bullet Physics Library. You can use the simulator to test run your controller scripts. You can either run it real-time or dump the output of your controller script to a sequence file to be loaded on the simulator.

Bots library simulator demo

This library uses the hexapod simulator by Bill Hsu.

Here's a hexapod controlled using Bots in action.

Bots hexapod in action

How to use

To run this in simulator mode:

  1. Clone this repository
  2. Run bundle install to install the files
  3. Create a robot controller file by requiring bots.rb
  4. Run the robot controller file in REPL using pry pry -r ./hex.rb (assuming your controller file is named hex.rb)
  5. To exit the REPL enter !!! and press enter

To run this in the sequence dump mode:

  1. Clone this repository
  2. Run bundle install to install the files
  3. Create a robot controller file by requiring bots.rb
  4. Run the robot controller file in REPL using pry pry -r ./hex.rb
  5. When have finished your activities the REPL would have dumped your activities into a .seq file
  6. Exit the REPL
  7. Run ./load.rb xxx.seq where xxx.seq is your sequence file

How to create a robot controller

Creating a robot controller is straightforward.

Subclass Bots::Controller

class Hexapod < Bots::Controller 
  ...
end

Create a constructor for your controller

You should call the constructor of your superclass with the type of engine, create legs and do whatever else you want to initialize the robot. In the example below I am creating legs for a hexapod i.e. robot with 6 legs.

def initialize(type=:sim)
  super(type)
  @legs = {}
  @legs[:front_left]   = Leg3DOF.new(:left, 1, 2, 3)
  @legs[:middle_left]  = Leg3DOF.new(:left, 4, 5, 6)
  @legs[:back_left]    = Leg3DOF.new(:left, 7, 8, 9)
    
  @legs[:front_right]  = Leg3DOF.new(:right, 32, 31, 30)
  @legs[:middle_right] = Leg3DOF.new(:right, 29, 28, 27)
  @legs[:back_right]   = Leg3DOF.new(:right, 26, 25, 24)
              
  @left_legs = [:front_left, :middle_right, :back_left]
  @right_legs = [:front_right, :middle_left, :back_right]      
end

Do stuff with the robot!

In the example below we're creating a method to simplify moving the bot.

def move(leg, c, f, t)
  execute @legs[leg].actuate(c, f, t)
end

the Leg3DOF has a method actuate that moves the 3 servos controlling the leg (coxa, femur and tibia) at the same time. In the move method we call actuate on the chosen leg, then execute the action. the execute method executes the leg actuation and creates the command that is then sent to the controller's engine.

For more information please read the source code for the sample hexapod hex.rb

bots's People

Contributors

sausheong avatar

Stargazers

 avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

Forkers

billhsu dtbinh

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.