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
Skip these steps if you already have DQ Robotics installed.
brew install eigen
git clone https://github.com/dqrobotics/cpp.git
cd cpp
mkdir build && cd build
cmake ..
make -j16
sudo make install
sudo add-apt-repository ppa:dqrobotics-dev/development -y
sudo apt-get update
sudo apt-get install libdqrobotics
Instructions missing here!
brew install pkg-config cppzmq eigen boost
sudo apt install libzmq3-dev libboost-all-dev
Required vcpkg packages:
.\vcpkg install cppzmq
Example for coppeliasim-v4.8.0-rev0. Note: :warning: replace coppeliasim-v4.8.0-rev0 with your CoppeliaSim version (≥ v4.7.0-rev0).
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 install
Additional step for Ubuntu users:
sudo ldconfig
Go to the build folder, and run:
sudo xargs rm < install_manifest.txt
Run powershell as administrator:
mkdir build
cd build
cmake -DCMAKE_TOOLCHAIN_FILE=C:/vcpkg/scripts/buildsystems/vcpkg.cmake ..
cmake --build . --config Release
cmake --install .
1) Open CoppeliaSim. (You do not need to load a specific scene). 2) 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)