Table of Contents generated with DocToc
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
The RemoteAPIObjects.h has 3750 lines of code, so to port all the functions, I create a kind of c_transpiler.
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.
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.
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);