Skip to content

2. Robot Interface

Manousos Linardakis edited this page Aug 16, 2023 · 1 revision

Robot Interface

2.0 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:

2.0.1 just_move(direction)

Move the fossbot forward or backwards.

  • Param:
    • direction (str): The direction to be headed. Defaults to "forward".

2.0.2 move_distance(dist, direction)

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".

2.0.3 reset_dir()

Reset all motors' directions to the default direction (forward).

2.0.4 stop()

Stop the fossbot's movement.

2.0.5 wait(time_s)

Wait (sleep) for a specified amount of time.

  • Param:
    • time_s (int): The time to sleep in seconds.

2.0.6 move_forward_distance(dist)

Move the fossbot forward by the input distance.

  • Param:
    • dist (float): The distance (cm) to be moved by the fossbot.

2.0.7 move_forward_default()

Move the fossbot forward by the default distance.

2.0.8 move_forward()

Move the fossbot forward.

2.0.9 move_reverse_distance(dist)

Move the fossbot in reverse by the input distance.

  • Param:
    • dist (float): The distance (cm) to be moved by the fossbot.

2.0.10 move_reverse_default()

Move the fossbot in reverse by the default distance.

2.0.11 move_reverse()

Move the fossbot in reverse.

2.0.12 just_rotate(dir_id)

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

2.0.13 rotate_90(dir_id)

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

2.0.14 rotate_clockwise()

Rotate the fossbot clockwise.

2.0.15 rotate_counterclockwise()

Rotate the fossbot counterclockwise.

2.0.16 rotate_clockwise_90()

Rotate the fossbot 90 degrees clockwise.

2.0.17 rotate_counterclockwise_90()

Rotate the fossbot 90 degrees counterclockwise.

2.0.18 get_distance()

Returns (float) the distance of the nearest obstacle in cm.

2.0.19 check_for_obstacle()

Returns (bool) True only if an obstacle is detected.

2.0.20 play_sound(audio_path)

Plays the MP3 file specified by the input audio_path.

  • Param:
    • audio_path (str): The path to the desired MP3 file.

2.0.21 get_floor_sensor(sensor_id)

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.

2.0.22 check_on_line(sensor_id)

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.

2.0.23 get_acceleration(axis)

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.

2.0.24 get_gyroscope(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.

2.0.25 rgb_set_color(color)

Sets the LED to the input color.

  • Param:
    • color (str): The desired color.

2.0.26 get_light_sensor()

Returns (float) the reading of the light sensor.

2.0.27 check_for_dark()

Returns (bool) True only if the light sensor detects darkness.

2.0.28 get_noise_detection()

Returns (bool) True only if noise is detected.

2.0.29 exit()

Exits the operation of the fossbot.

2.0.30 stop_timer()

Stops the timer.

2.0.31 start_timer()

Starts the timer.

2.0.32 get_elapsed()

Returns (int) the time elapsed since the start of the timer.