For factor graph graphviz output, added options to change the graph scale and manually specify factor positions
parent
ca4cf782f2
commit
4f4898beb1
|
@ -129,7 +129,7 @@ void NonlinearFactorGraph::saveGraph(std::ostream &stm, const Values& values,
|
|||
if(values.exists(key)) {
|
||||
boost::optional<Point2> xy = getXY(values.at(key), graphvizFormatting);
|
||||
if(xy)
|
||||
stm << ", pos=\"" << (xy->x() - minX) << "," << (xy->y() - minY) << "!\"";
|
||||
stm << ", pos=\"" << graphvizFormatting.scale*(xy->x() - minX) << "," << graphvizFormatting.scale*(xy->y() - minY) << "!\"";
|
||||
}
|
||||
stm << "];\n";
|
||||
}
|
||||
|
@ -150,7 +150,13 @@ void NonlinearFactorGraph::saveGraph(std::ostream &stm, const Values& values,
|
|||
size_t i = 0;
|
||||
BOOST_FOREACH(const vector<Key>& factorKeys, structure) {
|
||||
// Make each factor a dot
|
||||
stm << " factor" << i << "[label=\"\", shape=point];\n";
|
||||
stm << " factor" << i << "[label=\"\", shape=point";
|
||||
{
|
||||
map<size_t, Point2>::const_iterator pos = graphvizFormatting.factorPositions.find(i);
|
||||
if(pos != graphvizFormatting.factorPositions.end())
|
||||
stm << ", pos=\"" << graphvizFormatting.scale*(pos->second.x() - minX) << "," << graphvizFormatting.scale*(pos->second.y() - minY) << "!\"";
|
||||
}
|
||||
stm << "];\n";
|
||||
|
||||
// Make factor-variable connections
|
||||
BOOST_FOREACH(Key key, factorKeys) {
|
||||
|
|
|
@ -21,6 +21,7 @@
|
|||
|
||||
#pragma once
|
||||
|
||||
#include <gtsam/geometry/Point2.h>
|
||||
#include <gtsam/inference/SymbolicFactorGraph.h>
|
||||
#include <gtsam/linear/GaussianFactorGraph.h>
|
||||
#include <gtsam/nonlinear/NonlinearFactor.h>
|
||||
|
@ -37,12 +38,14 @@ namespace gtsam {
|
|||
Axis paperVerticalAxis; ///< The world axis assigned to the vertical paper axis
|
||||
double figureWidthInches; ///< The figure width on paper in inches
|
||||
double figureHeightInches; ///< The figure height on paper in inches
|
||||
double scale; ///< Scale all positions to reduce / increase density
|
||||
bool mergeSimilarFactors; ///< Merge multiple factors that have the same connectivity
|
||||
std::map<size_t, Point2> factorPositions; ///< (optional for each factor) Manually specify factor "dot" positions.
|
||||
/// Default constructor sets up robot coordinates. Paper horizontal is robot Y,
|
||||
/// paper vertical is robot X. Default figure size of 5x5 in.
|
||||
GraphvizFormatting() :
|
||||
paperHorizontalAxis(Y), paperVerticalAxis(X),
|
||||
figureWidthInches(5), figureHeightInches(5),
|
||||
figureWidthInches(5), figureHeightInches(5), scale(1),
|
||||
mergeSimilarFactors(false) {}
|
||||
};
|
||||
|
||||
|
|
Loading…
Reference in New Issue