Main Content

# nodeIDs

Get node IDs in factor graph

Since R2022a

## Syntax

``ids = nodeIDs(fg)``
``ids = nodeIDs(fg,Name=Value)``

## Description

The `nodeIDs` function gets all node IDs or gets a subset of node IDs from a factor graph for nodes of the same node type, group ID, or connect to factors of the same factor type.

````ids = nodeIDs(fg)` gets all node IDs currently in the factor graph.```
````ids = nodeIDs(fg,Name=Value)` specifies options using one or more name-value arguments.```

example

## Examples

collapse all

This example shows four ways of querying a factor graph for node IDs.

Create a factor graph containing four SE(3) pose nodes.

```fg = factorGraph; poseIDs = generateNodeID(fg,3,"factorTwoPoseSE3")```
```poseIDs = 3×2 0 1 1 2 2 3 ```
`poseFactors = factorTwoPoseSE3(poseIDs);`

Create group IDs that will put node IDs 0 and 1 into group 1, and node IDs 2 and 3 into group 2.

```group = [1 1; 1 2; 2 2]; addFactor(fg,poseFactors,group);```

Create and add a landmark factor connecting node 3 to a new node 4. Add both nodes to group 3. Note that nodes can exist in more than one group at the same time.

```lmFactor = factorPoseSE3AndPointXYZ([3 4]); addFactor(fg,lmFactor,3);```

Get All IDs in Factor Graph

Use `nodeIDs` to get all the IDs in the factor graph by specifying no additional arguments other than the factor graph.

`idAll = nodeIDs(fg)`
```idAll = 1×5 0 1 2 3 4 ```

Get Node IDs by Node Type

Use `nodeIDs` and specify the `NodeType` name-value argument as `"POSE_SE3"` to get all of the SE(3) pose nodes.

`idByNode = nodeIDs(fg,NodeType="POSE_SE3")`
```idByNode = 1×4 0 1 2 3 ```

Get Node IDs by Factor Type

Use `nodeIDs` and specify the `FactorType` name-value argument as `"factorPoseSE3AndPointXYZ"` to get all of the nodes related by a `factorPoseSE3AndPointXYZ` factor.

`idByFactor = nodeIDs(fg,FactorType="factorPoseSE3AndPointXYZ")`
```idByFactor = 1×2 3 4 ```

Get Node IDs by Group ID

Use `nodeIDs` and specify the `FactorType` name-value argument as `"factorTwoPoseSE3"` to get all of the nodes related by a `factorTwoPoseSE3` factor.

`idGroup1 = nodeIDs(fg,GroupID=1)`
```idGroup1 = 1×2 0 1 ```
`idGroup2 = nodeIDs(fg,GroupID=2)`
```idGroup2 = 1×2 2 3 ```
`idGroup3 = nodeIDs(fg,GroupID=3)`
```idGroup3 = 1×2 3 4 ```

## Input Arguments

collapse all

Factor graph, specified as a `factorGraph` object.

### Name-Value Arguments

Specify optional pairs of arguments as `Name1=Value1,...,NameN=ValueN`, where `Name` is the argument name and `Value` is the corresponding value. Name-value arguments must appear after other arguments, but the order of the pairs does not matter.

Example: `nodeIDs(fg,GroupID=1)` retrieves all of the node IDs of factor graph `fg` that are associated with group `1`.

Node type of the desired nodes in the factor graph, specified as one of these options:

• `"POSE_SE2"` — Pose in SE(2) state space

• `"POSE_SE3"` — Pose in SE(3) state space

• `"VEL3"` — 3-D velocity

• `"POINT_XY"` — 2-D point

• `"POINT_XYZ"` — 3-D point

• `"IMU_BIAS"` — IMU gyroscope and accelerometer bias

Example: `nodeIDs(fg,NodeType="POSE_SE2")` retrieves all of the node IDs of nodes that are of node type `POSE_SE2`.

Data Types: `char` | `string`

Factor type that the nodes relate to in the factor graph, specified as one of these options:

Example: `nodeIDs(fg,FactorType="factorTwoPoseSE2")` retrieves all of the node IDs of nodes that relate to factors of type `factorTwoPoseSE2`.

Data Types: `char` | `string`

Group ID of desired nodes, specified as a nonnegative integer or N-element row vector of nonnegative integers. N is the number of groups.

If `GroupID` is an N-element row vector of nonnegative integers, there must be no duplicate group IDs in the vector.

To add nodes to a group, specify the group using the `groupID` argument of the `addFactor` function.

Example: `nodeIDs(fg,GroupID=4)` retrieves all of the node IDs of nodes that are in group `4`.

## Output Arguments

collapse all

Node IDs of all nodes that fit the specified criteria within the specified `factorGraph` object, returned as an N-element row vector. N is the number of returned nodes. Note that the node IDs may not be continuous within the vector.

## Version History

Introduced in R2022a

expand all