sas
Modularised monitoring, logging, and control of robots.
Loading...
Searching...
No Matches
sas_robot_driver_coppeliasim.hpp
Go to the documentation of this file.
1#pragma once
2/*
3# Copyright (c) 2016-2025 Murilo Marques Marinho
4#
5# This file is part of sas_robot_driver_coppeliasim.
6#
7# sas_robot_driver_coppeliasim is free software: you can redistribute it and/or modify
8# it under the terms of the GNU Lesser General Public License as published by
9# the Free Software Foundation, either version 3 of the License, or
10# (at your option) any later version.
11#
12# sas_robot_driver_coppeliasim is distributed in the hope that it will be useful,
13# but WITHOUT ANY WARRANTY; without even the implied warranty of
14# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15# GNU Lesser General Public License for more details.
16#
17# You should have received a copy of the GNU Lesser General Public License
18# along with sas_robot_driver_coppeliasim. If not, see <https://www.gnu.org/licenses/>.
19#
20# ################################################################
21#
22# Author: Murilo M. Marinho, email: murilomarinho@ieee.org
23# Based on `sas` ros composer.
24#
25# ################################################################*/
26
31
32#include <atomic>
33#include <memory>
34
36
37#include <dqrobotics/interfaces/coppeliasim/DQ_CoppeliaSimInterfaceZMQ.h>
38
39using namespace Eigen;
40
41namespace sas
42{
43
48{
49 int port;
50 std::string ip;
51 int timeout = 1000;
52 std::vector<std::string> robot_joint_names;
53};
54
58class RobotDriverCoppeliaSim: public RobotDriver
59{
60private:
62 VectorXd joint_positions_;
63 std::shared_ptr<DQ_CoppeliaSimInterfaceZMQ> csi_;
64
65public:
66
67 // Prevent copies as usually drivers have threads
68 RobotDriverCoppeliaSim(const RobotDriverCoppeliaSim&)=delete;
69 RobotDriverCoppeliaSim()=delete;
70 ~RobotDriverCoppeliaSim();
71
77 RobotDriverCoppeliaSim(const RobotDriverCoppeliaSimConfiguration &configuration, std::atomic_bool* break_loops);
78
83 VectorXd get_joint_positions() override;
84
89 void set_target_joint_positions(const VectorXd& desired_joint_positions_rad) override;
90
95 std::tuple<VectorXd, VectorXd> get_joint_limits() override;
96
100 void connect() override;
101
105 void disconnect() override;
106
110 void initialize() override;
111
115 void deinitialize() override;
116
117};
118}
VectorXd get_joint_positions() override
Returns current joint positions in radians.
Definition sas_robot_driver_coppeliasim.cpp:59
void deinitialize() override
Deinitializes the driver state.
Definition sas_robot_driver_coppeliasim.cpp:103
void set_target_joint_positions(const VectorXd &desired_joint_positions_rad) override
Sets joint positions and target joint positions.
Definition sas_robot_driver_coppeliasim.cpp:68
void connect() override
Connects to the CoppeliaSim instance.
Definition sas_robot_driver_coppeliasim.cpp:79
void disconnect() override
Disconnects from the CoppeliaSim instance.
Definition sas_robot_driver_coppeliasim.cpp:111
void initialize() override
Initializes the driver state.
Definition sas_robot_driver_coppeliasim.cpp:95
std::tuple< VectorXd, VectorXd > get_joint_limits() override
Returns joint position limits.
Definition sas_robot_driver_coppeliasim.cpp:124
Abstract RobotDriver interface and watchdog support.
Configuration for RobotDriverCoppeliaSim.
Definition sas_robot_driver_coppeliasim.hpp:48
int port
ZMQ port number.
Definition sas_robot_driver_coppeliasim.hpp:49
std::string ip
CoppeliaSim IP address.
Definition sas_robot_driver_coppeliasim.hpp:50
std::vector< std::string > robot_joint_names
Names of the joints to control.
Definition sas_robot_driver_coppeliasim.hpp:52
int timeout
Connection timeout in milliseconds.
Definition sas_robot_driver_coppeliasim.hpp:51