Showing posts with label exercise 1. Show all posts
Showing posts with label exercise 1. Show all posts

Tuesday, March 22, 2011

Exercise 1, Task 15

The parking is done using the following code:

followline "bl" :($crossingblackline)
followline "bl" :($crossingblackline)
stop
wait 1
get "guidemark"
wait 1
turn 90

switch ($guidemarkok)
case 1
followline "br" :($crossingblackline)

case 2
followline "br" :($crossingblackline)
followline "br" :($crossingblackline)

case 3
followline "br" :($crossingblackline)
followline "br" :($crossingblackline)
followline "br" :($crossingblackline)

case 4
followline "br" :($crossingblackline)
followline "br" :($crossingblackline)
followline "br" :($crossingblackline)
followline "br" :($crossingblackline)

endswitch

turn -90
ignoreobstacles
fwd 0.4

stop

Monday, March 21, 2011

Exercise 1, Task 14

 The solution for the task is fulfilled by the following script:

drive @v0.3 :($irdistfrontmiddle < 0.45)
stop
wait 1
get "guidemark"
wait 1

switch ($guidemarkok)
case 1
turn 90
fwd 0.5
turn -90
ignoreobstacles
fwd 0.4

case 2
turn -90
fwd 0.5
turn 90
ignoreobstacles
fwd 0.4

endswitch
stop

Exercise 1, Task 13

Using the printed guidemark, the barcode was successfully read.

get “guidemark”
wait 3
eval $guidemarkok
stop

Exercise 1, Task 12

The barcode was printed successfully.

Tuesday, February 8, 2011

Exercise 1, Task 11

The following picture was taken with the camera mounted on the robot:


Exercise 1, Task 10




The following code was used:

fwd 0.3
followline "bl" :($irdistleft < 0.2)|($irdistright < 0.2)|($drivendist > 1)
switch($condition)
case 1
followline "bl" :($drivendist > 0.5)
case 2
followline "br" :($drivendist > 0.5)
case 3
turn 180
followline "br" :($drivendist > 1)
endswitch
stop



The robot follows a line until it sees an obstacle on the left or on the right side and then goes on the left side or the right side of the line. If it moves forward 1m and doesn't find any object it will turn 180 degrees and go back the same distance.

Exercise 1, Task 9

The robot will follow a line and stop if it encounters an object at a distance smaller than 0.3 m.
The program takes into consideration the values from all the front sensors.



fwd 0.5@v0.3
followline "bm" :($irdistfrontleft < 0.3) | ($irdistfrontmiddle < 0.3) | ($irdistfrontright < 0.3)
stop

Exercise 1, Task 8

The robot will follow a line on the floor and stop if it encounters another one crossing it.


fwd 0.3
followline "bl" :($crossingblackline)
eval $irdistfrontleft
eval $irdistfrontright
eval $irdistfrontmiddle
stop

Exercise 1, Task 7

The program is the same as the previous one, the only difference is that it follows the left branch of the fork.


fwd 0.3
followline "bl" :($drivendist > 3)
stop

Exercise 1, Task 6

This program makes the robot follow the right branch of a y-fork and stop after moving 3 meters.

fwd 0.3
followline "br" :($drivendist > 3)
stop

Tuesday, February 1, 2011

Exercise 1, Task 5

First the line sensor should be calibrated:
smrdemo –c

Make a program which makes the SMR follow a black line for 1 meter; turn and get back.
fwd 0.3
followline "br" :($drivendist > 1.0)
turn 180
followline "br" :($drivendist > 1.0)
stop

Here is the end result:





Exercise 1, Task 3

In this exercise, the robot has to move in a rectangle with the side lengths 1m and 0.3m.


The program has the following commands:


drive @v 0.3 :($drivendist > 0.5)
turnr 0.1 90 @v 0.3
drive @v 0.3 :($drivendist > 0.5)
turnr 0.1 90 @v 0.3
drive @v 0.3 :($drivendist > 0.5)
turnr 0.1 90 @v 0.3
drive @v 0.3 :($drivendist > 0.5)
turnr 0.1 90 @v 0.3
stop
The SMR will go straight, with the velocity 0.3. When the expression in the parenthesis is true, (the driven distance is greater than 0.5), the program will continue with the next line (the robot will not stop unless told so by the next command).

Exercise 1, Task 2

The following code is run:

fwd 1.5 @v0.3

turn 180
fwd 1.5 @v0.3
turn 180
stop

And here is the result:



Exercise 1, Task 4

"Make a program  that  makes   the  robot   run 0.75m  forward and  the  run  in a  square with  round
corners. The side lengths should be 0.3m and the turning radius should be 0.3 m."

 The code for task 4 is:
drive @v 0.3 :($drivendist > 0.75)
drive @v 0.3 :($drivendist > 0.3)
turnr 0.3 90 @v 0.3
drive @v 0.3 :($drivendist > 0.3)
turnr 0.3 90 @v 0.3
drive @v 0.3 :($drivendist > 0.3)
turnr 0.3 90 @v 0.3
drive @v 0.3 :($drivendist > 0.3)
turnr 0.3 90 @v 0.3
stop

And here is the movie of the robot:

Exercise 1, Task 1. Hello World!

A simple and easy task is to tell the robot to go forward, turn and get back.
The code is:

fwd 1.5 @v0.3
turn 180
fwd 1.5 @v0.3

That means: go forward 1.5m at the velocity 0.3m/s, turn around 180 degrees and the same length back.

Here is the result in the simulator.




Notice that the simulator includes movement errors; i.e. the returning position is slightly offset.