-
Notifications
You must be signed in to change notification settings - Fork 1
2. Robot Interface
The Robot Interface contains all the functions available for controlling the fossbot. It encompasses a class called FossBotInterface
that serves as the central interface for interacting with the fossbot. Below is a detailed list of the methods provided by this class, along with their descriptions:
Move the fossbot forward or backwards.
-
Param:
-
direction
(str): The direction to be headed. Defaults to "forward".
-
Move the fossbot to the specified direction (default is "forward") by a specified distance (in cm).
-
Param:
-
dist
(float): The distance to be moved (in cm). -
direction
(str): The direction to be moved towards. Defaults to "forward".
-
Reset all motors' directions to the default direction (forward).
Stop the fossbot's movement.
Wait (sleep) for a specified amount of time.
-
Param:
-
time_s
(int): The time to sleep in seconds.
-
Move the fossbot forward by the input distance.
-
Param:
-
dist
(float): The distance (cm) to be moved by the fossbot.
-
Move the fossbot forward by the default distance.
Move the fossbot forward.
Move the fossbot in reverse by the input distance.
-
Param:
-
dist
(float): The distance (cm) to be moved by the fossbot.
-
Move the fossbot in reverse by the default distance.
Move the fossbot in reverse.
Rotate the fossbot towards the specified direction id.
-
Param:
-
dir_id
(int): The direction id to rotate to:- counterclockwise: dir_id == 0
- clockwise: dir_id == 1
-
Rotate the fossbot 90 degrees towards the specified direction id.
-
Param:
-
dir_id
(int): The direction id to rotate 90 degrees:- counterclockwise: dir_id == 0
- clockwise: dir_id == 1
-
Rotate the fossbot clockwise.
Rotate the fossbot counterclockwise.
Rotate the fossbot 90 degrees clockwise.
Rotate the fossbot 90 degrees counterclockwise.
Returns (float) the distance of the nearest obstacle in cm.
Returns (bool) True only if an obstacle is detected.
Plays the MP3 file specified by the input audio_path
.
-
Param:
-
audio_path
(str): The path to the desired MP3 file.
-
Gets the reading of the floor-line sensor specified by the sensor_id
.
-
Param:
-
sensor_id
(int): The ID of the desired floor-line sensor.
-
- Returns (float): The reading of the specified floor-line sensor.
Checks if the line sensor (specified by the sensor_id
) is on the black line.
-
Param:
-
sensor_id
(int): The ID of the desired floor-line sensor.
-
- Returns (bool): True if the sensor is on the line, else False.
Gets the acceleration of the specified axis.
-
Param:
-
axis
(str): The axis to get the acceleration from.
-
- Returns (float): The acceleration of the specified axis.
Gets the gyroscope of the specified axis.
-
Param:
-
axis
(str): The axis to get the gyroscope from.
-
- Returns (float): The gyroscope of the specified axis.
Sets the LED to the input color.
-
Param:
-
color
(str): The desired color.
-
Returns (float) the reading of the light sensor.
Returns (bool) True only if the light sensor detects darkness.
Returns (bool) True only if noise is detected.
Exits the operation of the fossbot.
Stops the timer.
Starts the timer.
Returns (int) the time elapsed since the start of the timer.