sas
Modularised monitoring, logging, and control of robots.
Loading...
Searching...
No Matches
sas_robot_driver_gazebo.sas_robot_driver_gazebo.RobotDriverGazebo Class Reference
Inheritance diagram for sas_robot_driver_gazebo.sas_robot_driver_gazebo.RobotDriverGazebo:
marinholab::sas::core::RobotDriver

Public Member Functions

 __init__ (self, ShutdownSignaler ss, RobotDriverGazeboConfiguration configuration)
 connect (self)
 disconnect (self)
 initialize (self)
 deinitialize (self)
 get_joint_positions (self)
 get_joint_velocities (self)
 get_joint_torques (self)
 set_target_joint_positions (self, target_joint_positions_rad)
 joint_states_callback (self, msg)
Public Member Functions inherited from marinholab::sas::core::RobotDriver
virtual ~RobotDriver ()
 Virtual destructor for RobotDriver.
virtual Eigen::VectorXd get_joint_positions ()=0
 Get current joint positions.
virtual void set_target_joint_positions (const Eigen::VectorXd &set_target_joint_positions_rad)=0
 Set target joint positions.
virtual Eigen::VectorXd get_joint_velocities ()
 Get current joint velocities.
virtual void set_target_joint_velocities (const Eigen::VectorXd &set_target_joint_velocities)
 Set target joint velocities.
virtual Eigen::VectorXd get_joint_torques ()
 Get current joint torques.
virtual void set_target_joint_torques (const Eigen::VectorXd &set_target_joint_torques)
 Set target joint torques.
virtual std::tuple< Eigen::VectorXd, Eigen::VectorXd > get_joint_limits ()
 Get joint limits (min, max).
virtual void set_joint_limits (const std::tuple< Eigen::VectorXd, Eigen::VectorXd > &joint_limits)
 Set joint limits (min, max).
void watchdog_start (const std::chrono::nanoseconds &period)
 Start the watchdog thread with the given period.
void watchdog_trigger (const std::chrono::time_point< std::chrono::system_clock, std::chrono::nanoseconds > &time_point_from_the_client, const std::chrono::time_point< std::chrono::system_clock, std::chrono::nanoseconds > &time_point_from_the_server, const bool &status)
 Trigger the watchdog with timestamps from client/server and the current status.
void watchdog_set_maximum_acceptable_delay (const double &max_acceptable_delay)
 Set the maximum acceptable delay for the watchdog (seconds).
void check_for_watchdog_exceptions ()
 Check for exceptions thrown by the watchdog thread and rethrow if present.
virtual void connect ()=0
 Connect to the underlying robot/hardware.
virtual void disconnect ()=0
 Disconnect from the underlying robot/hardware.
virtual void initialize ()=0
 Initialize the driver resources.
virtual void deinitialize ()=0
 Deinitialize the driver resources.
void set_control_loop_callback (std::function< void()> callback)
 Set the control loop callback function.
void execute_control_loop_callback ()
 Execute the control loop callback if it has been set.
bool control_loop_callback_is_set ()
 Check if a control loop callback has been set.

Public Attributes

RobotDriverGazeboConfiguration configuration = configuration
int DOF = len(self.configuration.joint_names)
str joint_positions_topic_postfix = "/0/cmd_pos"
list joint_publishers = []
list joint_positions = [None] * self.DOF
list joint_velocities = [None] * self.DOF
list joint_torques = [None] * self.DOF
list limit_lower = [None] * self.DOF
list limit_upper = [None] * self.DOF
 node = None
 joint_states_callback

Additional Inherited Members

Public Types inherited from marinholab::sas::core::RobotDriver
enum class  Functionality {
  None =0 , PositionControl , VelocityControl , ForceControl ,
  Homing , ClearPositions , Watchdog
}
 Enumeration of optional driver functionalities.
Protected Member Functions inherited from marinholab::sas::core::RobotDriver
void _watchdog_thread_function ()
 RobotDriver::_watchdog_thread_function throws an exception if the elapsed time since the last trigger exceeds the specified period.
 RobotDriver (const std::shared_ptr< ShutdownSignaler > &shutdown_signaler_)
 RobotDriver (std::atomic_bool *break_loops)
 RobotDriver (const RobotDriver &)=delete
Protected Attributes inherited from marinholab::sas::core::RobotDriver
std::atomic_bool * break_loops_
std::shared_ptr< ShutdownSignaler > shutdown_signaler_
std::tuple< Eigen::VectorXd, Eigen::VectorXd > joint_limits_
Eigen::VectorXd joint_velocities_
Eigen::VectorXd joint_torques_
std::unique_ptr< marinholab::sas::core::Clock > clock_
std::unique_ptr< std::thread > watchdog_thread_
std::chrono::time_point< std::chrono::system_clock, std::chrono::nanoseconds > time_point_from_the_client_
std::chrono::time_point< std::chrono::system_clock, std::chrono::nanoseconds > time_point_from_the_server_
bool watchdog_status_
std::mutex mutex_watchdog_
double max_acceptable_delay_ = 0.1
double watchdog_period_
std::exception_ptr watchdog_exception_ {nullptr}
std::mutex watchdog_exception_mutex_
std::function< void()> control_loop_callback_

Detailed Description

@class RobotDriverGazebo
@brief Gazebo implementation of RobotDriver.

Publishes joint position commands to Gazebo and receives joint states,
velocities, torques, and limits from Gazebo model messages.

Constructor & Destructor Documentation

◆ __init__()

sas_robot_driver_gazebo.sas_robot_driver_gazebo.RobotDriverGazebo.__init__ ( self,
ShutdownSignaler ss,
RobotDriverGazeboConfiguration configuration )
@brief Construct a Gazebo robot driver.

@param ss ShutdownSignaler instance used by the base RobotDriver.
@param configuration Configuration values for Gazebo topics and joints.

Member Function Documentation

◆ connect()

sas_robot_driver_gazebo.sas_robot_driver_gazebo.RobotDriverGazebo.connect ( self)
@brief Connect to Gazebo topics.

Creates Gazebo publishers for joint commands and subscribes to the
configured joint state topic.

@return None
@exception RuntimeError Raised when the joint state subscription fails.

◆ deinitialize()

sas_robot_driver_gazebo.sas_robot_driver_gazebo.RobotDriverGazebo.deinitialize ( self)
@brief Deinitialize the driver.
@return None

◆ disconnect()

sas_robot_driver_gazebo.sas_robot_driver_gazebo.RobotDriverGazebo.disconnect ( self)
@brief Disconnect from Gazebo.
@return None

◆ get_joint_positions()

sas_robot_driver_gazebo.sas_robot_driver_gazebo.RobotDriverGazebo.get_joint_positions ( self)
@brief Return the current joint positions.

@return list Current joint positions in radians.
@exception RuntimeError Raised when joint positions are unavailable.

◆ get_joint_torques()

sas_robot_driver_gazebo.sas_robot_driver_gazebo.RobotDriverGazebo.get_joint_torques ( self)
@brief Return the current joint torques.

@return list Current joint torques.
@exception RuntimeError Raised when joint torques are unavailable.

◆ get_joint_velocities()

sas_robot_driver_gazebo.sas_robot_driver_gazebo.RobotDriverGazebo.get_joint_velocities ( self)
@brief Return the current joint velocities.

@return list Current joint velocities.
@exception RuntimeError Raised when joint velocities are unavailable.

◆ initialize()

sas_robot_driver_gazebo.sas_robot_driver_gazebo.RobotDriverGazebo.initialize ( self)
@brief Wait for joint states and limits.

Blocks until joint positions and joint limits have been received from
Gazebo, then stores the limits in the base RobotDriver.

@return None

◆ joint_states_callback()

sas_robot_driver_gazebo.sas_robot_driver_gazebo.RobotDriverGazebo.joint_states_callback ( self,
msg )
@brief Update cached joint state values.

Reads positions, velocities, torques, and limits for configured joints
from a Gazebo model message.

@param msg Gazebo model message containing joint state data.
@return None

◆ set_target_joint_positions()

sas_robot_driver_gazebo.sas_robot_driver_gazebo.RobotDriverGazebo.set_target_joint_positions ( self,
target_joint_positions_rad )
@brief Publish target joint positions.

@param target_joint_positions_rad Sequence of target joint positions in radians.
@return None

The documentation for this class was generated from the following file:
  • src/sas_robot_driver_gazebo/sas_robot_driver_gazebo/sas_robot_driver_gazebo.py