MBsysPy.mbsyspy.mbs_sensor module¶
Module to handle sensors on Multibody systems for any analysis.
Summary¶
Define the class MbsSensor based on the MbsSensor structure of MBsysC. This class has the functions required to compute the sensors (simple sensor, force sensors and body sensors).
-
class
MBsysPy.mbsyspy.mbs_sensor.
MbsSensor
(mbs, id_=None, sensor_ptr=None)¶ Bases:
object
Sensor are used to compute fields of a point on the multibody system.
Sensor can be computed in pure Python or computed by Python but the memory being allocated by the C-library or computed (and allocated) by the c-library.
- This class can be used for:
CompSSensor : retrieve data of a point of the system
GenSensor : retrieve data of the origin of any body of the system
CompForceSensor : retrieve data of a point of the sensor and apply a force on it
- Variables
P (ndarray) – Contains the position of the sensor expressed in the inertial frame: P[1:4]=[P_x, P_y, P_z]
V (ndarray) – Contains the velocity of the sensor expressed in the inertial frame: V[1:4]=[V_x, V_y, V_z]
A (ndarray) – Contains the velocity of the sensor expressed in the inertial frame: A[1:4]=[A_x, A_y, A_z]
R (ndarray) – Contains the rotation matrix from the inertial frame to the sensor frame: [X^s]=R.[X^0]
OM (ndarray) – Contains the angular velocity vector of the sensor expressed in the inertial frame: OM[1:4]=[omega_x, omega_y, omega_z]
OMP (ndarray) – Contains the angular acceleration vector of the sensor expressed in the inertial frame: OMP[1:4]=[domega_x, domega_y, domega_z]
J (ndarray) – Contains the jacobian matrix of the sensor: J[1:7,1:njoint]=(d velocity)/(d q)
id_ (int or None) – The ID of the sensor on the system. It is required to update the sensor values without giving the id to the method sensor or gensensor (both having an optional parameter id_).
-
comp_s_sensor
(id_=2)¶ Compute the fields of the second sensor of the multibody system.
-
comp_gen_sensor
(id_=2)¶ Compute the fields of the sensor located at the origin of the second body (including shadow bodies).
-
comp_f_sensor
(id_=2)¶ Compute the fields of the second force sensor of the multibody system.
-
reset
()¶ Set the values of all fields to 0.
Notes
In the Robotran framework the fields of the sensors that are always equal to zero are not computed. This is due to the symbolic approach. In MBsysPy implementation the computation function always reset all fields to zero prior to symbolic computation.
- Attributes
A
Access to A attribute, only value in the vector can be written.
J
Access to J attribute, only value in the matrix can be written.
OM
Access to OM attribute, only value in the vector can be written.
OMP
Access to OMP attribute, only value in the vector can be written.
P
Access to P attribute, only value in the vector can be written.
R
Access to R attribute, only value in the matrix can be written.
V
Access to V attribute, only value in the vector can be written.
Methods
assign_to_C
(self, sensor)Reassign a python sensor to an existing C MbsSensor structure.
comp_f_sensor
(self[, id_])Update the fields of the force sensor.
comp_gen_sensor
(self[, id_])Update the fields of the sensor.
comp_s_sensor
(self[, id_])Update the fields of the sensor.
reset
(self)Reset all the fields of the sensor.
-
property
A
¶ Access to A attribute, only value in the vector can be written.
-
property
J
¶ Access to J attribute, only value in the matrix can be written.
-
property
OM
¶ Access to OM attribute, only value in the vector can be written.
-
property
OMP
¶ Access to OMP attribute, only value in the vector can be written.
-
property
P
¶ Access to P attribute, only value in the vector can be written.
-
property
R
¶ Access to R attribute, only value in the matrix can be written.
-
property
V
¶ Access to V attribute, only value in the vector can be written.
-
__init__
(self, mbs, id_=None, sensor_ptr=None)¶ Create an instance of the MbsSensor class.
The sensor can be linked with C-memory (sensor_ptr) or being in pure Python.
- Parameters
mbs (MbsData) – Python MbsData instance of the MBS on which the sensor is computed.
id_ (int, optional) – ID of the sensor on the MBS.
sensor_ptr (ctypes.POINTER(MbsSensor_c), optional) – A pointer to an existing structure of MbsSensor_c. If provided the Python instance will share its memory with the C structure.
-
assign_to_C
(self, sensor)¶ Reassign a python sensor to an existing C MbsSensor structure.
If the sensor was already allocated by the C-library, it will not be binded again, but a warning will be raised.
- Parameters
sensor (ctypes.POINTER(MbsSensor_c)) – pointer to the allocated MbsSensor structure
-
comp_f_sensor
(self, id_=None)¶ Update the fields of the force sensor.
Compute all field of the specified force sensor. The sensors were specified by the user in MBsysPAD.
- Parameters
id_ (int, optional) – ID of the force sensor on the MBS. Cannot exceed the number of force sensor defined in the system (MbsData.Nxfrc).
Notes
If ‘id_’ is not set on the sensor instance, the first force sensor is considered. However a warning is generated.
See also
comp_s_sensor()
compute the user-specified sensor of the MBS.
comp_gen_sensor()
compute the sensor located at the origin of a body.
-
comp_gen_sensor
(self, id_=None)¶ Update the fields of the sensor.
Compute all field of the specified sensor. The sensors were automatically defined at the origin of each body of the MBS.
- Parameters
id_ (int, optional) – ID of the sensor on the MBS. Cannot exceed the number of bodies.
Notes
If ‘id_’ is not set on the sensor instance, the first body is considered. However a warning is generated.
See also
comp_s_sensor()
compute the user-specified sensor of the MBS.
comp_f_sensor()
compute the forces sensor.
-
comp_s_sensor
(self, id_=None)¶ Update the fields of the sensor.
Compute all field of the specified sensor. The sensors have been defined by the user on the MBS in the MBsysPAD interface.
- Parameters
id_ (int, optional) – ID of the sensor on the MBS. The maximal value is the number of sensors plus the number of forces sensor (MbsData.Nsensor + MbsData.Nxfrc).
Notes
If ‘id_’ is not set on the sensor instance the first sensor is computed. However a warning is generated.
The field of the sensors that are always equal to zero are not updated.
See also
comp_gen_sensor()
compute the sensor located at the origin of a body.
comp_f_sensor()
compute the forces sensor.
-
reset
(self)¶ Reset all the fields of the sensor.