You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardexpand all lines: en/pythonClient.htm
+73-29
Original file line number
Diff line number
Diff line change
@@ -17,46 +17,69 @@
17
17
18
18
19
19
20
-
<h1>CoppeliaSim's library and Python client</h1>
20
+
<aname="lib"></a>
21
+
<h1>CoppeliaSim's library</h1>
21
22
22
23
<p>CoppeliaSim offers a wide range of functionalities via its graphical user interface. For more customized scenarios where fine-grained control of the simulation(s) loop is required (e.g. reinforcement learning), it also offers the flexibility to be used as a library within custom programs.</p>
23
24
24
-
<p>Using CoppeliaSIm as a library consists of the following steps:</p>
25
+
<p>Using CoppeliaSim as a library consists of the following steps:</p>
25
26
26
27
<ol>
27
-
<li>Loading the CoppeliaSim's library (coppeliaSim.dll / libcoppeliaSim.so / libcoppeliaSim.dylib) via the specific function (dlopen() on POSIX or LoadLibrary() on Win32).</li>
<li>Creating a secondary (SIM) thread (this step is mandatory) and in the secondary thread:
37
+
<ol>
38
+
<li>call <code>simInitialize</code> to initialize.</li>
39
+
<li>any other coppeliaSim API functions, and/or call <code>simLoop</code> until <code>simGetExitRequest</code> returns false</li>
40
+
<li>call <code>simDeinitialize</code> before termination.</li>
41
+
</ol>
42
+
</li>
43
+
44
+
<li>On the main (UI) thread: call the <code>simRunGui</code> function (this step is mandatory, also when running headless, i.e. without GUI). Argument to <code>simRunGui</code> can be used to toggle on/off individual part of the interface (use <code>sim_gui_all</code> to enable all), or to run in headless mode (<code>sim_gui_headless</code>).</li>
45
+
</ol>
28
46
29
-
<li>Creating a secondary (SIM) thread (as of current version, this step is mandatory) and in the secondary thread execute:
30
-
<ol>
31
-
<li>simInitialize</li>
32
-
<li>any other coppeliaSim API functions, or simply simLoop until simGetExitRequest returns false</li>
33
-
<li>simDeinitialize.</li>
34
-
</ol>
35
-
</li>
47
+
<aname="pythonClient"></a>
48
+
<h1>Python client</h1>
36
49
37
-
<li>On the main (UI) thread: call the simRunGui function (as of current version, this step is mandatory, also when running headless, i.e. without GUI).</li>
38
-
</ol>
50
+
<p>A complete working example of loading the CoppeliaSim library in Python is given in <ahref="https://github.com/CoppeliaRobotics/coppeliaSimClientPython">coppeliaSimClientPython</a>.</p>
39
51
40
-
<h3>Python client application</h3>
52
+
<p>In this section, relevant parts are explained.</p>
41
53
42
-
<p>A complete working example of loading the CoppeliaSim library in Python using ctypes is given in <ahref="https://github.com/CoppeliaRobotics/coppeliaSimClientPython">coppeliaSimClientPython</a>.</p>
54
+
<h2>Initialization</h2>
43
55
44
-
<p>The coppeliaSim.bridge module provides seamless access to the regular API used by scripts, e.g.:</p>
56
+
<p>Module <code>coppeliaSim.lib</code> handles the load and setup of core functions (<code>simInitialize</code>, <code>simDeinitialize</code>, etc...) via <code>ctypes</code>.</p>
<p>Another possible scenario would be to manually control the operations used to setup a simulation environment (e.g. sim.loadScene) and to execute a simulation, e.g. by manually stepping for a predetermined amount of steps:</p>
92
+
<p>Another possible scenario would be to manually control the operations used to setup a simulation environment (e.g. <code>sim.loadScene</code>) and to execute a simulation, e.g. by manually stepping for a predetermined amount of steps:</p>
<p>Please refer to <ahref="https://github.com/CoppeliaRobotics/coppeliaSimClientPython/blob/main/main_with_ui.py">coppeliaSimClientPython/main_with_ui.py</a> for the complete code.</p>
0 commit comments