Skip to content

paurea/PyOnBrowser

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

13 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

PyOnBrowser

Usage

python3 main.py <inputfile> --outfile=<outputfile>
js <outfile>

If <outputfile> is not mentioned, the output file name defaults to __gen__.js

Compatible versions

  • python3 : 3.6.7
  • node : 8.10.0

Example

Hello World

The simplest example is to run a hello world program. Open up a python3 file and save it as helloWorld.py. Copy the following line of code into helloWorld.py.

print ('Hello World!')

Next, run the following command to generate the javascript file.

python3 main.py helloWorld.py --outfile=out.js

This generates the file out.js which contains the generated code. out.js can be executed in the command line in the following manner

js out.js

Alternatively, it can be included in a webpage.

Interaction with WebSim

To program your bot in websim using python3, you can use this tool. The file 'modules/Hal.py' contains the API that is supported.

import HAL

HAL.setV (12)
HAL.setW (10)
print ('US = ' + str (HAL.getUS ()))
print ('IR = ' + str (HAL.getIR ()))

print (HAL.getLaser ())
print (HAL.getEncoders ())

Execute locally without websim with emulated sensors and actuators

python3 --emulate /tmp/sensors main.py helloWorld.py --outfile=out.js In the directory, there has to be a file per sensor we want to get (US, IR, etc), one number per line. After running, a file ending in .out will be appended to with the values which were set to the actuators (V.out, W.out, etc).

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • JavaScript 63.1%
  • Python 36.9%