A DQ Robotics interface based on the ZeroMQ remote API to connect with CoppeliaSim. This API provides more functionalities than the legacy remote API (the one used by the DQ Robotics interface).
| SO | Status (C++17) | |
|---|---|---|
| macOS |
||
| Ubuntu {22.04, 24.04} LTS |
||
| Windows 11 |
cd C:/
git clone https://github.com/microsoft/vcpkg.git
cd vcpkg; .\bootstrap-vcpkg.bat
.\vcpkg.exe integrate install- Download and install CoppeliaSim ≥ v4.7.0-rev0 (Use CoppeliaSim arm64 for Apple Silicon Macs)
Install DQ Robotics for C++
Skip these steps if you already have DQ Robotics installed.
brew install eigengit clone https://github.com/dqrobotics/cpp.git
cd cpp
mkdir build && cd build
cmake ..
make -j16
sudo make installsudo add-apt-repository ppa:dqrobotics-dev/development -y
sudo apt-get update
sudo apt-get install libdqroboticsInstructions missing here!brew install pkg-config cppzmq eigen boostsudo apt install libzmq3-dev libboost-all-devRequired vcpkg packages:
.\vcpkg install cppzmq
.\vcpkg install boost-formatExample for coppeliasim-v4.8.0-rev0. Note:
git clone https://github.com/dqrobotics/cpp-interface-coppeliasim-zmq.git --recursive
cd cpp-interface-coppeliasim-zmq/submodules/zmqRemoteApi
git checkout coppeliasim-v4.8.0-rev0
cd ../..
mkdir build && cd build
cmake ..
make -j16
sudo make installAdditional step for Ubuntu users:
sudo ldconfigGo to the build folder, and run:
sudo xargs rm < install_manifest.txtRun powershell as administrator:
mkdir build
cd build
cmake -DCMAKE_TOOLCHAIN_FILE=C:/vcpkg/scripts/buildsystems/vcpkg.cmake ..
cmake --build . --config Release
cmake --install .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_CoppeliaSimInterfaceZMQExperimental.h>
using namespace DQ_robotics;
using namespace Eigen;
int main()
{
auto vi = std::make_shared<DQ_CoppeliaSimInterfaceZMQExperimental>();
vi->connect();
//To enable experimental methods
// 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");
auto jointnames = vi->get_jointnames_from_parent_object("/UR5");
vi->set_joint_modes(jointnames, DQ_CoppeliaSimInterfaceZMQExperimental::JOINT_MODE::DYNAMIC);
vi->set_joint_control_modes(jointnames, DQ_CoppeliaSimInterfaceZMQExperimental::JOINT_CONTROL_MODE::VELOCITY);
vi->enable_dynamics(true);
vi->set_engine(DQ_CoppeliaSimInterfaceZMQExperimental::ENGINE::MUJOCO);
vi->set_simulation_time_step(0.05);
vi->set_stepping_mode(true);
vi->draw_trajectory(jointnames.back(), 2, {1,0,1}, 1000);
vi->start_simulation();
auto qd = (VectorXd(6)<< 0.5, 0.5, 0.5,0.5,0.5,0.5).finished();
auto q = vi->get_joint_positions(jointnames);
VectorXd error = qd-q;
double k = 0.1;
double epsilon = 0.1;
while (error.norm() > epsilon)
{
q = vi->get_joint_positions(jointnames);
error = qd-q;
auto u = k*error;
vi->set_joint_target_velocities(jointnames, u);
vi->trigger_next_simulation_step();
std::cout<<"error: "<<error.norm()<<std::endl;
}
vi->stop_simulation();
}
add_executable(${CMAKE_PROJECT_NAME} main.cpp)
target_link_libraries(${CMAKE_PROJECT_NAME}
dqrobotics
dqrobotics-interface-coppeliasim-zmq)