dqrobotics / python

The DQ Robotics library in Python
https://dqrobotics.github.io
GNU Lesser General Public License v3.0
26 stars 9 forks source link

[LANGUAGE INCOMPATIBILITY] The method "wait_for_simulation_step_to_end()" is missing. #50

Closed juanjqo closed 1 year ago

juanjqo commented 1 year ago

Code of Conduct

By submitting this report you automatically agree that you've read and accepted the following conditions.

@dqrobotics/developers

Hi @mmmarinho. I spot a missing method in dqrobotics/python. It looks like it is just a missing wrapper. If you agree, I could prepare a PR to fix it. :-)

The method wait_for_simulation_step_to_end() is available in the Matlab and C++ versions of the DQ Robotics but is missing in the Python implementation.

Minimal Example

#!/bin/python3
from dqrobotics.interfaces.vrep import DQ_VrepInterface
import time

vi = DQ_VrepInterface()

def main() -> None:
    try:
        vi.connect("127.0.0.1", 19997, 100, 10)
        vi.set_synchronous(True)
        vi.start_simulation()
        time.sleep(0.1)
        vi.trigger_next_simulation_step()
        vi.wait_for_simulation_step_to_end()
        vi.stop_simulation()
        vi.disconnect()

    except KeyboardInterrupt:
        pass

    except Exception as e:
        print(e)
        vi.stop_simulation()
        vi.disconnect()

if __name__ == "__main__":
    main()

PYTHON OUTPUT

'dqrobotics._dqrobotics._interfaces._vrep.DQ_VrepIn' object has no attribute 'wait_for_simulation_step_to_end'

Process finished with exit code 0

Minimal working example in C++:

#include <iostream>
#include <dqrobotics/interfaces/vrep/DQ_VrepInterface.h>
#include <thread>

int main()
{
    auto vi = DQ_VrepInterface();
    try {
        vi.connect("127.0.0.1", 19997,100,10);
        vi.set_synchronous(true);
        vi.start_simulation();
        std::this_thread::sleep_for(std::chrono::milliseconds(100));
        vi.trigger_next_simulation_step();
        vi.wait_for_simulation_step_to_end();
        vi.stop_simulation();
        vi.disconnect();
    } catch (std::exception& e) {
        std::cout<<e.what()<<std::endl;
        vi.stop_simulation();
        vi.disconnect();
    }
    return 0;
}

CMakeLists.txt

cmake_minimum_required(VERSION 3.5)

project(main LANGUAGES CXX)

set(CMAKE_CXX_STANDARD 11)
set(CMAKE_CXX_STANDARD_REQUIRED ON)

find_package(Threads REQUIRED)
add_executable(main main.cpp)
target_link_libraries(main
                      Threads::Threads
                      dqrobotics
                      dqrobotics-interface-vrep
                      )

C++ OUTPUT

/main exited with code 0

Environment:

mmmarinho commented 1 year ago

Hello @juanjqo

Thanks, I agree with the PR.