Overview
Create an object of type miro.lib.RobotInterface
to interface with your robot without dealing with the ROS internals.
ROS, which is the underlying interface, is not a secure network protocol—unauthorized access to data published from your robot is possible. See the Information Security section of the Owner's Guide before continuing.
Before you can use this interface you must use MiRoapp to connect your robot to a network.
General information
See ROS interface for some applicable information.
For examples of how to exchange data using this interface, see the Examples at
~/mdk/bin/shared/robot
.Constructor
def __init__(self,
node_name="robot_interface",
robot_name=None,
control_period=0.02,
flags=0,
command=None,
mirocode_mode=False,
use_pose_control=False,
wait_for_ready=True
)
- node_name
- Name given to underlying ROS node.
- robot_name
- Pass a value to connect to a robot with a non-default name.
- control_period
- Controls how often the interface sends control data to the robot (values of 0.05, 0.1, 0.2 are sensible choices for most applications).
- flags
- Flags to be sent to ROS topic control/flags during initialisation.
- command
- String to be sent to ROS topic control/command during initialisation.
- MiRocode_mode
- Used internally, should always be false.
- use_pose_control
- Set to true to enable a simple velocity/position controller of type PoseController. Note that if you want to do position control, you can access the controller at
RobotInterface.pose_controller
. - wait_for_ready
- By default, if
command
is provided, the interface will wait for the cameras to restart before returning from the constructor; set this to False to skip this wait.
Methods
- get_pose()
- Return the current estimate of the robot's pose in the world frame (as an
miro.lib.Pose
which encodes anx, y, theta
tuple). This is zeroed at initialisation, and thereafter integrates the body movement based on reported wheel speeds, without any attempt at correction. - target_mdk_release()
- Return the target robot's MDK release string.
- target_supports(...)
- Test if target robot supports the specified feature (see source code for details).
- register_callback(type, callback)
- Request that callbacks of type
type
be sent to the functioncallback
.type
can be any of: 'cameras', 'camera_left', 'camera_right', 'sensors' (all 50Hz sensors), 'microphones'. - disconnect()
- Terminate internal threads and disconnect from the robot. You should call this function before discarding the interface or your program may hang at exit.
- is_active()
- Test if still connected.
- wait_for_control_boundary()
- Yield the processor until the next control boundary (the times, at intervals of
control_period
, at which control signals are sent to the physical robot). - get_*()
- Get latest periodic sensor signals from the robot (see source code for details of individual functions).
- set_*()
- Set next periodic control signals for the robot (see source code for details of individual functions).
- post_*()
- Post non-periodic control signals to the robot (flags and tones).