📜 ⬆️ ⬇️

Remote management of objects in Blender

Debugging different control algorithms for our robot , we felt how pleasant it would be to have a simulation environment and debug programs first in it, and then test on a real robot. Since we actively used Blender to create models for 3D printing and for the user interface, we decided to try the Blender Game Engine as a medium for modeling a robot. The first results were very good:


The video shows the control panel for the driver, which shows the view from the onboard cameras and the data from the sensors.

After that there was a question - how to integrate BGE with our communication and management system? Those. How to make the same program control the real or virtual robot in BGE without any changes? To control the robot over the network, we use the Ice library, which, among many others, supports Python. Blender is also able to execute Python scripts and provides an interface to all its objects and functions. Thus, the plan was born - to write a program on python that would implement exactly the same (remote) interfaces as the program that runs on the robot. But instead of real engines, it would change the properties of objects in BGE in accordance with the commands coming over the network.

As a first step, we decided to make the most simple example that shows:

To do this, it took two Python files. The first is with the server code that will be launched inside Blender and the second is the client program that sends requests to change the position of the server over the network. These two programs can be found on GitHub . Testblender.py is a server. It should be noted that it was necessary to start the server in a separate thread, because otherwise, waiting for messages over the network, it blocked the Blender user interface and the change in the position of the object was not visually displayed. Client.py is a simple program that sends 100 requests to change the position of the current (selected) object by moving it in a circle in the XZ plane. The following video shows how to run the server and client program and the result of the work - an object moving in a circle.

')
After we have learned how to manage objects inside Blender remotely (over the network), we plan to implement interfaces to control the robot inside BGE to control the model.

In fact, the described Blender remote object management technique can be used for completely different applications. For example, to visualize data collected on another computer. Therefore, we hope that the simple example described above and this article will be interesting and useful for readers :-).

Source: https://habr.com/ru/post/185522/


All Articles