sas
Modularised monitoring, logging, and control of robots.
Loading...
Searching...
No Matches
sas::RobotDriverCoppeliaSim Class Reference

RobotDriver for CoppeliaSim via ZMQ. More...

#include <sas_robot_driver_coppeliasim.hpp>

Inheritance diagram for sas::RobotDriverCoppeliaSim:
sas::RobotDriver

Public Member Functions

 RobotDriverCoppeliaSim (const RobotDriverCoppeliaSim &)=delete
 RobotDriverCoppeliaSim (const RobotDriverCoppeliaSimConfiguration &configuration, std::atomic_bool *break_loops)
 Constructs the driver.
VectorXd get_joint_positions () override
 Returns current joint positions in radians.
void set_target_joint_positions (const VectorXd &desired_joint_positions_rad) override
 Sets joint positions and target joint positions.
std::tuple< VectorXd, VectorXd > get_joint_limits () override
 Returns joint position limits.
void connect () override
 Connects to the CoppeliaSim instance.
void disconnect () override
 Disconnects from the CoppeliaSim instance.
void initialize () override
 Initializes the driver state.
void deinitialize () override
 Deinitializes the driver state.
Public Member Functions inherited from sas::RobotDriver
 ~RobotDriver ()
 Virtual destructor for RobotDriver.
virtual VectorXd get_joint_velocities ()
 Get current joint velocities.
virtual void set_target_joint_velocities (const VectorXd &set_target_joint_velocities)
 Set target joint velocities.
virtual VectorXd get_joint_torques ()
 Get current joint torques.
virtual void set_target_joint_torques (const VectorXd &set_target_joint_torques)
 Set target joint torques.
virtual void set_joint_limits (const std::tuple< VectorXd, 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.
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.

Additional Inherited Members

Public Types inherited from sas::RobotDriver
enum class  Functionality {
  None =0 , PositionControl , VelocityControl , ForceControl ,
  Homing , ClearPositions , Watchdog
}
 Enumeration of optional driver functionalities.
Protected Member Functions inherited from sas::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 sas::RobotDriver
std::atomic_bool * break_loops_
std::shared_ptr< ShutdownSignalershutdown_signaler_
std::tuple< VectorXd, VectorXd > joint_limits_
VectorXd joint_velocities_
VectorXd joint_torques_
std::unique_ptr< sas::Clockclock_
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

RobotDriver for CoppeliaSim via ZMQ.

Constructor & Destructor Documentation

◆ RobotDriverCoppeliaSim()

sas::RobotDriverCoppeliaSim::RobotDriverCoppeliaSim ( const RobotDriverCoppeliaSimConfiguration & configuration,
std::atomic_bool * break_loops )

Constructs the driver.

Parameters
configurationDriver configuration parameters.
break_loopsPointer to the loop-breaking flag.

Member Function Documentation

◆ connect()

void sas::RobotDriverCoppeliaSim::connect ( )
overridevirtual

Connects to the CoppeliaSim instance.

Throws std::runtime_error if the connection attempt fails.

Implements sas::RobotDriver.

◆ deinitialize()

void sas::RobotDriverCoppeliaSim::deinitialize ( )
overridevirtual

Deinitializes the driver state.

Implements sas::RobotDriver.

◆ disconnect()

void sas::RobotDriverCoppeliaSim::disconnect ( )
overridevirtual

Disconnects from the CoppeliaSim instance.

Implements sas::RobotDriver.

◆ get_joint_limits()

std::tuple< VectorXd, VectorXd > sas::RobotDriverCoppeliaSim::get_joint_limits ( )
overridevirtual

Returns joint position limits.

Returns
Tuple of (min, max) joint position vectors.

Joint limits are queried from the simulator when available. For cyclic joints, limits are set to the representable float range.

Returns
Tuple of (min, max) joint position vectors in radians.

Reimplemented from sas::RobotDriver.

◆ get_joint_positions()

VectorXd sas::RobotDriverCoppeliaSim::get_joint_positions ( )
overridevirtual

Returns current joint positions in radians.

Returns
Joint positions as a VectorXd.

Throws if the interface is in an invalid state (e.g., not connected).

Returns
Joint positions as a VectorXd.

Implements sas::RobotDriver.

◆ initialize()

void sas::RobotDriverCoppeliaSim::initialize ( )
overridevirtual

Initializes the driver state.

Reads the initial joint positions to ensure the internal state is valid before the control loop begins.

Implements sas::RobotDriver.

◆ set_target_joint_positions()

void sas::RobotDriverCoppeliaSim::set_target_joint_positions ( const VectorXd & desired_joint_positions_rad)
overridevirtual

Sets joint positions and target joint positions.

Parameters
desired_joint_positions_radDesired joint positions in radians.

Implements sas::RobotDriver.


The documentation for this class was generated from the following files: