controller_base
BaseController
Bases: Serializable, Registerable, Recreatable
An abstract class with interface for mapping specific types of commands to deployable control signals.
Each instance represents a group of controllers that share the same
(robot kinematic tree pattern, body_part, controller_config) key. Members are added via
add_member() and assigned a controller_idx. All members are stepped together in a single
batched call, with per-member state stored in indexed compute-backend arrays (cb.arr_type).
External command vectors may be plain Python iterables or torch tensors; they are converted
inside :meth:update_goal. Subclasses' :meth:_update_goal and :meth:compute_no_op_goal
must return dict values as compute-backend float arrays (cb.arr_type), which are
copied into the group's batched goal buffers. Per-member _goal_set is a compute-backend bool
vector (cb.bool_zeros / cb.bool_array). Internal goals, controls, and
:meth:compute_control I/O use cb. Serialized / :meth:_dump_state goal payloads use
cb.to_torch; :meth:_load_state accepts torch tensors and cb.from_torch.
Source code in OmniGibson/omnigibson/controllers/controller_base.py
76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 | |
command_dim
property
Returns:
| Type | Description |
|---|---|
int
|
Expected size of inputted commands |
command_input_limits
property
Returns:
| Type | Description |
|---|---|
None or 2 - tuple
|
If specified, returns (min, max) command input limits for this controller, where @min and @max are numpy float arrays of length self.command_dim. Otherwise, returns None |
command_output_limits
property
Returns:
| Type | Description |
|---|---|
None or 2 - tuple
|
If specified, returns (min, max) command output limits for this controller, where @min and @max are numpy float arrays of length self.command_dim. Otherwise, returns None |
control_dim
property
Returns:
| Type | Description |
|---|---|
int
|
Expected size of outputted controls |
control_freq
property
Returns:
| Type | Description |
|---|---|
float
|
Control frequency (Hz) of this controller |
control_type
property
Returns:
| Type | Description |
|---|---|
ControlType
|
Type of control returned by this controller |
dof_idx
property
Returns:
| Type | Description |
|---|---|
Array[int]
|
DOF indices corresponding to the specific DOFs being controlled by this controller group |
goal_dim
property
Returns:
| Type | Description |
|---|---|
int
|
Expected size of flattened goals for a single group member |
isaac_kd
property
Returns:
| Type | Description |
|---|---|
None or Array[float]
|
Stiffness gains that should be applied to the underlying Isaac joint motors. None if not specified. |
isaac_kp
property
Returns:
| Type | Description |
|---|---|
None or Array[float]
|
Stiffness gains that should be applied to the underlying Isaac joint motors. None if not specified. |
n_members
property
Returns:
| Type | Description |
|---|---|
int
|
Number of controllers registered in this controller group |
routing_path
property
Returns:
| Type | Description |
|---|---|
str
|
Articulation root path of the first member, used as a routing key for ControllableObjectViewAPI pattern lookups. All members in a group share the same view pattern, so any member's path works; index 0 is canonical. |
__init__(control_freq, control_limits, dof_idx, command_input_limits='default', command_output_limits='default', isaac_kp=None, isaac_kd=None)
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
control_freq
|
int
|
controller loop frequency |
required |
control_limits
|
Dict[str, Tuple[Array[float], Array[float]]]
|
The min/max limits to the outputted control signal. Should specify per-dof type limits, i.e.: "position": [[min], [max]] "velocity": [[min], [max]] "effort": [[min], [max]] "has_limit": [...bool...] Values outside of this range will be clipped, if the corresponding joint index in has_limit is True. |
required |
dof_idx
|
Array[int]
|
specific dof indices controlled by this robot. Used for inferring controller-relevant values during control computations |
required |
command_input_limits
|
None or default or Tuple[float, float] or Tuple[Array[float], Array[float]]
|
if set, is the min/max acceptable inputted command. Values outside this range will be clipped. If None, no clipping will be used. If "default", range will be set to (-1, 1) |
'default'
|
command_output_limits
|
None or default or Tuple[float, float] or Tuple[Array[float], Array[float]]
|
if set, is the min/max scaled command. If both this value and @command_input_limits is not None, then all inputted command values will be scaled from the input range to the output range. If either is None, no scaling will be used. If "default", then this range will automatically be set to the @control_limits entry corresponding to self.control_type |
'default'
|
isaac_kp
|
None or float or Array[float]
|
If specified, stiffness gains to apply to the underlying isaac DOFs. Can either be a single number or a per-DOF set of numbers. Should only be nonzero if self.control_type is position |
None
|
isaac_kd
|
None or float or Array[float]
|
If specified, damping gains to apply to the underlying isaac DOFs. Can either be a single number or a per-DOF set of numbers Should only be nonzero if self.control_type is position or velocity |
None
|
Source code in OmniGibson/omnigibson/controllers/controller_base.py
94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 | |
add_member(articulation_root_path, control_enabled=True)
Register a controller as a member of this controller group.
Reuses the first tombstoned (unregistered) slot if one exists, otherwise appends a new slot.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
articulation_root_path
|
str
|
articulation root prim path of the new group member |
required |
Returns:
| Type | Description |
|---|---|
int
|
controller_idx — index into this group's member arrays for the added controller, used to access goal, control, and articulation_root_path |
Source code in OmniGibson/omnigibson/controllers/controller_base.py
clip_control(control)
Clips the inputted @control signal based on @control_limits.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
control
|
arr_type
|
(N, control_dim) control signal to clip |
required |
Returns:
| Type | Description |
|---|---|
arr_type
|
Clipped (N, control_dim) control signal |
Source code in OmniGibson/omnigibson/controllers/controller_base.py
compute_control(goals)
Converts batched @goals into deployable (non-clipped!) control signals for all member controllers.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
goals
|
Dict[str, arr_type]
|
batched goals, each value has shape (N, *shape) |
required |
Returns:
| Type | Description |
|---|---|
arr_type
|
(N, control_dim) control signals |
Source code in OmniGibson/omnigibson/controllers/controller_base.py
compute_no_op_action(controller_idx)
Compute a no-op action that updates the goal to match the current position Disclaimer: this no-op might cause drift under external load (e.g. when the controller cannot reach the goal position)
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
controller_idx
|
int
|
index of the controller in this group |
required |
Returns:
| Type | Description |
|---|---|
arr_type
|
no-op action command |
Source code in OmniGibson/omnigibson/controllers/controller_base.py
compute_no_op_goal(controller_idx)
Compute no-op goal for the controller at @controller_idx.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
controller_idx
|
int
|
index of the controller in this controller group |
required |
Returns:
| Type | Description |
|---|---|
dict
|
Maps relevant goal keys to compute-backend arrays for that controller |
Source code in OmniGibson/omnigibson/controllers/controller_base.py
dump_state(controller_idx, serialized=False)
Dumps the state for a single controller member.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
controller_idx
|
int
|
member index in this controller group |
required |
serialized
|
bool
|
whether to return flattened serialized state |
False
|
Returns:
| Type | Description |
|---|---|
dict or Tensor
|
member state for this controller_idx |
Source code in OmniGibson/omnigibson/controllers/controller_base.py
get_control(controller_idx)
Returns the last deployed control signal for the controller at @controller_idx.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
controller_idx
|
int
|
index of the controller in this group |
required |
Returns:
| Type | Description |
|---|---|
arr_type
|
last control vector of shape (control_dim,). |
Source code in OmniGibson/omnigibson/controllers/controller_base.py
get_goal(controller_idx)
Returns the current goal for the controller at @controller_idx.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
controller_idx
|
int
|
index of the controller in this group |
required |
Returns:
| Type | Description |
|---|---|
dict
|
Maps goal keys to per-controller compute-backend arrays of shape (*shape). |
Source code in OmniGibson/omnigibson/controllers/controller_base.py
has_no_active_members()
load_state(controller_idx, state, serialized=False)
Loads state for a single controller member.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
controller_idx
|
int
|
member index in this controller group |
required |
state
|
dict or Tensor
|
member state payload |
required |
serialized
|
bool
|
whether @state is serialized |
False
|
Source code in OmniGibson/omnigibson/controllers/controller_base.py
nums2array(nums, dim)
staticmethod
Convert input @nums into numpy array of length @dim. If @nums is a single number, broadcasts it to the corresponding dimension size @dim before converting into a numpy array
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
nums
|
numeric or Iterable
|
Either single value or array of numbers |
required |
dim
|
int
|
Size of array to broadcast input to |
required |
Returns:
| Type | Description |
|---|---|
Array
|
Array filled with values specified in @nums |
Source code in OmniGibson/omnigibson/controllers/controller_base.py
reset(controller_idx)
Resets the goal state for the controller at @controller_idx. Can be extended by subclass
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
controller_idx
|
int
|
index of the controller in this controller group |
required |
Source code in OmniGibson/omnigibson/controllers/controller_base.py
step()
Take a batched controller step across all member controller.
For any controller that has not received a goal yet, a no-op goal is computed. The control is then computed for all controllers, clipped, written to Isaac, and the goal_set flags are reset.
Source code in OmniGibson/omnigibson/controllers/controller_base.py
unregister_member(controller_idx)
Mark member at controller_idx as a tombstone (can be reused by new member).
update_goal(controller_idx, command)
Updates the goal for controller at @controller_idx with the given @command.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
controller_idx
|
int
|
index of the controller in this controller group |
required |
command
|
Array[float]
|
inputted command to preprocess and extract relevant goal(s) |
required |
Source code in OmniGibson/omnigibson/controllers/controller_base.py
ControlType
Source code in OmniGibson/omnigibson/controllers/controller_base.py
get_type(type_str)
classmethod
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
type_str
|
str
|
One of "position", "velocity", or "effort" (any case), and maps it to the corresponding type |
required |
Returns:
| Type | Description |
|---|---|
ControlType
|
control type corresponding to the associated string |
Source code in OmniGibson/omnigibson/controllers/controller_base.py
GripperController
Bases: BaseController
Controller to control a gripper. All implemented controllers that encompass gripper capabilities should extend from this class.
Source code in OmniGibson/omnigibson/controllers/controller_base.py
is_grasping(controller_idx)
Checks whether the current state of this gripper being controlled is in a grasping state. Should be implemented by subclass.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
controller_idx
|
int
|
index of the controller in this group. Used for MultiFingerGripperController. |
required |
Returns:
| Type | Description |
|---|---|
IsGraspingState
|
Grasping state of gripper |
Source code in OmniGibson/omnigibson/controllers/controller_base.py
LocomotionController
Bases: BaseController
Controller to control locomotion. All implemented controllers that encompass locomotion capabilities should extend from this class.
Source code in OmniGibson/omnigibson/controllers/controller_base.py
ManipulationController
Bases: BaseController
Controller to control manipulation. All implemented controllers that encompass manipulation capabilities should extend from this class.