Interfaces¶
ActuationInterface
¶
Interface object for sending actuation commands to the SVEA car’s low-level controller.
We implement the interface for two reasons:
- Our models typically expect steering angle
[rad]
and velocity[m/s]
. - We would like to add some features on top of just sending the control inputs.
The low-level controller expects unit-less steering and velocity values between
[-127, 127]
that correspond to the minimum and maximum steering angles and
velocities.
This interface makes it easy to input steering angles in [rad]
and
velocities in [m/s]
. Assumes very simplistic models of the low-level
actuation. It assumes a linear steering model and a linear velocity model.
The control interface assumes that the ESC is in the default Sports mode.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
vehicle_name |
str
|
Name of vehicle being controlled; The name will be
effectively be added as a namespace to the topics used by the
corresponding low lever interface i.e
|
''
|
log_length |
int
|
Number of messages from control requests, control actuated
and the remote that should be stored in the internal log. Set to
|
100
|
differential_front
property
¶
Status of the front differential lock
:return: 0
if unlocked 1
if locked,
None
if no information has been received.
:rtype: int
differential_rear
property
¶
Status of the rear differential lock
:return: 0
if unlocked 1
if locked,
None
if no information has been received.
:rtype: int
emergency
property
¶
Check if the emergency flag is set. If the emergency flag can not be cleared from ROS it is also possible to clear it by not sending any control requests for at least 5 seconds, and setting the remote to override.
:return: True
if emergency flag is set, False
otherwise,
None
if no information has been received.
:rtype: bool
gear: int
property
¶
Current gear.
Returns:
Type | Description |
---|---|
int
|
|
int
|
received. |
max_speed: float
property
¶
Get the maximum speed, dependent on gear.
Returns:
Type | Description |
---|---|
float
|
The maximum speed, independent of direction |
max_speed_signal: float
property
¶
Get the maximal velocity that the controller will actually attempt to actuate for the current gear.
Returns:
Type | Description |
---|---|
float
|
The maximum actuated speed, independent of direction. |
remote_idle
property
¶
Check if the remote is considered idle by the low level interface.
:return: True
if idle, False
if active,
None
if no information has been received.
:rtype: bool
remote_override
property
¶
Check if the remote override is active. If the override is active the control requests will be ignored by the low level interface.
:return: True
if override is engaged, False
otherwise,
None
if no information has been received.
:rtype: bool
software_idle
property
¶
Check if the computer is considered idle by the low level interface.
:return: True
if idle, False
if active,
None
if no information has been received.
:rtype: bool
send_control(steering=None, velocity=None, brake_force=0, transmission=-1, differential_front=-1, differential_rear=-1, ctrl_code=0)
¶
Method for taking control inputs and implementing features over the control inputs.
This method converts steering angles and velocities from [rad]
and
[m/s]
to unit-less values that the low-level system expects,
saturates the unit-less values, implements a stopping feature for
blocking control inputs (note, this is not necessarily a braking
feature, it only blocks inputs from being published, thus it should not
be used for emergency braking), and sends/publishes inputs to the
low-level interface.
If an argument is left empty the low-level interface will be told to
use the last sent value. The same is true if the gear or differential
arguments have any other values than 0 or 1. If you do not call
send_control
then the car will not do anything.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
steering |
Optional[float]
|
Input steering angle for the car in |
None
|
velocity |
Optional[float]
|
Input velocity for the car |
None
|
brake_force |
float
|
Brake force as a percentage |
0
|
transmission |
int
|
0 means low gear, 1 means high gear, -1 means keep the currently set gear. |
-1
|
differential_front |
int
|
0 means unlocked, 1 means locked, -1 means keep the currently set lock state. |
-1
|
differential_rear |
int
|
0 means unlocked, 1 means locked, -1 means keep the currently set lock state. |
-1
|
ctrl_code |
int
|
Deprecated. |
0
|
start(wait=False)
¶
Spins up ROS background thread; must be called to start receiving and sending data.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
wait |
bool
|
True if the interface should call |
False
|
wait_until_ready(timeout=10.0)
¶
Wait until the interface is ready.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
timeout |
float
|
Number of seconds to wait for a response from the low level interface. |
10.0
|
Returns:
Type | Description |
---|---|
bool
|
False if timed out or rospy is shutdown, true otherwise. Will |
bool
|
return when the interface is ready, after |
bool
|
rospy is shutdown. |
LocalizationInterface
¶
Interface handling the reception of state information from the localization stack.
This object can take on several callback functions and execute them as soon as state information is available.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
vehicle_name |
str
|
Name of vehicle being controlled; The name will be
effectively be added as a namespace to the topics used by the
corresponding localization node i.e |
''
|
add_callback(cb)
¶
Add state callback.
Every function passed into this method will be called whenever new state information comes in from the localization stack.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
cb |
Callable[[VehicleState], None]
|
A callback function intended for responding to the reception of state info. |
required |
remove_callback(cb)
¶
Remove callback so it will no longer be called when state information is received.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
cb |
Callable[[VehicleState], None]
|
A callback function that should be no longer used in response |
required |
start()
¶
Spins up ROS background thread; must be called to start receiving data.