Drawing world for “soar” simulator

We are currently using “soar” simulator from MIT to teach programming SOPH303 Digital World. In that simulator, we first need to load the so called world. The world is basically a python file. An example for boundaryWorld.py is shown in the figure below.

Image

The lines of code to create the world is shown here:

dimensions(4,4)
wall((0,3),(1,3))
wall((1,3),(1,4))
wall((2,0),(2,2))
wall((2,2),(3,2))
initialRobotLoc(2, 3)

The first line sets the dimension of the world in meters (x dim, ydim). The wall function set up a straight line wall from two points (x1,y1) to (x2,y2). The initialRobotLoc function places the robot at the position (x,y) in the world. The initialRobotLoc function can accept the third parameter, which is the angle in radians with respect to the horizontal x axis. So if you want the robot to point north,

initialRobotLoc(2,3,math.pi/2)

That’s it.

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: