Isaac Sim | OmniGraph | Array Index errors


When using the ArrayIndex node, there is no protection from index out of range exceptions.
Causing the following error:

2023-06-04 15:03:50 [710,130ms] [Error] [omni.graph.core.plugin] /nakai_container/MovementGraph/velocity_command_index0: inputs:index 0 is out of range for inputs:array of size 0
2023-06-04 15:03:50 [710,131ms] [Error] [omni.graph.core.plugin] /nakai_container/MovementGraph/velocity_command_index1: inputs:index 1 is out of range for inputs:array of size 0

For us, the use case is trying to extract the velocity command from a differential controller in order to control an 8-wheeled robot, but since the differential controller outputs an empty array at first, it throws the above error.

Hi @omers - You can probably add a conditional check before accessing the array elements using the ArrayIndex node. You can use the omni.graph.nodes.Compare node to check if the array size is greater than the desired index before accessing the element.

@rthaker Ok thanks. Do you think this should be added as part of the ArrayIndex node as well?

Hi @omers - Yes, you can add it as a part of ArrayIndex node.

You can add something like this:

if len(array) > index:
    value = array[index]
    value = default_value