Skip to content

Affonso-Gui/scratch3-ros-vm

 
 

Repository files navigation

ROS Extension for Scratch 3

animation

An extension to connect Scratch 3 to ROS enabled platforms!

Supports:

  • publishing and subscribing topics
  • calling services
  • getting and setting rosparam variables

About

This extension packs with utility blocks for creating and manipulating JSON objects, which are integrated to Scratch variables and used to represent ROS messages.

When communicating with the ROS interface, message types are mostly infered by the topic or service name, being occluded from the user. This way the user do not need to worry that much about types, allowing easier and more intuitive usage of this extension.

This also means, however, that this extension doesn't do well in advertising new topics or serving services. Maybe these will be supported in future releases, but for now Scratch interface is designed to act as a ROS client, publishing to topics and called nodes already advertised by some other node, which should be responsible to handle the message from Scratch and do all of the robotics stuff.

Quick Start

  1. Install ROS and the following dependencies. Ths project was tested on ROS1 (kinetic, melodic, noetic).
# Install main dependencies
sudo apt install ros-kinetic-rosbridge-server
# Install examples dependencies
sudo apt install ros-kinetic-turtlesim ros-kinetic-actionlib-tutorials 
  1. Access http://www.scratch3ros.com . The extension currently doesn't support https access!

  2. Open a terminal and fire up the following command

roslaunch rosbridge_server rosbridge_websocket.launch
  1. Add the ROS Extension from the bottom left button and input localhost as the master URI

Examples

Examples can be found at the examples directory. To run the examples:

  1. On a terminal, launch roslaunch rosbridge_server rosbridge_websocket.launch
  2. Access http://www.scratch3ros.com/ and load the example file
  3. Use localhost as the master URI. If a warning sign appears near the ROS blocks, click it to reconnect. warning
  4. Check comments for other required nodes
  5. Click the green flag to start!

Simple chatter: scratch3ros_rosext_chatter Simple actionlib client: scratch3ros_rosext_fibonacci Turtlesim: scratch3ros_rosext_turtlesim

Blocks API

Details of provided blocks can be found at BLOCKS.md.

Run from Source

Git clone the repositories below and follow instructions at https://github.com/LLK/scratch-gui/wiki/Getting-Started

For a quick overview:

git clone https://github.com/Affonso-Gui/scratch3-ros-gui
git clone https://github.com/Affonso-Gui/scratch3-ros-vm
git clone https://github.com/Affonso-Gui/scratch3-ros-parser
cd scratch3-ros-parser && npm install && npm link
cd ../scratch3-ros-vm && npm install && npm link
cd ../scratch3-ros-gui && npm install && npm link scratch-parser scratch-vm
npm start

The current version have been tested with npm 9.8.1 and node 18.18.0.

Develop a library for your own robot

You can include Scratch3-ROS on your Scratch project and create custom block libraries for your own robot. Multiple examples are given in the jsk_robot branch:

About

Virtual Machine used to represent, run, and maintain the state of programs for Scratch 3.0

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • JavaScript 99.6%
  • Other 0.4%