An unofficial DQ Robotics interface to connect with CoppeliaSim based on ZeroMQ remote API. This API provides more functionalities when compared to the legacy remote API (the one used by the DQ Robotics interface). However, unlike DQ Robotics, dqrobotics-interface-coppeliasim is experimental and lacks official support.
CoppeliaSim | SO | Status (C++20) | Status (Python) | Status (Matlab ≥ R2023b) |
---|---|---|---|---|
macOS (Apple Silicon) | ||||
Ubuntu 22.04 LTS (arm64, x64) | ||||
Windows 11 (arm64, x64) |
This project is under active development, incomplete, and experimental/unstable. Therefore, I highly recommend the official DQ Robotics interface if you want stability and outstanding technical support.
Feature | Status (C++20) | Status (Python) | Status (Matlab ≥ R2023b) |
---|---|---|---|
Implementation | 🚧 under construction 🚀 | -- | 🚧 under construction 🐢 |
Documentation | 🚧 under construction 🚀 | -- | 📌 planned |
Unit Testing | 🚧 under construction 🚀 | -- | 📌 planned |
Packages | 📌 planned | -- | 📌 planned |
The C++20 version is the baseline, and you could expect it to be the most stable, reliable, and better-supported version.
- DQ Robotics for C++
- MacOS users require Homebrew
- Windows users require vcpkg (C:\vcpkg)
brew install pkg-config cppzmq
sudo apt install libzmq3-dev
If you do not have vcpkg:
cd C:/
git clone https://github.com/microsoft/vcpkg.git
cd vcpkg; .\bootstrap-vcpkg.bat
.\vcpkg.exe integrate install
Required vcpkg packages:
.\vcpkg install cppzmq
Example for coppeliasim-v4.7.0-rev2. Note:
git clone https://github.com/juanjqo/dqrobotics-interface-coppeliasim --recursive
cd dqrobotics-interface-coppeliasim/coppeliarobotics/zmqRemoteApi
git checkout coppeliasim-v4.7.0-rev2
cd ../.. && mkdir build && cd build
cmake ..
make -j16
sudo make install
Additional step for Ubuntu users:
sudo ldconfig
Run powershell as administrator:
mkdir build
cd build
cmake -DCMAKE_TOOLCHAIN_FILE=C:/vcpkg/scripts/buildsystems/vcpkg.cmake ..
cmake --build . --config Release
cmake --install .
sudo xargs rm < install_manifest.txt
Example (Find more examples here)
- Open CoppeliaSim. (You do not need to load a specific scene).
- Run and enjoy!
#include <dqrobotics/DQ.h>
#include <dqrobotics/interfaces/coppeliasim/DQ_CoppeliaSimInterface.h>
#include <dqrobotics/interfaces/coppeliasim/robots/URXCoppeliaSimRobot.h>
using namespace DQ_robotics;
using namespace Eigen;
VectorXd compute_control_signal(const MatrixXd& J,
const VectorXd& q,
const double& damping,
const double& gain,
const VectorXd& task_error);
int main()
{
auto vi = std::make_shared<DQ_CoppeliaSimInterface>();
vi->connect();
// Load the models only if they are not already on the scene.
vi->load_from_model_browser("/robots/non-mobile/UR5.ttm", "/UR5");
vi->load_from_model_browser("/other/reference frame.ttm", "/Current_pose");
vi->load_from_model_browser("/other/reference frame.ttm", "/Desired_pose");
vi->start_simulation();
auto robot = URXCoppeliaSimRobot("/UR5", vi, URXCoppeliaSimRobot::MODEL::UR5);
auto robot_model = robot.kinematics();
robot.set_robot_as_visualization_tool();
auto q = robot.get_configuration_space_positions();
double gain = 10;
double T = 0.001;
double damping = 0.01;
auto xd = robot_model.fkm(((VectorXd(6) << 0.5, 0, 1.5, 0, 0, 0).finished()));
vi->set_object_pose("/Desired_pose", xd);
for (int i=0; i<300; i++)
{
auto x = robot_model.fkm(q);
vi->set_object_pose("/Current_pose", x);
auto J = robot_model.pose_jacobian(q);
auto Jt = robot_model.translation_jacobian(J, x);
auto task_error = (x.translation()-xd.translation()).vec4();
auto u = compute_control_signal(Jt, q, damping, gain, task_error);
q = q + T*u;
robot.set_control_inputs(q);
std::cout<<"error: "<<task_error.norm()<<std::endl;
}
vi->stop_simulation();
}
VectorXd compute_control_signal(const MatrixXd& J,
const VectorXd& q,
const double& damping,
const double& gain,
const VectorXd& task_error)
{
VectorXd u = (J.transpose()*J + damping*damping*MatrixXd::Identity(q.size(), q.size())).inverse()*
J.transpose()*(-gain*task_error);
return u;
}
add_executable(${CMAKE_PROJECT_NAME} main.cpp)
target_link_libraries(${CMAKE_PROJECT_NAME}
dqrobotics
dqrobotics-interface-coppeliasim)