uppaal2jetracer.jetracerros2.jetracerros2 package

Submodules

uppaal2jetracer.jetracerros2.jetracerros2.collision_controller module

Collision controller

This file contains classes to handle laser scan data and check for potential collisions.

This file can be imported and contains the following classes:

  • FilteredLaserScanSubscriber: Checks for the laser scans for potential collisions.

  • LaserFilterParameterSetter: Sets parameters of the laser filter.

  • CollisionController: Checks for potential collisions.

class CollisionController[source]

Bases: object

A wrapper class to check for potential collisions using the /filtered_scan topic.

This class provides asynchronous methods to set the parameters of the LaserFilter node. If you need to wait for the returned Future to complete, avoid blocking the thread where CollisionController is used. Otherwise, laser scan data will remain invalid until the thread is unblocked. Providing a synchronous alternative is not feasible because waiting for the Future would prevent access to any current data from the LaserFilter, as the execution would be stalled.

free_ahead(collision_threshold: float = None) bool[source]

Check if the path ahead is free of obstacles.

potential_collision(collision_threshold: float = None) bool[source]

Check if there is a potential collision ahead.

set_max_range_async(max_range: float) Future[source]

Set the maximum range for the values filtered by the laser filter.

This method is asynchronous. It does not wait for the future to complete!

See the class documentation for more information.

Parameters:

max_range (float) – The maximum range in meters

Returns:

The future to wait for the parameter to be set.

Return type:

rclpy.task.Future

set_min_range_async(min_range: float) Future[source]

Set the minimum range for the values filtered by the laser filter.

This method is asynchronous. It does not wait for the future to complete!

See the class documentation for more information.

Parameters:

min_range (float) – The minimum range in meters

Returns:

The future to wait for the parameter to be set.

Return type:

rclpy.task.Future

set_section_end_async(section_end: int) Future[source]

Set the end of the section to keep in the filtered scan. In degrees.

This method is asynchronous. It does not wait for the future to complete!

See the class documentation for more information.

Parameters:

section_end (int) – The end of the section in degrees

Returns:

The future to wait for the parameter to be set.

Return type:

rclpy.task.Future

set_section_start_async(section_start: int) Future[source]

Set the start of the section to keep in the filtered scan. In degrees.

This method is asynchronous. It does not wait for the future to complete!

See the class documentation for more information.

Parameters:

section_start (int) – The start of the section in degrees

Returns:

The future to wait for the parameter to be set.

Return type:

rclpy.task.Future

shutdown()[source]

Destroy the node and release the resources.

class FilteredLaserScanSubscriber[source]

Bases: Node

A class to subscribe to the filtered laser scan data and check for potential collisions.

property collision_threshold: float

Get the threshold for potential collisions.

property free_ahead: bool

Check if the path ahead is free of obstacles. It is recommended to use rclpy.spin_once() on this node before calling this method.

property potential_collision: bool

Check if there is a potential collision ahead. It is recommended to use rclpy.spin_once() on this node before calling this method.

class LaserFilterParameterSetter[source]

Bases: Node

This node is used to set the parameters of the laser filter.

set_max_range(max_range: float) Future[source]

Set the maximum range for the values filtered by the laser filter.

Parameters:

max_range (float) – The maximum range in meters

set_min_range(min_range: float)[source]

Set the minimum range for the values filtered by the laser filter.

Parameters:

min_range (float) – The minimum range in meters

set_section_end(section_end: int) Future[source]

Set the end of the section to keep in the filtered scan. In degrees.

Parameters:

section_end (int) – The end of the section in degrees

set_section_start(section_start: int) Future[source]

Set the start of the section to keep in the filtered scan. In degrees.

Parameters:

section_start (int) – The start of the section in degrees

uppaal2jetracer.jetracerros2.jetracerros2.jetracer_controller module

JetRacer controller

This file contains the control of a JetRacer and its ROS 2 Launch entrypoint.

This file can be imported and contains the following classes:

  • JetRacerController: Controls a NVIDIA JetRacer ROS AI Kit.

class JetRacerController[source]

Bases: Node

This class is the main controller for the JetRacer. It uses the /cmd_vel topic to control the servo motors using ServoMotorController.

It provides a action server turn to turn the JetRacer by a certain angle. It provides a service set_speed to set the speed of the JetRacer.

main(args=None)[source]

Entry point for ROS 2 launch script.

uppaal2jetracer.jetracerros2.jetracerros2.laser_filter module

Laser filter

This file contains the access to the Lidar and its ROS 2 Launch entrypoint.

This file can be imported and contains the following classes:

  • LaserFilter: Filters lidar scan data.

class LaserFilter[source]

Bases: Node

A class to filter the laser scan data based on the range and angle.

All values which are not in the range [min_range, max_range] will be set to 0. Only values with angles between -angle_range/2 and +angle_range/2 are kept, as they correspond to the region in front of the LiDAR. If a parameter is changed, the filter will automatically update the scan data based on the last received unfiltered scan data.

MAX_RANGE_PARAM = 'max_range'
MIN_RANGE_PARAM = 'min_range'
SECTION_END_PARAM = 'section_end'
SECTION_START_PARAM = 'section_start'
main(args=None)[source]

Entry point for ROS 2 launch script.

uppaal2jetracer.jetracerros2.jetracerros2.servo_motor_controller module

Servo motor controller

This file contains the motor control and its ROS 2 Launch entrypoint. Its main purpose is to write speed data to the JetRacer motors.

This file can be imported and contains the following classes:

  • ServoMotorController: Controls the motors of a JetRacer.

class ServoMotorController[source]

Bases: Node

This class is used to control the servo motors of the JetRacer.

Variables:
  • _linear_velocity (float) – The linear velocity of the JetRacer in m/s. Range is from -1.2 to 1.2.

  • _steering_angle (float) – The steering angle of the JetRacer in radians. Range is from -0.6 to 0.6.

property last_subscription_time: Time

Get the last time the cmd_vel topic received new data. :return: The last time the cmd_vel topic received new data. :rtype: Time

set_coefficient(a: float = -0.016073, b: float = 0.176183, c: float = -23.428084, d: float = 1500)[source]

Set the coefficients of the JetRacer.

Parameters:
  • a (float) – coefficient a, defaults to -0.016073

  • b (float) – coefficient b, defaults to 0.176183

  • c (float) – coefficient c, defaults to -23.428084

  • d (float) – coefficient d, defaults to 1500

set_params(proportional_gain: int = 350, integral_gain: int = 120, derivative_gain: int = 0, linear_correction: float = 1.0, servo_bias: int = 50) None[source]

Set the parameters of the JetRacer.

Parameters:
  • proportional_gain (int, optional) – proportional gain of the PID, defaults to 350, range is from 0 to 2000.

  • integral_gain (int, optional) – integral gain of the PID, defaults to 120, range is from 0 to 2000.

  • derivative_gain (int, optional) – derivative gain of the PID, defaults to 0, range is from 0 to 2000.

  • linear_correction (float, optional) – applied linear correction, defaults to 1.0

  • servo_bias (int, optional) – servo bias, defaults to 50, range is from -500 to 500.

set_velocity() None[source]

Set the velocity of the JetRacer.

zero_velocity() None[source]

Set the velocity of the JetRacer to zero.

main(args=None)[source]

Entry point for ROS 2 launch script.

uppaal2jetracer.jetracerros2.jetracerros2.speed_controller module

Speed controller

This file contains the speed control of a JetRacer.

This file can be imported and contains the following classes:

  • SetSpeedClientAsync: Sets the speed of a JetRacer asynchronously

  • SpeedController: Controls the speed of a JetRacer.

class SetSpeedClientAsync[source]

Bases: Node

A asynchronous client to set the speed of the JetRacer.

It is recommended to always wait for the future to complete!

Variables:

_set_speed_client (Client) – The client to set the speed of the JetRacer.

send_speed_request(speed: float) Future[source]

Send a request to set the speed of the JetRacer.

Parameters:

speed (float) – The speed to set the JetRacer to in m/s. Range is [-1.2, 1.2].

Returns:

The future to wait for the result.

Return type:

Future

class SpeedController[source]

Bases: object

A class to control the speed of the JetRacer using rclpy.

set_speed(speed: float)[source]

Set the speed of the JetRacer using SetSpeedClient. This methods waits for the future to complete.

Parameters:

speed (float) – The speed to set the JetRacer to in m/s. Range is [-1.2, 1.2].

shutdown()[source]

Shutdown the SpeedController and destroy the node.

uppaal2jetracer.jetracerros2.jetracerros2.turn_controller module

Turn controller

This file contains the turn control of a JetRacer.

This file can be imported and contains the following classes:

  • TurnActionClientAsync: Turns a JetRacer asynchronously.

  • TurnController: Controls the turning of a JetRacer.

class TurnActionClientAsync[source]

Bases: Node

A wrapper class used to asynchronously send a goal to the turn action server and wait for the result.

Variables:
  • _turn_action_client_async (TurnActionClientAsync) – The asynchronous action client for the turn action server.

  • _result (Turn.Result) – The result of the turn action.

  • _status (GoalStatus) – The status of the turn action. Used to wait for the result.

cancel_turn_goal_async()[source]

Cancel the turn goal.

cleanup()[source]

Cleanup the turn action client.

This method should only be called after the turn action has finished or is being cancelled!

is_turn_goal_active() bool[source]

Check if the turn goal is active.

Returns:

True if the turn goal is active, False otherwise.

property result: Turn_Result

Get the result of the turn action.

Returns:

The result of the turn action.

Return type:

Turn.Result

send_turn_goal_async(theta: float)[source]

Asynchronously sends a goal to the turn action server.

Parameters:

theta (float) – The angle to turn the JetRacer in radians.

Returns:

The future of the goal handle.

Return type:

rclpy.task.Future

property status: int

Get the status of the turn action.

Returns:

The status of the turn action.

Return type:

GoalStatus

class TurnController[source]

Bases: object

This class is used to send a goal to the turn action server and wait for the result.

shutdown()[source]

Shutdown the TurnController and destroy the node.

stop()[source]

Stop the JetRacer.

turn(theta: float)[source]

” Send a goal to the turn action server and wait for the result.

Parameters:

theta (float) – The angle to turn the JetRacer in radians. Positive is left, negative is right.

Module contents