Find file History

GoPiGo for Node.js

The GoPiGo is a delightful and complete robot for the Raspberry Pi that turns your Pi into a fully operating robot. GoPiGo is a mobile robotic platform for the Raspberry Pi developed by Dexter Industries.


Quick start

Before to start you should install Node.js on your RaspberryPi and clone the repo on your local environment. Be sure to have npm installed and then you can proceed installing the package.

Go inside your Node.js application folder and type

$ npm install node-gopigo

Now you can include the module inside your application as usual:

var Gopigo = require('node-gopigo').Gopigo

At this point you may need to include the GoPiGo base classes:

var Commands = Gopigo.commands
var Robot = Gopigo.robot

Now you can instanciate the GoPiGo, for example:

robot = new Robot({
  minVoltage: 5.5,
  criticalVoltage: 1.2,
  debug: true,
  ultrasonicSensorPin: 15

The next step is to add some listeners:

robot.on('init', function onInit(res) {
  if (res) {
    console.log('GoPiGo Ready!')
    /* Now you can do awesome stuff with your GoPiGo */
  } else {
    console.log('Something went wrong during the init.')
robot.on('error', function onError(err) {
  console.log('Something went wrong')
robot.on('free', function onFree() {
  console.log('GoPiGo is free to go')
robot.on('halt', function onHalt() {
  console.log('GoPiGo is halted')
robot.on('close', function onClose() {
  console.log('GoPiGo is going to sleep')
robot.on('reset', function onReset() {
  console.log('GoPiGo is resetting')
robot.on('normalVoltage', function onNormalVoltage(voltage) {
  console.log('Voltage is ok ['+voltage+']')
robot.on('lowVoltage', function onLowVoltage(voltage) {
  console.log('(!!) Voltage is low ['+voltage+']')
robot.on('criticalVoltage', function onCriticalVoltage(voltage) {
  console.log('(!!!) Voltage is critical ['+voltage+']')

When you are ready to go you should call the init method


You'll find a more complex example in the "basicTest.js" file under the "tests" folder of the repository.


GoPiGo for the Raspberry Pi: an open source robotics platform for the Raspberry Pi. Copyright (C) 2015 Dexter Industries

This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.

This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.

You should have received a copy of the GNU General Public License along with this program. If not, see