Skip to content

IntelligentRoboticsLab/coppelia-zmq

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

83 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Table of Contents generated with DocToc

example workflow

Unofficial Rust zmqRemoteApi

This client support the coppeliasim 4.4.0 version

A Rust ZeroMQ remote API for coppeliasim

to run tests

cargo test

to run an example: make sure to open the correct coppeliasim scene and run the cargo command:

cargo run --example=simple_test

Perhaps you want to see the zmq communication logs. There is two logs levels:

  • level 1: debug, debug level you will see the request in json format
  • level 2: trace, trace level you will see the request in json and bytes format
RUST_LOG="trace" cargo run --example=simple_test

Porting C++ client to Rust client

The RemoteAPIObjects.h has 3750 lines of code, so to port all the functions, I create a kind of c_transpiler.

diferences between C++ client and Rust client

At moment the only difference encountered is in

std::vector<uint8_t> getStringSignal(std::string signalName);

in rust the function returns a std::String. I haven't observed any examples where the function returns a block of bytes.

running the opencv example

Watch the video

Get started

create a new rust project:

cargo new new_project

add this crate at your cargo.toml :

# the branch is the coppelia version
zmq_remote_api = { git = "https://github.com/samuel-cavalcanti/rust_zmqRemoteApi", branch = "CoppeliaSim_4.4.0"}

See this simple example to understand how to use this create.

Main Branch

the main branch use the smart pointers

// main branch
let client = zmq_remote_api::RemoteApiClient::new(RemoteApiClientParams {
host: "localhost".to_string(),
..RemoteApiClientParams::default()
})?;

// Rc means Reference counter, is a smart pointer that counter the number of references
let client = Rc::new(client);
let sim = Sim::new(client.clone());

Using smart pointer is easier than dealing with borrowing and life cycle.

// CoppeliaSim_4.4.0, CoppeliaSim_4.3.0

 let client = zmq_remote_api::RemoteApiClient::new(RemoteApiClientParams {
        host: "localhost".to_string(),
        ..RemoteApiClientParams::default()
    })?;

    let sim = Sim::new(&client);

About

A Unofficial Rust ZeroMQ remote API for coppeliasim

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Rust 48.4%
  • Python 28.4%
  • C++ 23.2%