Skip to content

ROS Bot API Documentation

Jaya Bhargav P edited this page Oct 21, 2024 · 1 revision

Functions

dump(value)

Print the value to the dashboard console, should be used in place of python default print. Can be used for debugging purposes, does not have the default attributes of the python print function

Parameters:

  • value (str): String to be printed, any other datatype must be typecasted to str. Incase of other datatypes, it will be typecasted by default, resulting in unexpected print outputs

Warning

print() tty outputs will not be visible on the dashboard console, and script will not be executed if print is used

set_speed(right_speed, left_speed)

Sets the speed of the motors.

Parameters:

  • right_speed (int): Speed of the right motor, between -100 and 100.
  • left_speed (int): Speed of the left motor, between -100 and 100.

Returns:

  • bool: True if the speed is set successfully, False otherwise.

Description

  • Negative speed for reverse motion
  • Zero for stop
  • Positive speed for forward motion

get_speed()

Gets the current speed of the motors.

Returns:

  • right_speed (int): Speed of the right motor, between -100 and 100.
  • left_speed (int): Speed of the left motor, between -100 and 100.

Description

  • Negative speed for reverse motion
  • Zero for stop
  • Positive speed for forward motion

get_distance_to_obstacle()

Gets the distance to the obstacle using the IR sensor.

Returns:

  • distance (float): Distance to the nearest obstacle in cm.

get_color_grid()

Gets the color values of the sensor array.

Returns:

  • color ([bool, bool, bool, bool, bool]): Ground color, where True represents white and False represents black.

start_encoder_pulse_counting()

Starts the encoder pulse counting.

Caution

Calling this function twice will reset the counter.

Returns:

  • bool: Success or failure of starting the encoder pulse counting.

Warning

Count reliable until $2,14,74,83,647$

stop_encoder_pulse_counting()

Stops the encoder pulse counting and resets the counter value.

Returns:

  • bool: Success or failure of stopping the encoder pulse counting.

get_encoder_pulse_count()

Gets the encoder pulse count.

Returns:

  • count (int): Encoder pulse count.

Warning

Count reliable until $2,14,74,83,647$

ping()

User code must ping the host once every 10 seconds to reset the watchdog. User program will be terminated when the watchdog resets on reaching 10 seconds.

Warning

Your program has to keep calling this function repteadly in a loop in between your code & logic to ensure it's running, once every ~8 seconds, to ensure program doesn't terminate due to minor delay in function calls.