Docs

This TJBot simulator provides an emulated environment where you can control a virtual TJBot. It has been built to support basic code samples and gives just some of the freedom that programming on the real TJBot provides. However, this simulator doesn't provide all the same things the Node.js environment running on the Raspberry Pi does. The following documentation describes the methods available and how to use them. Enjoy!

Service credentials are sent over the internet to a proxy site that relays them to the respective Watson services. Code and credentials are only stored locally in the browser.

armBack()

Moves the arm backward

var tj = new TJBot(["servo"], {}, {});
tj.armBack();

analyzeTone(text).then(response => {...})

Analyzes emotions, language style and social tones

var tj = new TJBot([], {}, {
  tone_analyzer: {
    apikey: process.env.TONE_ANALYZER_API_KEY
  }
});

var text = "I like TJBot so much!";

tj.analyzeTone(text).then(response => {
  console.log(response);
});

converse(workspaceId, text, response => {...})

Process the natural language input using Watson Assistant

var tj = new TJBot([], {
  robot: {
    gender: "male"
  }
},
{
  assistant: {
    apikey: process.env.ASSISTANT_API_KEY
  }
});

tj.converse(process.env.ASSISTANT_WORKSPACE_ID, "hello", response => {
  console.log(response)
});

identifyLanguage(text).then(response => {...})

Identifies which languages the text may be

var tj = new TJBot([], {}, {
  language_translator: {
    apikey: process.env.LANGUAGE_TRANSLATOR_API_KEY
  }
});

tj.identifyLanguage("hello").then(response => {
  console.log(response);
});

isTranslatable(sourceLanguage, targetLanguage).then(result)

Returns a Promise that resolves to true if there exists a translation model between the source language and the target language.

var tj = new TJBot([], {}, {
  language_translator: {
    apikey: process.env.LANGUAGE_TRANSLATOR_API_KEY
  }
});

tj.isTranslatable("en", "es").then(result => {
  console.log(result);
});

listen(cb)

Listens to the microphone and returns the text to the callback

var tj = new TJBot(["microphone"], {}, {
  speech_to_text: {
    apikey: process.env.SPEECH_TO_TEXT_API_KEY
  }
});

tj.listen((text) => {
  console.log(text);
  tj.stopListening();
});

lowerArm()

Moves the arm down

var tj = new TJBot(["servo"], {}, {});
tj.lowerArm();

pulse(color, duration)

Pulse the LED a single time

var tj = new TJBot(["led"], {}, {});
tj.pulse("red", 2);

raiseArm()

Moves the arm up

var tj = new TJBot(["servo"], {}, {});
tj.raiseArm();

randomColor()

Get a random color

var tj = new TJBot(["led"], {}, {});
tj.shine(tj.randomColor());

see(classifier_ids = [])

Takes a photo and recognizes objects and colors

var tj = new TJBot(["camera"], {}, {
  visual_recognition: {
    apikey: process.env.VISUAL_RECOGNITION_API_KEY
  }
});

tj.see().then(objects => {
  console.log(objects);
});

shine(color)

Shines the LED a color

var tj = new TJBot(["led"], {}, {});
tj.shine("red");

shineColors()

Get the list of colors recognized by TJBot

var tj = new TJBot(["led"], {}, {});
const colors = tj.shineColors();

speak(text)

Shines the LED a color

var tj = new TJBot(["speaker"], {
    robot: {
      gender: "male"
    },
    speak: {
      language: "en-US"
    }
  },
  {
  text_to_speech: {
    apikey: process.env.TEXT_TO_SPEECH_API_KEY
  }
});

tj.speak("hello");
var tj = new TJBot(["speaker"], {
    robot: {
      gender: "female"
    },
    speak: {
      language: "fr-FR"
    }
  },
  {
  text_to_speech: {
    apikey: process.env.TEXT_TO_SPEECH_API_KEY
  }
});

tj.speak("bonjour");
var tj = new TJBot(["speaker"], {
    robot: {
      gender: "female"
    },
    speak: {
      language: "en-GB"
    }
  },
  {
  text_to_speech: {
    apikey: process.env.TEXT_TO_SPEECH_API_KEY
  }
});

tj.speak("hello. how are you today?");

translate(text, sourceLanguage, targetLanguage).then(translation => {...})

Translates content from one language into another

var tj = new TJBot([], {}, {
  language_translator: {
    apikey: process.env.LANGUAGE_TRANSLATOR_API_KEY
  }
});

tj.translate("Hello", "en", "fr")
  .then((response) => console.log(response.translations[0].translation));

wave()

Waves the arm up and down

var tj = new TJBot(["servo"], {}, {});
tj.wave();