Skip to content
anonamause10 edited this page Jul 8, 2020 · 11 revisions

Welcome to the RoboSim wiki!

Description

This app is an interactive robotics playground with a robot that can be controlled either in the app with a keyboard or through python scripting.

Installation

Windows

Download the proper .zip file from the releases tab, extract it, and run the installer file. Then, you will have an executable RoboSim app.

MacOS

Download the proper .zip file from the releases tab, extract it, and run the app that is installed. (Note: due to me not being a registered Apple Developer, you may get a security warning. To open the app, either control-click the app in finder and hit "Open", or go to System Preferences->Security and Privacy, and click "Open Anyway").

Usage

Basic usage

When you load in, you will be looking at the back of the robot (unfortunately, the arm on top doesn't do anything quite yet). When you click anywhere, your mouse will disappear and you will be able to move around the camera(depending on your camera mode). To reveal the mouse at any time, hit the escape button. You can then use the mouse to interact with the several settings present on the screen. Check the "Toggle Telecontrol" check box to be able to control the robot with the keyboard, using WASD/Arrow keys.

Camera

There are 4 camera modes available

  1. Free to rotate - This mode lets the user rotate the camera freely, while it always looks at the robot.
  2. Lock to robot forward - This mode locks the camera to always be behind the robot, but allows for the camera to move up and down.
  3. First person - This mode puts the camera at the front of the robot, showing you a view as if you were inside the robot.
  4. Top down - This mode lifts the camera to always be looking down at the top of the robot.

Placing blocks

Clicking the "Place Obstacles" button will zoom the user out to a point where they can see the entire map. They may use arrow keys/WASD to be able to pan the camera around, and either use the Q and E buttons or use their mouses scroll wheel to zoom in or out. The slightly transparent green block is a cursor, and when the mouse is pressed, a solid block will be placed where it is. This cursor supports click+drag. Hit escape at any time to reveal the mouse, and click anywhere to control the cursor again.

Running scripts

One of the main features of this simulator is the ability to run scripts using Python. Thankfully, setup for python is very easy.

Setup

Users will have to have python installed on their machine, as well as an IDE that supports it (I recommend Visual Studio Code, which is very lightweight and easy to use. You must also install the python extension for VSCode).

  1. Once all of that is setup up, users should create a folder for their scripts, something like "Robosim scripts" which they can place on their desktop.
  2. In VSCode, go to File -> Open Folder and select the folder you just created to open it.
  3. Open a terminal in VSCode, by using the keyboard command Ctrl+` or going to View->Terminal. A terminal will open up in the bottom of the screen.
  4. In the terminal, use the command "pip install robosim3d" (Note: on MacOS, depending on if python 3 is active, users may need to use "pip3 install robosim3d" instead. To check this, VSCode will display which python version is active in the bottom left).

Running a script

  1. Users can use one copy and paste the test script into a new file, (created by clicking on the new file button, or File -> New file) naming it "test.py" or something along those lines, and pasting in the test script provided.

Here is the test script:

from robosim3d import Robot
import time
robot = Robot()
while(not robot.connected):
    robot.wait()
while(not robot.started):
    robot.wait()
print("running")
# Robot will move forwards for two seconds, turn until facing rightwards, and then move forwards until it is 5 units away from an obstacle or the wass
robot.setForwardVel(0.5)#start moving forwards
time.sleep(2)#wait two seconds
robot.setForwardVel(0)#stop
robot.setTurnVel(0.5)#start turning to the right
while(robot.getGyroAngle()<90 or robot.getGyroAngle()>180): #keep turning until facing the right
    robot.wait()
robot.setTurnVel(0)#stop turning
robot.setForwardVel(0.5)#start moving forward
while(robot.getForwardDist()>5): #keep moving forward until close enough to a wall or obstacle
    robot.wait()
robot.setForwardVel(0)#stop
robot.stop()#close connection
  1. To run the script, make sure that the RoboSim app is open and running. In the terminal, use the command "python test.py", replacing "test.py" with the name of your file if you named it something different, and then go to the RoboSim app and hit the start script button. (Note: Again, depending on the active version of python for MacOS users, they may need to replace the keyword python in the command with python3).
  2. The robot in the app should start doing whatever you tell it to in the script. If you want to stop mid-script, hit the "stop script" button in the RoboSim app. To reset the robots position, use the Reset Robot Position button.

The nature of the method used to connect the python script with the RoboSim app (sockets, for those who are interested) can lead to some issues if a script is run without the RoboSim app being ready. If for some reason you run a python script without the RoboSim app open, it may result in an infinite loop in the python script. To stop this, place your cursor in the terminal in VSCode and use the keyboard shortcut Ctrl+C to stop the script. If this for some reason does not stop the script(if the script is stopped properly, a new line such as "PS C:\Users<UserName>\Desktop\RoboSim Scripts>" will appear), you will have to hard stop the terminal by clicking the trash can icon to delete it.

Documentation

Click here for the documentation.