Adapter util Package
Adapter util package is stored in /src/util
of Mech-Center’s installation directory. It contains various modules and some general functions. During programming, you can check the util package and see if there is an existing function that you can use directly. If there is such a function, directly use it. If there is no such function, but it is a commonly-used one, you can abstract the function and add it into the util package.
The introductions of each module are as follows.
database Module
The database module contains functions about the database. A mechmind.db file will be created by default when running Mech-Center, and it is used to store the running logs. The database module provides SQL statements that can be used to query one or all recorded entries.
json_keys Module
The json_keys module stores all JSON key/value strings used in Mech-Center, which can be directly imported and used in other modules.
message_box Module
The message_box module provides functions about popup boxes, which can be divided into types as information, warning, and critical.
transforms Module
The transforms module provides functions used for converting Euler angles to quaternions, converting quaternions to Euler angles, pose multiplication, converting object pose to TCP, converting TCP to object pose, and calculation of object rotation. The third-party library transforms3d also provides functions as converting Euler angles to quaternions and converting quaternions to Euler angles. However, in actual use, the conversion value output by transforms3d can be wrong in some cases. In practice, you can use the transforms3d library first. If the output result is incorrect, the custom conversion functions provided in the transforms module can be used.
util_file Module
The util_file module provides functions of file reading and writing, such as reading and writing JSON file.
timer Module
The timer module provides a convenient timer class. When a timing function is required, you can generate a Timer object, pass it into the callback function, and then call start(). There is no need to destroy the Timer object after use, as it will be destroyed automatically when the program exits.
pose Module
The pose module provides a class with the same expression as Mech-Viz, including translation (in meters) and rotation (in quaternions). It can perform inversion and multiplication operations, and provide conversion from list or to list. In addition, several small unit conversion functions about pose are also provided, including millimeters to meters, meters to millimeters, radians to degrees, degrees to radians, quaternions to Euler angles, and Euler angles to quaternions.