|
rby1-sdk
|
Robot control interface. More...
#include <robot.h>
Public Types | |
| using | ModelType = T |
Public Member Functions | |
| bool | BrakeEngage (const std::string &dev_name) const |
| Engage the brake for a device. | |
| bool | BrakeRelease (const std::string &dev_name) const |
| Release the brake for a device. | |
| bool | CancelControl () const |
| Cancel current control operation. | |
| bool | Connect (int max_retries=5, int timeout_ms=1000, std::function< bool()> signal_check=nullptr) |
| Attempts to establish a connection with the robot. | |
| 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. | |
| 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. | |
| std::unique_ptr< RobotCommandStreamHandler< T > > | CreateCommandStream (int priority=1) |
| Create a command stream for continuous command sending. | |
| bool | DisableControlManager () const |
| Disable the control manager. | |
| void | Disconnect () |
| Disconnect from the robot. | |
| bool | DisconnectWifi () const |
| Disconnect from WiFi network. | |
| bool | DownloadFile (const std::string &path, std::ostream &output) const |
| Download a file from the robot. | |
| 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. | |
| bool | EnableControlManager (bool unlimited_mode_enabled=false) const |
| Enable the control manager. | |
| 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. | |
| std::string | GetAddress () |
| Get the robot's network address. | |
| ControlManagerState | GetControlManagerState () const |
| Get control manager state. | |
| std::shared_ptr< dyn::Robot< T::kRobotDOF > > | GetDynamics (const std::string &urdf_model="") |
| Get robot dynamics model. | |
| std::vector< std::string > | GetFaultLogList () const |
| Get fault log list. | |
| std::vector< rb::PIDGain > | GetHeadPositionPIDGains () const |
| Get head position PID gains. | |
| std::vector< Log > | GetLastLog (unsigned int count) const |
| Get last log entries. | |
| std::vector< rb::PIDGain > | GetLeftArmPositionPIDGains () const |
| Get left arm position PID gains. | |
| std::string | GetParameter (const std::string &name) const |
| Get a robot parameter value. | |
| std::vector< std::pair< std::string, int > > | GetParameterList () const |
| Get list of available parameters. | |
| rb::PIDGain | GetPositionPIDGain (const std::string &dev_name) const |
| Get position PID gain for a specific device. | |
| std::vector< rb::PIDGain > | GetRightArmPositionPIDGains () const |
| Get right arm position PID gains. | |
| RobotInfo | GetRobotInfo () const |
| Retrieves static information about the robot. | |
| std::string | GetRobotModel () const |
| Get robot model information. | |
| std::vector< SerialDevice > | GetSerialDeviceList () const |
| Get list of available serial devices on the robot. | |
| RobotState< T > | GetState () const |
| Get current robot state. | |
| std::tuple< struct timespec, std::string, std::string > | GetSystemTime () const |
| Get robot system time. | |
| double | GetTimeScale () const |
| Get the current time scale factor. | |
| std::vector< rb::PIDGain > | GetTorsoPositionPIDGains () const |
| Get torso position PID gains. | |
| std::optional< WifiStatus > | GetWifiStatus () const |
| Get WiFi connection status. | |
| bool | HasEstablishedTimeSync () |
| Check if time synchronization has been established. | |
| bool | HomeOffsetReset (const std::string &dev_name) const |
| Reset home offset for a device. | |
| bool | ImportRobotModel (const std::string &name, const std::string &model) const |
| Import robot model. | |
| bool | IsConnected () const |
| Checks whether the robot is currently connected. | |
| bool | IsPowerOn (const std::string &dev_name) const |
| Check if a device is powered on. | |
| bool | IsServoOn (const std::string &dev_name) const |
| Check if servo control is enabled for a device. | |
| std::unique_ptr< SerialStream > | OpenSerialStream (const std::string &device_path, int buadrate, int bytesize, char parity, int stopbits) const |
| Open a serial stream. | |
| bool | PowerOff (const std::string &dev_name) const |
| Power off a device. | |
| bool | PowerOn (const std::string &dev_name) const |
| Power on a device. | |
| void | ResetAllParameters () const |
| Reset all parameters to their default values. | |
| void | ResetAllParametersToDefault () const |
| bool | ResetBatteryConfig () const |
| Reset battery configuration to default. | |
| bool | ResetFaultControlManager () const |
| Reset fault in the control manager. | |
| bool | ResetNetworkSetting () const |
| Reset network settings to default. | |
| bool | ResetOdometry (double angle, const Eigen::Vector< double, 2 > &position) |
| Reset odometry to specified values. | |
| bool | ResetParameter (const std::string &name) const |
| Reset a parameter to its default value. | |
| bool | ResetParameterToDefault (const std::string &name) const |
| std::vector< WifiNetwork > | ScanWifi () const |
| Scan for available WiFi networks. | |
| std::unique_ptr< RobotCommandHandler< T > > | SendCommand (const RobotCommandBuilder &builder, int priority=1) |
| Send a command to the robot. | |
| bool | ServoOff (const std::string &dev_name) const |
| Disable servo control for a device. | |
| bool | ServoOn (const std::string &dev_name) const |
| Enable servo control for a device. | |
| bool | SetBatteryConfig (double cutoff_voltage, double fully_charged_voltage, const std::array< double, 4 > &coefficients) |
| Set battery configuration. | |
| bool | SetBatteryLevel (double level) const |
| Set battery level. | |
| bool | SetLEDColor (const Color &color, double duration=1, double transition_time=0, bool blinking=false, double blinking_freq=1) |
| Set LED color. | |
| bool | SetParameter (const std::string &name, const std::string &value, bool write_db=true) |
| Set a robot parameter. | |
| bool | SetPositionDGain (const std::string &dev_name, uint16_t d_gain) const |
| Set position derivative gain for a device. | |
| bool | SetPositionIGain (const std::string &dev_name, uint16_t i_gain) const |
| Set position integral gain for a device. | |
| bool | SetPositionPGain (const std::string &dev_name, uint16_t p_gain) const |
| Set position proportional gain for a device. | |
| bool | SetPositionPIDGain (const std::string &dev_name, const rb::PIDGain &pid_gain) const |
| Set position PID gains for a device. | |
| 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. | |
| bool | SetPresetPosition (const std::string &joint_name) const |
| Set preset position for a joint (only available for PVL-based motors). | |
| bool | SetSystemTime (struct timespec utc_time, std::optional< std::string > time_zone=std::nullopt) const |
| Set robot system time. | |
| double | SetTimeScale (double time_scale) const |
| Set the time scale for motion execution. | |
| 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. | |
| 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. | |
| bool | SetToolFlangeOutputVoltage (const std::string &name, int voltage) const |
| Set tool flange output voltage. | |
| void | StartLogStream (const std::function< void(const std::vector< Log > &)> &cb, double rate) |
| Start log stream callback. | |
| void | StartStateUpdate (const std::function< void(const RobotState< T > &)> &cb, double rate) |
| Start state update callback. | |
| void | StartStateUpdate (const std::function< void(const RobotState< T > &, const ControlManagerState &)> &cb, double rate) |
| Start state update callback with control manager state. | |
| bool | StartTimeSync (long period_sec=10) |
| Start time synchronization. | |
| void | StopLogStream () |
| Stop log stream callback. | |
| void | StopStateUpdate () |
| Stop state update callback. | |
| bool | StopTimeSync () |
| Stop time synchronization. | |
| bool | SyncTime () |
| Synchronize time with the robot. | |
| bool | WaitForControlReady (long timeout_ms) const |
| Wait until the robot is ready to accept control commands. | |
Static Public Member Functions | |
| static std::shared_ptr< Robot< T > > | Create (std::string address) |
| Create a robot instance. | |
Robot control interface.
Provides high-level control interface for robot operations including connection management, power control, and command execution.
| T | Robot model type |
| bool rb::Robot< T >::BrakeEngage | ( | const std::string & | dev_name | ) | const |
Engage the brake for a device.
| dev_name | Device name (joint name) to engage brake. Supports regex patterns. |
| bool rb::Robot< T >::BrakeRelease | ( | const std::string & | dev_name | ) | const |
Release the brake for a device.
| dev_name | Device name (joint name) to release brake. Supports regex patterns. |
| bool rb::Robot< T >::CancelControl | ( | ) | const |
Cancel current control operation.
| bool rb::Robot< T >::Connect | ( | int | max_retries = 5, |
| int | timeout_ms = 1000, | ||
| std::function< bool()> | signal_check = nullptr ) |
Attempts to establish a connection with the robot.
| 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. |
| bool rb::Robot< T >::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.
| 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). |
| bool rb::Robot< T >::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.
| 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). |
| std::unique_ptr< RobotCommandStreamHandler< T > > rb::Robot< T >::CreateCommandStream | ( | int | priority = 1 | ) |
Create a command stream for continuous command sending.
| priority | Command priority (default: 1). |
| bool rb::Robot< T >::DisableControlManager | ( | ) | const |
Disable the control manager.
| bool rb::Robot< T >::DisconnectWifi | ( | ) | const |
Disconnect from WiFi network.
| bool rb::Robot< T >::DownloadFile | ( | const std::string & | path, |
| std::ostream & | output ) const |
Download a file from the robot.
| path | File path on the robot. |
| output | Output stream to write the file content. |
| bool rb::Robot< T >::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.
| path | File path on the robot. |
| on_chunk | Callback function called for each chunk of data. |
| bool rb::Robot< T >::EnableControlManager | ( | bool | unlimited_mode_enabled = false | ) | const |
Enable the control manager.
Must be called before sending commands to the robot.
| unlimited_mode_enabled | Whether to enable unlimited mode (default: false). |
| bool rb::Robot< T >::FactoryResetParameter | ( | const std::string & | name | ) | const |
Factory reset a parameter to its default value.
| name | Parameter name. |
| std::string rb::Robot< T >::GetAddress | ( | ) |
Get the robot's network address.
| ControlManagerState rb::Robot< T >::GetControlManagerState | ( | ) | const |
Get control manager state.
| std::shared_ptr< dyn::Robot< T::kRobotDOF > > rb::Robot< T >::GetDynamics | ( | const std::string & | urdf_model = "" | ) |
Get robot dynamics model.
| urdf_model | URDF model path (default: empty string to use robot's model). |
| std::vector< std::string > rb::Robot< T >::GetFaultLogList | ( | ) | const |
Get fault log list.
| std::vector< rb::PIDGain > rb::Robot< T >::GetHeadPositionPIDGains | ( | ) | const |
Get head position PID gains.
Get last log entries.
| count | Number of log entries to retrieve. |
| std::vector< rb::PIDGain > rb::Robot< T >::GetLeftArmPositionPIDGains | ( | ) | const |
Get left arm position PID gains.
| std::string rb::Robot< T >::GetParameter | ( | const std::string & | name | ) | const |
Get a robot parameter value.
| name | Parameter name. |
| std::vector< std::pair< std::string, int > > rb::Robot< T >::GetParameterList | ( | ) | const |
Get list of available parameters.
| rb::PIDGain rb::Robot< T >::GetPositionPIDGain | ( | const std::string & | dev_name | ) | const |
Get position PID gain for a specific device.
| dev_name | Device name. |
| std::vector< rb::PIDGain > rb::Robot< T >::GetRightArmPositionPIDGains | ( | ) | const |
Get right arm position PID gains.
| std::string rb::Robot< T >::GetRobotModel | ( | ) | const |
Get robot model information.
| std::vector< SerialDevice > rb::Robot< T >::GetSerialDeviceList | ( | ) | const |
Get list of available serial devices on the robot.
| RobotState< T > rb::Robot< T >::GetState | ( | ) | const |
Get current robot state.
| std::tuple< struct timespec, std::string, std::string > rb::Robot< T >::GetSystemTime | ( | ) | const |
Get robot system time.
| double rb::Robot< T >::GetTimeScale | ( | ) | const |
Get the current time scale factor.
| std::vector< rb::PIDGain > rb::Robot< T >::GetTorsoPositionPIDGains | ( | ) | const |
Get torso position PID gains.
| std::optional< WifiStatus > rb::Robot< T >::GetWifiStatus | ( | ) | const |
Get WiFi connection status.
| bool rb::Robot< T >::HasEstablishedTimeSync | ( | ) |
Check if time synchronization has been established.
| bool rb::Robot< T >::HomeOffsetReset | ( | const std::string & | dev_name | ) | const |
Reset home offset for a device.
| dev_name | Device name to reset home offset. Supports regex patterns. |
| bool rb::Robot< T >::ImportRobotModel | ( | const std::string & | name, |
| const std::string & | model ) const |
Import robot model.
| name | Model name. |
| model | Model data. |
|
nodiscard |
Checks whether the robot is currently connected.
| bool rb::Robot< T >::IsPowerOn | ( | const std::string & | dev_name | ) | const |
Check if a device is powered on.
| dev_name | Device name to check. Supports regex patterns. |
| bool rb::Robot< T >::IsServoOn | ( | const std::string & | dev_name | ) | const |
Check if servo control is enabled for a device.
| dev_name | Device name to check. Supports regex patterns. |
| std::unique_ptr< SerialStream > rb::Robot< T >::OpenSerialStream | ( | const std::string & | device_path, |
| int | buadrate, | ||
| int | bytesize, | ||
| char | parity, | ||
| int | stopbits ) const |
Open a serial stream.
| device_path | Serial device path. |
| buadrate | Baud rate. |
| bytesize | Byte size. |
| parity | Parity. |
| stopbits | Stop bits. |
| bool rb::Robot< T >::PowerOff | ( | const std::string & | dev_name | ) | const |
Power off a device.
| dev_name | Device name to power off. Supports regex patterns (e.g., ".*" for all devices). |
| bool rb::Robot< T >::PowerOn | ( | const std::string & | dev_name | ) | const |
Power on a device.
| dev_name | Device name to power on. Supports regex patterns (e.g., ".*" for all devices). |
| bool rb::Robot< T >::ResetBatteryConfig | ( | ) | const |
Reset battery configuration to default.
| bool rb::Robot< T >::ResetFaultControlManager | ( | ) | const |
Reset fault in the control manager.
| bool rb::Robot< T >::ResetNetworkSetting | ( | ) | const |
Reset network settings to default.
| bool rb::Robot< T >::ResetOdometry | ( | double | angle, |
| const Eigen::Vector< double, 2 > & | position ) |
Reset odometry to specified values.
| angle | New angle [rad]. |
| position | New position [m]. Position is [x, y] in meters. |
| bool rb::Robot< T >::ResetParameter | ( | const std::string & | name | ) | const |
Reset a parameter to its default value.
| name | Parameter name. |
| std::vector< WifiNetwork > rb::Robot< T >::ScanWifi | ( | ) | const |
Scan for available WiFi networks.
| std::unique_ptr< RobotCommandHandler< T > > rb::Robot< T >::SendCommand | ( | const RobotCommandBuilder & | builder, |
| int | priority = 1 ) |
Send a command to the robot.
| builder | Command builder to send. |
| priority | Command priority (default: 1). |
| bool rb::Robot< T >::ServoOff | ( | const std::string & | dev_name | ) | const |
Disable servo control for a device.
| dev_name | Device name to disable servo control. Supports regex patterns. |
| bool rb::Robot< T >::ServoOn | ( | const std::string & | dev_name | ) | const |
Enable servo control for a device.
| dev_name | Device name to enable servo control. Supports regex patterns (e.g., ".*" for all devices). |
| bool rb::Robot< T >::SetBatteryConfig | ( | double | cutoff_voltage, |
| double | fully_charged_voltage, | ||
| const std::array< double, 4 > & | coefficients ) |
Set battery configuration.
| cutoff_voltage | Cutoff voltage [V]. |
| fully_charged_voltage | Fully charged voltage [V]. |
| coefficients | Battery coefficients array. |
| bool rb::Robot< T >::SetBatteryLevel | ( | double | level | ) | const |
Set battery level.
| level | Battery level percentage (0.0 to 100.0). |
| bool rb::Robot< T >::SetLEDColor | ( | const Color & | color, |
| double | duration = 1, | ||
| double | transition_time = 0, | ||
| bool | blinking = false, | ||
| double | blinking_freq = 1 ) |
Set LED color.
| 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). |
| bool rb::Robot< T >::SetParameter | ( | const std::string & | name, |
| const std::string & | value, | ||
| bool | write_db = true ) |
Set a robot parameter.
| name | Parameter name. |
| value | Parameter value. |
| write_db | Whether to write to database (default: true). |
| bool rb::Robot< T >::SetPositionDGain | ( | const std::string & | dev_name, |
| uint16_t | d_gain ) const |
Set position derivative gain for a device.
| dev_name | Device name. Supports regex patterns. |
| d_gain | Derivative gain value. |
| bool rb::Robot< T >::SetPositionIGain | ( | const std::string & | dev_name, |
| uint16_t | i_gain ) const |
Set position integral gain for a device.
| dev_name | Device name. Supports regex patterns. |
| i_gain | Integral gain value. |
| bool rb::Robot< T >::SetPositionPGain | ( | const std::string & | dev_name, |
| uint16_t | p_gain ) const |
Set position proportional gain for a device.
| dev_name | Device name. Supports regex patterns. |
| p_gain | Proportional gain value. |
| bool rb::Robot< T >::SetPositionPIDGain | ( | const std::string & | dev_name, |
| const rb::PIDGain & | pid_gain ) const |
Set position PID gains for a device.
| dev_name | Device name. Supports regex patterns. |
| pid_gain | PID gain structure. |
| bool rb::Robot< T >::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.
| dev_name | Device name. Supports regex patterns. |
| p_gain | Proportional gain value. |
| i_gain | Integral gain value. |
| d_gain | Derivative gain value. |
| bool rb::Robot< T >::SetPresetPosition | ( | const std::string & | joint_name | ) | const |
Set preset position for a joint (only available for PVL-based motors).
| joint_name | Joint name to set preset position. |
| bool rb::Robot< T >::SetSystemTime | ( | struct timespec | utc_time, |
| std::optional< std::string > | time_zone = std::nullopt ) const |
Set robot system time.
| utc_time | New system time in UTC. |
| time_zone | Time zone (optional). |
| double rb::Robot< T >::SetTimeScale | ( | double | time_scale | ) | const |
Set the time scale for motion execution.
| time_scale | Time scale value (0.0 to 1.0). 0.0 stops motion, 1.0 is full speed. |
| bool rb::Robot< T >::SetToolFlangeDigitalOutput | ( | const std::string & | name, |
| unsigned int | channel, | ||
| bool | state ) const |
Set the digital output state of a specific channel on the tool flange.
| name | Arm identifier ("right" or "left"). |
| channel | Digital output channel index. |
| state | Desired state of the digital output (true = ON, false = OFF). |
| bool rb::Robot< T >::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.
| 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). |
| bool rb::Robot< T >::SetToolFlangeOutputVoltage | ( | const std::string & | name, |
| int | voltage ) const |
Set tool flange output voltage.
| name | Tool flange name ("right" or "left"). |
| voltage | Output voltage [V]. Common voltages: 12V, 24V. Use 0V to turn off output. |
| void rb::Robot< T >::StartLogStream | ( | const std::function< void(const std::vector< Log > &)> & | cb, |
| double | rate ) |
Start log stream callback.
| cb | Callback function for log updates. |
| rate | Update rate [Hz]. |
| void rb::Robot< T >::StartStateUpdate | ( | const std::function< void(const RobotState< T > &)> & | cb, |
| double | rate ) |
Start state update callback.
| cb | Callback function for robot state updates. |
| rate | Update rate [Hz]. |
| void rb::Robot< T >::StartStateUpdate | ( | const std::function< void(const RobotState< T > &, const ControlManagerState &)> & | cb, |
| double | rate ) |
Start state update callback with control manager state.
| cb | Callback function for robot state and control manager state updates. |
| rate | Update rate [Hz]. |
| bool rb::Robot< T >::StartTimeSync | ( | long | period_sec = 10 | ) |
Start time synchronization.
| period_sec | Synchronization period [s] (default: 10). |
| bool rb::Robot< T >::StopTimeSync | ( | ) |
Stop time synchronization.
| bool rb::Robot< T >::SyncTime | ( | ) |
Synchronize time with the robot.
| bool rb::Robot< T >::WaitForControlReady | ( | long | timeout_ms | ) | const |
Wait until the robot is ready to accept control commands.
Call after servo_on() and before sending control commands.
| timeout_ms | Timeout [ms]. |