Skip to content

Commit

Permalink
FrameSemantics: fix NullVertex warnings (#1458)
Browse files Browse the repository at this point in the history
Follow-up to gz-math#606.

Signed-off-by: Steve Peters <[email protected]>
  • Loading branch information
scpeters authored Jul 15, 2024
1 parent 133b430 commit e40331e
Showing 1 changed file with 11 additions and 7 deletions.
18 changes: 11 additions & 7 deletions src/FrameSemantics.cc
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,8 @@ FindSourceVertex(const ScopedGraph<T> &_graph,
using DirectedEdge = typename ScopedGraph<T>::Edge;
using Vertex = typename ScopedGraph<T>::Vertex;
using VertexId = gz::math::graph::VertexId;
using VertexType = typename ScopedGraph<T>::VertexType;
using gz::math::graph::NullVertex;
using EdgesType = std::vector<DirectedEdge>;
using PairType = std::pair<const Vertex &, EdgesType>;
EdgesType edges;
Expand All @@ -86,7 +88,7 @@ FindSourceVertex(const ScopedGraph<T> &_graph,
_errors.push_back({ErrorCode::POSE_RELATIVE_TO_INVALID,
"Unable to resolve pose, invalid vertex[" + std::to_string(_id) + "] "
"in PoseRelativeToGraph."});
return PairType(Vertex::NullVertex, EdgesType());
return PairType(NullVertex<VertexType>(), EdgesType());
}

if (_id == _graph.ScopeVertexId())
Expand All @@ -106,7 +108,7 @@ FindSourceVertex(const ScopedGraph<T> &_graph,
_errors.push_back({ErrorCode::POSE_RELATIVE_TO_GRAPH_ERROR,
"PoseRelativeToGraph error: multiple incoming edges to "
"current vertex [" + vertex.get().Name() + "]."});
return PairType(Vertex::NullVertex, EdgesType());
return PairType(NullVertex<VertexType>(), EdgesType());
}
auto const &edge = incidentsTo.begin()->second;
vertex = _graph.Graph().VertexFromId(edge.get().Vertices().first);
Expand All @@ -116,7 +118,7 @@ FindSourceVertex(const ScopedGraph<T> &_graph,
_errors.push_back({ErrorCode::POSE_RELATIVE_TO_CYCLE,
"PoseRelativeToGraph cycle detected, already visited vertex [" +
vertex.get().Name() + "]."});
return PairType(Vertex::NullVertex, EdgesType());
return PairType(NullVertex<VertexType>(), EdgesType());
}
if (vertex.get().Id() == _graph.ScopeVertexId())
{
Expand All @@ -129,7 +131,7 @@ FindSourceVertex(const ScopedGraph<T> &_graph,
if (vertex.get().Id() != _graph.ScopeVertexId())
{
// Error, the root vertex is not the same as the the source
return PairType(Vertex::NullVertex, EdgesType());
return PairType(NullVertex<VertexType>(), EdgesType());
}

return PairType(vertex, edges);
Expand Down Expand Up @@ -157,6 +159,8 @@ FindSinkVertex(
using DirectedEdge = typename ScopedGraph<T>::Edge;
using Vertex = typename ScopedGraph<T>::Vertex;
using VertexId = gz::math::graph::VertexId;
using VertexType = typename ScopedGraph<T>::VertexType;
using gz::math::graph::NullVertex;
using EdgesType = std::vector<DirectedEdge>;
using PairType = std::pair<const Vertex &, EdgesType>;
EdgesType edges;
Expand All @@ -166,7 +170,7 @@ FindSinkVertex(
_errors.push_back({ErrorCode::FRAME_ATTACHED_TO_INVALID,
"Invalid vertex[" + std::to_string(_id) + "] "
"in FrameAttachedToGraph."});
return PairType(Vertex::NullVertex, EdgesType());
return PairType(NullVertex<VertexType>(), EdgesType());
}

std::set<VertexId> visited;
Expand All @@ -180,7 +184,7 @@ FindSinkVertex(
_errors.push_back({ErrorCode::FRAME_ATTACHED_TO_GRAPH_ERROR,
"FrameAttachedToGraph error: multiple outgoing edges from "
"current vertex [" + vertex.get().Name() + "]."});
return PairType(Vertex::NullVertex, EdgesType());
return PairType(NullVertex<VertexType>(), EdgesType());
}
auto const &edge = incidentsFrom.begin()->second;
vertex = _graph.Graph().VertexFromId(edge.get().Vertices().second);
Expand All @@ -190,7 +194,7 @@ FindSinkVertex(
_errors.push_back({ErrorCode::FRAME_ATTACHED_TO_CYCLE,
"FrameAttachedToGraph cycle detected, already visited vertex [" +
vertex.get().Name() + "]."});
return PairType(Vertex::NullVertex, EdgesType());
return PairType(NullVertex<VertexType>(), EdgesType());
}
visited.insert(vertex.get().Id());
incidentsFrom = _graph.Graph().IncidentsFrom(vertex);
Expand Down

0 comments on commit e40331e

Please sign in to comment.