Robot#
rb::Robot<T> is the main application-facing client in the SDK. It owns the
network session to the robot and exposes the operational flow most user code
follows: connect, power and servo devices, enable the control manager, submit
commands, and read state or logs.
Header
Header |
|
Declaration
Namespace |
|
Kind |
|
Template parameter |
|
Primary role |
Own the robot connection, state streams, command submission, time sync, parameters, and advanced real-time control entry points. |
Public Member Functions
Method |
Purpose |
Notes |
|---|---|---|
|
Construct the client and manage the robot connection lifecycle. |
|
|
Retrieve static metadata, the imported model, or a dynamics helper. |
Use before building model-based control logic. |
|
Manage device power and servo state. |
Device names accept regex-style patterns. |
|
Manage brakes on the selected devices. |
Useful in bring-up and service workflows. |
|
Control the execution subsystem and clear control-manager faults. |
Check ControlManagerState first when faults are active. |
|
Submit one-shot commands or open a command stream. |
Use Command Builder API to construct the payload. |
|
Receive or poll live state snapshots. |
See RobotState. |
|
Receive or fetch structured logs from the robot. |
See Log. |
|
Enter or leave the UDP-based real-time control path. |
|
|
Inspect, set, or reset named configuration parameters. |
Includes full reset and factory reset helpers. |
|
Cover networking, serial-device access, and mobility-adjacent utilities. |
These are secondary but still part of the public client. |
Numeric Parameters & Returns
Method or family |
Unit / encoding |
Notes |
|---|---|---|
|
Retries, |
|
|
Dimensionless |
Motion-time scaling factor. |
|
Register value |
|
|
|
Common values called out by the headers are |
|
|
Callback frequency requested from the robot. |
|
Port number, priority |
|
|
|
|
|
|
Period between time-synchronization attempts. |
|
|
|
|
|
Public headers document the battery-level range as |
|
|
Battery cutoff and full-charge thresholds. |
|
|
Timed wait before control commands are accepted. |
Detailed Reference
-
template<typename T>
class Robot : public std::enable_shared_from_this<Robot<T>># Robot control interface.
Provides high-level control interface for robot operations including connection management, power control, and command execution.
- Template Parameters:
T – Robot model type
Public Functions
-
~Robot()#
-
bool BreakEngage(const std::string &dev_name) const#
Engage the brake for a device.
- Parameters:
dev_name – Device name (joint name) to engage brake. Supports regex patterns.
- Returns:
True if successful, false otherwise.
-
bool BreakRelease(const std::string &dev_name) const#
Release the brake for a device.
- Parameters:
dev_name – Device name (joint name) to release brake. Supports regex patterns.
- Returns:
True if successful, false otherwise.
-
bool CancelControl() const#
Cancel current control operation.
- Returns:
True if successful, false otherwise.
-
bool Connect(int max_retries = 5, int timeout_ms = 1000, std::function<bool()> signal_check = nullptr)#
Attempts to establish a connection with the robot.
- Parameters:
max_retries – Maximum number of retries to connect (default: 5).
timeout_ms – Timeout in milliseconds for each connection attempt (default: 1000).
signal_check – Optional function to check for a signal (e.g., Ctrl+C). If provided, the connection will be aborted if this function returns false.
- Returns:
True if the connection was successful, false otherwise.
-
bool ConnectWifi(const std::string &ssid, const std::string &password = "", bool use_dhcp = true, const std::string &ip_address = "", const std::string &gateway = "", const std::vector<std::string> &dns = {}) const#
Connect to WiFi network.
- Parameters:
ssid – WiFi network name.
password – WiFi password (default: empty string).
use_dhcp – Use DHCP for automatic IP configuration (default: true).
ip_address – Static IP address (default: empty string).
gateway – Gateway address (default: empty string).
dns – DNS servers (default: empty vector).
- Returns:
True if successful, false otherwise.
-
bool Control(std::function<ControlInput<T>(const ControlState<T>&)> control, int port = 0, int priority = 1)#
Start a blocking real-time control loop using a custom control callback.
This function runs a UDP-based real-time loop that repeatedly calls the user-provided control callback. The loop exits when the callback returns a ControlInput with finish=true, or when an error/abort occurs.
- Parameters:
control – A callable that accepts a ControlState and returns a ControlInput.
port – UDP port to bind for the RT server. Use 0 to let the OS choose an available port (default: 0).
priority – Command priority sent with the RT control request (default: 1).
- Returns:
True if the loop terminated because the callback set finish=true in ControlInput, false if the loop ended due to an error or abort.
-
std::unique_ptr<RobotCommandStreamHandler<T>> CreateCommandStream(int priority = 1)#
Create a command stream for continuous command sending.
- Parameters:
priority – Command priority (default: 1).
- Returns:
std::unique_ptr<RobotCommandStreamHandler<T>> Command stream handler.
-
bool DisableControlManager() const#
Disable the control manager.
- Returns:
True if successful, false otherwise.
-
void Disconnect()#
Disconnect from the robot.
-
bool DisconnectWifi() const#
Disconnect from WiFi network.
- Returns:
True if successful, false otherwise.
-
bool DownloadFile(const std::string &path, std::ostream &output) const#
Download a file from the robot.
- Parameters:
path – File path on the robot.
output – Output stream to write the file content.
- Returns:
True if successful, false otherwise.
-
bool DownloadFileToCallback(const std::string &path, std::function<void(const char*, size_t)> on_chunk) const#
Download a file from the robot using a callback function.
- Parameters:
path – File path on the robot.
on_chunk – Callback function called for each chunk of data.
- Returns:
True if successful, false otherwise.
-
bool EnableControlManager(bool unlimited_mode_enabled = false) const#
Enable the control manager.
Must be called before sending commands to the robot.
- Parameters:
unlimited_mode_enabled – Whether to enable unlimited mode (default: false).
- Returns:
True if successful, false otherwise.
-
void FactoryResetAllParameters() const#
Factory reset all parameters to their default values.
-
bool FactoryResetParameter(const std::string &name) const#
Factory reset a parameter to its default value.
- Parameters:
name – Parameter name.
- Returns:
True if successful, false otherwise.
-
std::string GetAddress()#
Get the robot’s network address.
- Returns:
std::string The robot’s address.
-
ControlManagerState GetControlManagerState() const#
Get control manager state.
- Returns:
ControlManagerState Current control manager state.
-
std::shared_ptr<dyn::Robot<T::kRobotDOF>> GetDynamics(const std::string &urdf_model = "")#
Get robot dynamics model.
- Parameters:
urdf_model – URDF model path (default: empty string to use robot’s model).
- Returns:
std::shared_ptr<dyn::Robot<T::kRobotDOF>> Robot dynamics model.
-
std::vector<std::string> GetFaultLogList() const#
Get fault log list.
- Returns:
std::vector<std::string> List of fault log entries.
-
std::vector<rb::PIDGain> GetHeadPositionPIDGains() const#
Get head position PID gains.
- Returns:
std::vector<rb::PIDGain> Vector of PID gains for head joints.
-
std::vector<Log> GetLastLog(unsigned int count) const#
Get last log entries.
- Parameters:
count – Number of log entries to retrieve.
- Returns:
std::vector<Log> List of log entries.
-
std::vector<rb::PIDGain> GetLeftArmPositionPIDGains() const#
Get left arm position PID gains.
- Returns:
std::vector<rb::PIDGain> Vector of PID gains for left arm joints.
-
std::string GetParameter(const std::string &name) const#
Get a robot parameter value.
- Parameters:
name – Parameter name.
- Returns:
std::string Parameter value.
-
std::vector<std::pair<std::string, int>> GetParameterList() const#
Get list of available parameters.
- Returns:
std::vector<std::pair<std::string, int>> List of parameter names and their types.
-
rb::PIDGain GetPositionPIDGain(const std::string &dev_name) const#
Get position PID gain for a specific device.
- Parameters:
dev_name – Device name.
- Returns:
rb::PIDGain PID gain for the specified device.
-
std::vector<rb::PIDGain> GetRightArmPositionPIDGains() const#
Get right arm position PID gains.
- Returns:
std::vector<rb::PIDGain> Vector of PID gains for right arm joints.
-
RobotInfo GetRobotInfo() const#
Retrieves static information about the robot.
Gets structured metadata including joint details, device names, robot model information, SDK version, and joint configuration.
-
std::string GetRobotModel() const#
Get robot model information.
- Returns:
std::string Robot model string.
-
std::vector<SerialDevice> GetSerialDeviceList() const#
Get list of available serial devices on the robot.
- Returns:
std::vector<SerialDevice> List of available serial devices.
-
RobotState<T> GetState() const#
Get current robot state.
- Returns:
RobotState<T> Current robot state.
-
std::tuple<struct timespec, std::string, std::string> GetSystemTime() const#
Get robot system time.
- Returns:
std::tuple<struct timespec, std::string, std::string> Robot system time, timezone string, and local time string.
-
double GetTimeScale() const#
Get the current time scale factor.
- Returns:
double Current time scale factor.
-
std::vector<rb::PIDGain> GetTorsoPositionPIDGains() const#
Get torso position PID gains.
- Returns:
std::vector<rb::PIDGain> Vector of PID gains for torso joints.
-
std::optional<WifiStatus> GetWifiStatus() const#
Get WiFi connection status.
- Returns:
std::optional<WifiStatus> Current WiFi status.
-
bool HasEstablishedTimeSync()#
Check if time synchronization has been established.
- Returns:
True if time sync is established, false otherwise.
-
bool HomeOffsetReset(const std::string &dev_name) const#
Reset home offset for a device.
- Parameters:
dev_name – Device name to reset home offset. Supports regex patterns.
- Returns:
True if successful, false otherwise.
-
bool ImportRobotModel(const std::string &name, const std::string &model) const#
Import robot model.
- Parameters:
name – Model name.
model – Model data.
- Returns:
True if successful, false otherwise.
-
bool IsConnected() const#
Checks whether the robot is currently connected.
- Returns:
True if the robot is connected, false otherwise.
-
bool IsPowerOn(const std::string &dev_name) const#
Check if a device is powered on.
- Parameters:
dev_name – Device name to check. Supports regex patterns.
- Returns:
True if device is powered on, false otherwise.
-
bool IsServoOn(const std::string &dev_name) const#
Check if servo control is enabled for a device.
- Parameters:
dev_name – Device name to check. Supports regex patterns.
- Returns:
True if servo control is enabled, false otherwise.
-
std::unique_ptr<SerialStream> OpenSerialStream(const std::string &device_path, int buadrate, int bytesize, char parity, int stopbits) const#
Open a serial stream.
- Parameters:
device_path – Serial device path.
buadrate – Baud rate.
bytesize – Byte size.
parity – Parity.
stopbits – Stop bits.
- Returns:
std::unique_ptr<SerialStream> Serial stream instance.
-
bool PowerOff(const std::string &dev_name) const#
Power off a device.
- Parameters:
dev_name – Device name to power off. Supports regex patterns (e.g., “.*” for all devices).
- Returns:
True if successful, false otherwise.
-
bool PowerOn(const std::string &dev_name) const#
Power on a device.
- Parameters:
dev_name – Device name to power on. Supports regex patterns (e.g., “.*” for all devices).
- Returns:
True if successful, false otherwise.
-
void ResetAllParameters() const#
Reset all parameters to their default values.
-
void ResetAllParametersToDefault() const#
-
bool ResetBatteryConfig() const#
Reset battery configuration to default.
- Returns:
True if successful, false otherwise.
-
bool ResetFaultControlManager() const#
Reset fault in the control manager.
- Returns:
True if successful, false otherwise.
-
bool ResetNetworkSetting() const#
Reset network settings to default.
- Returns:
True if successful, false otherwise.
-
bool ResetOdometry(double angle, const Eigen::Vector<double, 2> &position)#
Reset odometry to specified values.
- Parameters:
angle – New angle [rad].
position – New position [m]. Position is [x, y] in meters.
- Returns:
True if successful, false otherwise.
-
bool ResetParameter(const std::string &name) const#
Reset a parameter to its default value.
- Parameters:
name – Parameter name.
- Returns:
True if successful, false otherwise.
-
bool ResetParameterToDefault(const std::string &name) const#
-
std::vector<WifiNetwork> ScanWifi() const#
Scan for available WiFi networks.
- Returns:
std::vector<WifiNetwork> List of available WiFi networks.
-
std::unique_ptr<RobotCommandHandler<T>> SendCommand(const RobotCommandBuilder &builder, int priority = 1)#
Send a command to the robot.
- Parameters:
builder – Command builder to send.
priority – Command priority (default: 1).
- Returns:
std::unique_ptr<RobotCommandHandler<T>> Command handler for monitoring execution.
-
bool ServoOff(const std::string &dev_name) const#
Disable servo control for a device.
- Parameters:
dev_name – Device name to disable servo control. Supports regex patterns.
- Returns:
True if successful, false otherwise.
-
bool ServoOn(const std::string &dev_name) const#
Enable servo control for a device.
- Parameters:
dev_name – Device name to enable servo control. Supports regex patterns (e.g., “.*” for all devices).
- Returns:
True if successful, false otherwise.
-
bool SetBatteryConfig(double cutoff_voltage, double fully_charged_voltage, const std::array<double, 4> &coefficients)#
Set battery configuration.
- Parameters:
cutoff_voltage – Cutoff voltage [V].
fully_charged_voltage – Fully charged voltage [V].
coefficients – Battery coefficients array.
- Returns:
True if successful, false otherwise.
-
bool SetBatteryLevel(double level) const#
Set battery level.
- Parameters:
level – Battery level percentage (0.0 to 100.0).
- Returns:
True if successful, false otherwise.
-
bool SetLEDColor(const Color &color, double duration = 1, double transition_time = 0, bool blinking = false, double blinking_freq = 1)#
Set LED color.
- Parameters:
color – LED color.
duration – Duration [s] (default: 1).
transition_time – Transition time [s] (default: 0).
blinking – Whether to blink (default: false).
blinking_freq – Blinking frequency [Hz] (default: 1).
- Returns:
True if successful, false otherwise.
-
bool SetParameter(const std::string &name, const std::string &value, bool write_db = true)#
Set a robot parameter.
- Parameters:
name – Parameter name.
value – Parameter value.
write_db – Whether to write to database (default: true).
- Returns:
True if successful, false if matching parameter not found.
-
bool SetPositionDGain(const std::string &dev_name, uint16_t d_gain) const#
Set position derivative gain for a device.
- Parameters:
dev_name – Device name. Supports regex patterns.
d_gain – Derivative gain value.
- Returns:
True if successful, false otherwise.
-
bool SetPositionIGain(const std::string &dev_name, uint16_t i_gain) const#
Set position integral gain for a device.
- Parameters:
dev_name – Device name. Supports regex patterns.
i_gain – Integral gain value.
- Returns:
True if successful, false otherwise.
-
bool SetPositionPGain(const std::string &dev_name, uint16_t p_gain) const#
Set position proportional gain for a device.
- Parameters:
dev_name – Device name. Supports regex patterns.
p_gain – Proportional gain value.
- Returns:
True if successful, false otherwise.
-
bool SetPositionPIDGain(const std::string &dev_name, const rb::PIDGain &pid_gain) const#
Set position PID gains for a device.
- Parameters:
dev_name – Device name. Supports regex patterns.
pid_gain – PID gain structure.
- Returns:
True if successful, false otherwise.
-
bool SetPositionPIDGain(const std::string &dev_name, uint16_t p_gain, uint16_t i_gain, uint16_t d_gain) const#
Set position PID gains for a device.
- Parameters:
dev_name – Device name. Supports regex patterns.
p_gain – Proportional gain value.
i_gain – Integral gain value.
d_gain – Derivative gain value.
- Returns:
True if successful, false otherwise.
-
bool SetPresetPosition(const std::string &joint_name) const#
Set preset position for a joint (only available for PVL-based motors).
- Parameters:
joint_name – Joint name to set preset position.
- Returns:
True if successful, false otherwise.
-
bool SetSystemTime(struct timespec utc_time, std::optional<std::string> time_zone = std::nullopt) const#
Set robot system time.
- Parameters:
utc_time – New system time in UTC.
time_zone – Time zone (optional).
- Returns:
True if successful, false otherwise.
-
double SetTimeScale(double time_scale) const#
Set the time scale for motion execution.
- Parameters:
time_scale – Time scale value (0.0 to 1.0). 0.0 stops motion, 1.0 is full speed.
- Returns:
double The set time scale factor.
-
bool SetToolFlangeDigitalOutput(const std::string &name, unsigned int channel, bool state) const#
Set the digital output state of a specific channel on the tool flange.
- Parameters:
name – Arm identifier (“right” or “left”).
channel – Digital output channel index.
state – Desired state of the digital output (true = ON, false = OFF).
- Returns:
True if the command was successfully sent, false otherwise.
-
bool SetToolFlangeDigitalOutputDual(const std::string &name, bool state_0, bool state_1) const#
Set the digital output states of two channels on the tool flange simultaneously.
- Parameters:
name – Arm identifier (“right” or “left”).
state_0 – Desired state for digital output channel 0 (true = ON, false = OFF).
state_1 – Desired state for digital output channel 1 (true = ON, false = OFF).
- Returns:
True if the command was successfully sent, false otherwise.
-
bool SetToolFlangeOutputVoltage(const std::string &name, int voltage) const#
Set tool flange output voltage.
- Parameters:
name – Tool flange name (“right” or “left”).
voltage – Output voltage [V]. Common voltages: 12V, 24V. Use 0V to turn off output.
- Returns:
True if successful, false otherwise.
-
void StartLogStream(const std::function<void(const std::vector<Log>&)> &cb, double rate)#
Start log stream callback.
- Parameters:
cb – Callback function for log updates.
rate – Update rate [Hz].
-
void StartStateUpdate(const std::function<void(const RobotState<T>&)> &cb, double rate)#
Start state update callback.
- Parameters:
cb – Callback function for robot state updates.
rate – Update rate [Hz].
-
void StartStateUpdate(const std::function<void(const RobotState<T>&, const ControlManagerState&)> &cb, double rate)#
Start state update callback with control manager state.
- Parameters:
cb – Callback function for robot state and control manager state updates.
rate – Update rate [Hz].
-
bool StartTimeSync(long period_sec = 10)#
Start time synchronization.
- Parameters:
period_sec – Synchronization period [s] (default: 10).
- Returns:
True if successful, false otherwise.
-
void StopLogStream()#
Stop log stream callback.
-
void StopStateUpdate()#
Stop state update callback.
-
bool StopTimeSync()#
Stop time synchronization.
- Returns:
True if successful, false otherwise.
-
bool SyncTime()#
Synchronize time with the robot.
- Returns:
True if successful, false otherwise.
-
bool WaitForControlReady(long timeout_ms) const#
Wait until the robot is ready to accept control commands.
Call after servo_on() and before sending control commands.
- Parameters:
timeout_ms – Timeout [ms].
- Returns:
True if the robot is ready to accept control, false if timeout expired.
Related Types
Examples
get_robot_state.cppfor the smallest connection and state flow.demo_motion.cppfor a full connect-power-servo-command cycle.real_time_control_command.cppfor the advancedControl()path.