GithubHelp home page GithubHelp logo

monster-drift's Introduction

monster-drift

๐Ÿ“ป๐ŸŽ Drive a radio controlled car with Node.js and HackRF. This module should work with most radio controlled cars operating on a frequency of 27MHz.

Build status js-standard-style

180 turn

Contributions

Contributions are welcome! Add your own tricks and manoeuvres and make a Pull Request ๐Ÿค•๐Ÿ™ˆโœŒ๏ธ

Installation

Use from the command line:

npm install monster-drift --global

Use programmatically:

npm install monster-drift --save

CLI Usage

Simply run the monster-drift command to start. Use --help to get help.

Programmatic Usage

Drive forward for one seconds and stop:

var drive = require('monster-drift')()

drive.forward()

setTimeout(function () {
  drive.stop()
}, 1000)

API

Some cars might not support all commands.

var drive = new MonsterDrift([options])

This module exposes a MonsterDrift object that you can initiate to get a drive object.

Options:

  • channel - The channel to transmit on in the 27 MHz band (default: 19)
  • freq - The frequency in Hz to transmit on (overwrites channel)
  • speed - The default forward speed. Must be between 1 and 3 (default: 1). Can be overwritten with drive.forward(speed) (experimental)
  • swaplr - Boolean for inverting left and right (default: false)
  • stop - Milliseconds in which to automatically stop the card if no drive commands have been issued (default: never)
  • id - The HackRF device id to use (default: 0)
  • gain - The HackRF TX gain (0-47 dB in 1 dB steps, default: 47)
  • sampleRate - The sample rate used when transmitting (default: 8e6)

drive.forward([speed])

Drive forward.

An optional speed can be given between 1 and 3. The default speed is 1. Note that not all cars support all speeds.

drive.reverse()

Drive reverse.

drive.left()

Turn wheels left.

drive.right()

Turn wheels right.

drive.forwardRight()

Drive forward while turning right.

drive.forwardLeft()

Drive forward while turning left.

drive.reverseRight()

Drive reverse while turning right.

drive.reverseLeft()

Drive reverse while turning left.

drive.stop([callback])

Stop the car and turn off transmitter. Calls optional callback when done.

drive.close([callback])

Stop the car, turn off transmitter and close the HackRF USB connection. Calls optional callback when done.

drive.turn180([callback])

Make a 180. Calls callback when done.

drive.batch(commands[, callback])

Issue a series of driving commands to the car and call optional callback when done.

The commands argument is an array of commands. Each command is a double tuple with the following format: [function, duration]. The function part is a drive function, e.g. drive.forward, and the duration part is the number of milliseconds to perform the operation.

If the last tuple contains a duration then drive.stop will be called automatically. Leave out duratuon to continue forever.

// make a 180
drive.batch([
  [drive.forward, 1000],
  [drive.right, 125],
  [drive.reverseLeft, 100],
  [drive.reverse]
])

License

MIT

monster-drift's People

Contributors

mafintosh avatar watson avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

monster-drift's Issues

Other radio frequencies

Is there any way to use this for RC cars operating on radio frequencies apart from 27 MHz? Like 40 MHz?

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.