controller_base
BaseController
Bases: Serializable
, Registerable
, Recreatable
An abstract class with interface for mapping specific types of commands to deployable control signals.
Source code in omnigibson/controllers/controller_base.py
66 67 68 69 70 71 72 73 74 75 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 |
|
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
property
Returns:
Type | Description |
---|---|
n - array
|
Array of most recent controls deployed by this controller |
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 robot |
goal
property
Returns:
Type | Description |
---|---|
dict
|
Current goal for this controller. Maps relevant goal keys to goal values to be used during controller step computations |
goal_dim
property
Returns:
Type | Description |
---|---|
int
|
Expected size of flattened, internal goals |
__init__(control_freq, control_limits, dof_idx, command_input_limits='default', command_output_limits='default')
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'
|
Source code in omnigibson/controllers/controller_base.py
71 72 73 74 75 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 |
|
clip_control(control)
Clips the inputted @control signal based on @control_limits.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
control
|
Array[float]
|
control signal to clip |
required |
Returns:
Type | Description |
---|---|
Array[float]
|
Clipped control signal |
Source code in omnigibson/controllers/controller_base.py
compute_control(goal_dict, control_dict)
Converts the (already preprocessed) inputted @command into deployable (non-clipped!) control signal. Should be implemented by subclass.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
goal_dict
|
Dict[str, Any]
|
dictionary that should include any relevant keyword-mapped goals necessary for controller computation |
required |
control_dict
|
Dict[str, Any]
|
dictionary that should include any relevant keyword-mapped states necessary for controller computation |
required |
Returns:
Type | Description |
---|---|
Array[float]
|
outputted (non-clipped!) control signal to deploy |
Source code in omnigibson/controllers/controller_base.py
compute_no_op_action(control_dict)
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)
Source code in omnigibson/controllers/controller_base.py
compute_no_op_goal(control_dict)
Compute no-op goal given the current state @control_dict
Parameters:
Name | Type | Description | Default |
---|---|---|---|
control_dict
|
dict
|
Current state |
required |
Returns:
Type | Description |
---|---|
dict
|
Maps relevant goal keys (from self._goal_shapes.keys()) to relevant goal data to be used in controller computations |
Source code in 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 |
---|---|
tensor
|
Array filled with values specified in @nums |
Source code in omnigibson/controllers/controller_base.py
reset()
step(control_dict)
Take a controller step.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
control_dict
|
Dict[str, Any]
|
dictionary that should include any relevant keyword-mapped states necessary for controller computation |
required |
Returns:
Type | Description |
---|---|
Array[float]
|
numpy array of outputted control signals |
Source code in omnigibson/controllers/controller_base.py
update_goal(command, control_dict)
Updates inputted @command internally, writing any necessary internal variables as needed.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
command
|
Array[float]
|
inputted command to preprocess and extract relevant goal(s) to store internally in this controller |
required |
control_dict
|
dict
|
Current state |
required |
Source code in omnigibson/controllers/controller_base.py
ControlType
Source code in 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/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/controllers/controller_base.py
is_grasping()
Checks whether the current state of this gripper being controlled is in a grasping state. Should be implemented by subclass.
Returns:
Type | Description |
---|---|
IsGraspingState
|
Grasping state of gripper |
Source code in 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/controllers/controller_base.py
ManipulationController
Bases: BaseController
Controller to control manipulation. All implemented controllers that encompass manipulation capabilities should extend from this class.