nodeIDs
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.
Examples
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
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"POSE_SE3_SCALE"
— Pose scale in SE(3) state space"TRANSFORM_SE3"
— Sensor transform 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:
"factorIMU"
—factorIMU
"factorGPS"
—factorGPS
"factorCameraSE3AndPointXYZ"
—factorCameraSE3AndPointXYZ
"factorPoseSE2AndPointXY"
—factorPoseSE2AndPointXY
"factorPoseSE3AndPointXYZ"
—factorPoseSE3AndPointXYZ
"factorTwoPoseSE2"
—factorTwoPoseSE2
"factorTwoPoseSE3"
—factorTwoPoseSE3
"factorTwoPoseSIM3"
—factorTwoPoseSIM3
"factorIMUBiasPrior"
—factorIMUBiasPrior
"factorPoseSE3Prior"
—factorPoseSE3Prior
"factorVelocity3Prior"
—factorVelocity3Prior
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
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.
Extended Capabilities
When generating portable C code with a C++ compiler, you must specify hierarchical
packing with non-minimal headers. For more information on packaging options, see the
packNGo
(MATLAB Coder) function.
Version History
Introduced in R2022aYou can now get node IDs related by the SIM(3) similarity transformation factor using
the factorTwoPoseSIM3
object. You can now get node IDs of pose scale nodes using
"POSE_SE3_SCALE"
and node IDs of sensor transform nodes using
"TRANSFORM_SE3"
.
nodeIDs
now supports getting node IDs that match node type,
factor type, or group ID.
See Also
MATLAB Command
You clicked a link that corresponds to this MATLAB command:
Run the command by entering it in the MATLAB Command Window. Web browsers do not support MATLAB commands.
Select a Web Site
Choose a web site to get translated content where available and see local events and offers. Based on your location, we recommend that you select: United States.
You can also select a web site from the following list
How to Get Best Site Performance
Select the China site (in Chinese or English) for best site performance. Other MathWorks country sites are not optimized for visits from your location.
Americas
- América Latina (Español)
- Canada (English)
- United States (English)
Europe
- Belgium (English)
- Denmark (English)
- Deutschland (Deutsch)
- España (Español)
- Finland (English)
- France (Français)
- Ireland (English)
- Italia (Italiano)
- Luxembourg (English)
- Netherlands (English)
- Norway (English)
- Österreich (Deutsch)
- Portugal (English)
- Sweden (English)
- Switzerland
- United Kingdom (English)