|
7 | 7 |
|
8 | 8 | import genesis as gs |
9 | 9 | import genesis.utils.array_class as array_class |
10 | | -import genesis.utils.geom as gu |
11 | 10 | from genesis.engine.entities import DroneEntity, RigidEntity |
12 | 11 | from genesis.engine.entities.base_entity import Entity |
13 | 12 | from genesis.engine.states import QueriedStates, RigidSolverState |
|
27 | 26 | from .collider import Collider |
28 | 27 | from .constraint import ConstraintSolver, ConstraintSolverIsland |
29 | 28 | from .abd.misc import ( |
| 29 | + func_add_safe_backward, |
| 30 | + func_apply_coupling_force, |
| 31 | + func_apply_link_external_force, |
| 32 | + func_apply_external_torque, |
| 33 | + func_apply_link_external_torque, |
| 34 | + func_atomic_add_if, |
| 35 | + func_check_index_range, |
| 36 | + func_clear_external_force, |
| 37 | + func_read_field_if, |
30 | 38 | func_wakeup_entity_and_its_temp_island, |
| 39 | + func_write_field_if, |
| 40 | + func_write_and_read_field_if, |
31 | 41 | kernel_init_invweight, |
32 | 42 | kernel_init_meaninertia, |
33 | 43 | kernel_init_dof_fields, |
|
43 | 53 | kernel_init_equality_fields, |
44 | 54 | kernel_apply_links_external_force, |
45 | 55 | kernel_apply_links_external_torque, |
46 | | - func_apply_coupling_force, |
47 | | - func_apply_link_external_force, |
48 | | - func_apply_external_torque, |
49 | | - func_apply_link_external_torque, |
50 | | - func_clear_external_force, |
51 | 56 | kernel_update_geoms_render_T, |
52 | 57 | kernel_update_vgeoms_render_T, |
53 | 58 | kernel_bit_reduction, |
54 | 59 | kernel_set_zero, |
55 | | - func_atomic_add_if, |
56 | | - func_add_safe_backward, |
57 | | - func_read_field_if, |
58 | | - func_write_field_if, |
59 | | - func_write_and_read_field_if, |
60 | | - func_check_index_range, |
61 | 60 | kernel_clear_external_force, |
62 | 61 | ) |
63 | 62 | from .abd.forward_kinematics import ( |
64 | | - kernel_forward_kinematics_links_geoms, |
65 | | - kernel_masked_forward_kinematics_links_geoms, |
66 | | - kernel_forward_velocity, |
67 | | - kernel_masked_forward_velocity, |
| 63 | + func_aggregate_awake_entities, |
68 | 64 | func_COM_links, |
69 | 65 | func_COM_links_entity, |
70 | 66 | func_forward_kinematics_entity, |
71 | 67 | func_forward_kinematics_batch, |
72 | | - kernel_forward_kinematics_entity, |
| 68 | + func_forward_velocity_entity, |
| 69 | + func_forward_velocity_batch, |
| 70 | + func_forward_velocity, |
| 71 | + func_hibernate_entity_and_zero_dof_velocities, |
| 72 | + func_hibernate__for_all_awake_islands_either_hiberanate_or_update_aabb_sort_buffer, |
73 | 73 | func_update_geoms_entity, |
74 | 74 | func_update_geoms_batch, |
| 75 | + func_update_all_verts, |
| 76 | + func_update_cartesian_space, |
| 77 | + func_update_cartesian_space_entity, |
| 78 | + func_update_cartesian_space_batch, |
75 | 79 | func_update_geoms, |
| 80 | + func_update_verts_for_geom, |
| 81 | + kernel_forward_kinematics_links_geoms, |
| 82 | + kernel_masked_forward_kinematics_links_geoms, |
| 83 | + kernel_forward_velocity, |
| 84 | + kernel_masked_forward_velocity, |
| 85 | + kernel_forward_kinematics_entity, |
76 | 86 | kernel_update_geoms, |
77 | | - func_forward_velocity_entity, |
78 | | - func_forward_velocity_batch, |
79 | | - func_forward_velocity, |
80 | 87 | kernel_update_verts_for_geoms, |
81 | | - func_update_verts_for_geom, |
82 | | - func_update_all_verts, |
83 | 88 | kernel_update_all_verts, |
84 | 89 | kernel_update_geom_aabbs, |
85 | 90 | kernel_update_vgeoms, |
86 | | - func_hibernate__for_all_awake_islands_either_hiberanate_or_update_aabb_sort_buffer, |
87 | | - func_aggregate_awake_entities, |
88 | | - func_hibernate_entity_and_zero_dof_velocities, |
89 | | - func_update_cartesian_space_entity, |
90 | | - func_update_cartesian_space_batch, |
91 | | - func_update_cartesian_space, |
92 | 91 | kernel_update_cartesian_space, |
93 | 92 | ) |
94 | 93 | from .abd.forward_dynamics import ( |
95 | | - update_qacc_from_qvel_delta, |
96 | | - update_qvel, |
97 | | - kernel_compute_mass_matrix, |
98 | | - func_forward_dynamics, |
99 | | - kernel_forward_dynamics, |
100 | | - kernel_update_acc, |
101 | | - func_vel_at_point, |
| 94 | + func_actuation, |
| 95 | + func_bias_force, |
102 | 96 | func_compute_mass_matrix, |
| 97 | + func_compute_qacc, |
103 | 98 | func_factor_mass, |
| 99 | + func_forward_dynamics, |
104 | 100 | func_solve_mass_entity, |
105 | 101 | func_solve_mass_batch, |
106 | 102 | func_solve_mass, |
107 | 103 | func_torque_and_passive_force, |
108 | 104 | func_update_acc, |
109 | 105 | func_update_force, |
110 | | - func_actuation, |
111 | | - func_bias_force, |
112 | | - kernel_compute_qacc, |
113 | | - func_compute_qacc, |
114 | 106 | func_integrate, |
115 | | - kernel_forward_dynamics_without_qacc, |
116 | 107 | func_implicit_damping, |
| 108 | + func_vel_at_point, |
| 109 | + kernel_compute_mass_matrix, |
| 110 | + kernel_forward_dynamics, |
| 111 | + kernel_update_acc, |
| 112 | + kernel_compute_qacc, |
| 113 | + kernel_forward_dynamics_without_qacc, |
| 114 | + update_qacc_from_qvel_delta, |
| 115 | + update_qvel, |
117 | 116 | ) |
118 | 117 | from .abd.accessor import ( |
119 | 118 | kernel_get_state, |
|
156 | 155 | kernel_set_geoms_friction, |
157 | 156 | ) |
158 | 157 | from .abd.diff import ( |
| 158 | + func_copy_cartesian_space, |
159 | 159 | func_copy_next_to_curr, |
160 | 160 | func_copy_next_to_curr_grad, |
161 | | - kernel_save_adjoint_cache, |
162 | | - func_save_adjoint_cache, |
| 161 | + func_integrate_dq_entity, |
| 162 | + func_is_grad_valid, |
163 | 163 | func_load_adjoint_cache, |
| 164 | + func_save_adjoint_cache, |
| 165 | + kernel_save_adjoint_cache, |
164 | 166 | kernel_prepare_backward_substep, |
165 | 167 | kernel_begin_backward_substep, |
166 | | - func_is_grad_valid, |
167 | | - func_copy_cartesian_space, |
168 | 168 | kernel_copy_acc, |
169 | | - func_integrate_dq_entity, |
170 | 169 | ) |
171 | 170 |
|
172 | 171 | if TYPE_CHECKING: |
173 | | - import genesis.engine.solvers.rigid.array_class |
174 | 172 | from genesis.engine.scene import Scene |
175 | 173 | from genesis.engine.simulator import Simulator |
176 | 174 | from genesis.engine.entities.rigid_entity import RigidJoint, RigidLink, RigidGeom, RigidVisGeom |
@@ -1198,23 +1196,23 @@ def check_errno(self): |
1198 | 1196 | else: |
1199 | 1197 | errno = kernel_bit_reduction(self._errno) |
1200 | 1198 |
|
1201 | | - if errno & 0b00000000000000000000000000000001: |
| 1199 | + if errno & array_class.ErrorCode.OVERFLOW_CANDIDATE_CONTACTS: |
1202 | 1200 | max_collision_pairs_broad = self.collider._collider_info.max_collision_pairs_broad[None] |
1203 | 1201 | gs.raise_exception( |
1204 | 1202 | f"Exceeding max number of broad phase candidate contact pairs ({max_collision_pairs_broad}). " |
1205 | 1203 | f"Please increase the value of RigidSolver's option 'multiplier_collision_broad_phase'." |
1206 | 1204 | ) |
1207 | | - if errno & 0b00000000000000000000000000000010: |
| 1205 | + if errno & array_class.ErrorCode.OVERFLOW_COLLISION_PAIRS: |
1208 | 1206 | max_contact_pairs = self.collider._collider_info.max_contact_pairs[None] |
1209 | 1207 | gs.raise_exception( |
1210 | 1208 | f"Exceeding max number of contact pairs ({max_contact_pairs}). Please increase the value of " |
1211 | 1209 | "RigidSolver's option 'max_collision_pairs'." |
1212 | 1210 | ) |
1213 | | - if errno & 0b00000000000000000000000000000100: |
| 1211 | + if errno & array_class.ErrorCode.INVALID_FORCE_NAN: |
1214 | 1212 | gs.raise_exception("Invalid constraint forces causing 'nan'. Please decrease Rigid simulation timestep.") |
1215 | | - if errno & 0b00000000000000000000000000001000: |
| 1213 | + if errno & array_class.ErrorCode.INVALID_ACC_NAN: |
1216 | 1214 | gs.raise_exception("Invalid accelerations causing 'nan'. Please decrease Rigid simulation timestep.") |
1217 | | - if errno & 0b00000000000000000000000000010000: |
| 1215 | + if errno & array_class.ErrorCode.OVERFLOW_HIBERNATION_ISLANDS: |
1218 | 1216 | gs.raise_exception("Contact island buffer overflow. Please increase RigidOptions 'max_collision_pairs'.") |
1219 | 1217 |
|
1220 | 1218 | def _kernel_detect_collision(self): |
|
0 commit comments