Understanding Simulators through Coppeliasim
Machines have always been intriguing to and have been an integral part of mankind for a long. They are meant to expand the abilities of humans and assist us to achieve the optimum. They help bring to practice the innovations we achieve. They aid in making what we dream and deem as ‘perfect’. Between designing a machine with required calculations and finest accuracy and manufacturing a machine, there exists an intermediate step involving simulations.
Simulations are virtually obtained working models of the machine design taking into consideration the working environment and all the other factors, enabling the Engineer to know whether the design can work post-manufacture or not, acknowledging the errors, if any. To put it in simple words, simulations are an artificial portrayal of a real system, predicting and understanding the behavior of it, once put to use.
Simulators are machines or computer based software programs that carry out simulations. Simulators present around deal with simulating a lot of different things like there are simulators to simulate the electrical behavior in a circuit, flow of air across a body, internal stress, strain, deformation by a force, temperature distribution/variation, etc. But throughout this article we will be dealing with simulators dynamic in nature which can be used to model a robot. We will be understanding simulators by taking an example of a popular simulator known as CoppeliaSim.
What is CoppeliaSim Edu?
Developed by Coppelia Robotics, it is a robot simulator with an integrated development environment. The simulator CoppeliaSim is based on a distributed control architecture: each object/model can be individually controlled via an embedded script, a plugin, a ROS or BlueZero node, a remote API client, or a custom solution. CoppeliaSim is used for fast algorithm development, factory automation simulations, fast prototyping and veriﬁcation, robotics related education, remote monitoring, safety double-checking, as digital twin, and much more.
(Launch Screen of CopeliaSim)
To smoothly work with Simulators, one should have basic knowledge about engineering design, coding languages and control systems. For CoppeliaSim, along with the knowledge of engineering design, we need to know Python and Lua Language in coding along with the knowledge of Image Processing using OpenCV, NumPy and Matplotlib. Furthermore, a deep understanding of Proportional-Intergral-Derivative (PID) Controller is required along with MATLAB and Simulink to obtain accurate results. C/C++ programming language is also in use while dealing with Plugin(s) and Remote API Client.
(A chart to help choose an api over other)
Physics behind simulators:
Simulators usually deal with rigid body dynamics, but few have the capability to model a (non rigid body) with dynamics in consideration. These become a lot compute-intensive and usually needed to compute the dynamics before playing the simulation.
For most purposes and initial prototyping considering a body rigid is a good approximation which speeds up the work to a very great extent.
Explore Arduino Collection
Role of Sensors, Joints, actuators:
Sensors gather data from the virtual environment as perceived by them which can be used to gather information and store or use it for further processing and actuation.
(A window to change properties of force sensor)
Joints are responsible for restricted movement between 2 links/components. Eg: Revolute joint, prismatic joint, universal joint, etc.
(Properties of a joint which can be edited as per requirements)
Actuators are the devices which produce physical movement on an input signal given by the controller.
Eg: Motors, hydraulic, etc
API stands for Application Standard Interface. APIs enable developers to make repetitive yet complex processes highly reusable with the least amount of coding. APIs work by sharing data and information between applications, systems, and devices—making it possible for these things to communicate with each other. Simulators have an API to send and receive data to and from the simulator application. This is to enable users to make a programme in a language which is supported which acts as the microcontroller of the robot. Api is also used to gather data which can be used for further processing. CoppeliaSim Edu uses Powerful APIs in 6 different coding languages. C++ and python are the majority used languages in simulators.
(Image showing few api commands and most popular API’s)
Making a good simulation:
Placing objects accurately using appropriate tools provided will increase the speed and accuracy of the simulation.
Using pure shapes instead of mesh wherever possible as it reduces the number of shapes hence the computation for it is decreased.
Make an object dynamic only when it needs to be, static objects take up negligible computation. Disabling and enabling properties of objects as required, disabling a property would likely decrease the accuracy of the simulation, but also decrease the computation required, hence one must select the properties wisely.
(Window showing Simulation Settings)
It is a parameter which is known while the simulation is running, indicating the ratio of computed simulation time to the time taken by the computer to do so. Having a real time factor (RF) close to unity (1) is desirable, indicating the simulation is running smoothly and things are at the same speed as it would have been with a physical model. When the RF drops by a significant amount many simulators start making more approximations and reduce the number of iterations to reduce the computation load and bring RF closer to 1. This reduces the correctness of the simulation.
Specs Required for a simulator:
Usually simulators utilise 1-4 cores of the CPU, hence higher clock speed and better IPC will increase the simulation speed. They often rely on large parallel computing where ever possible so a good graphics card according to your scene is strongly recommended.
It is difficult to list down all the products but a benchmark like geekbench enables easy comparison to choose a computer to begin with simulation.
Single core score more than: 800 Multi core score more than: 2000
Compute score more than: 10000 (OpenCL or CUDA)
Commonly used simulators:
This blog has been submitted by RnC under the Robocraze Club Outreach Program
Author:- Sairaj Jayaprakash, Nayak, Rishabh Dugar