Ejemplo n.º 1
0
#!/usr/bin/python

from __future__ import print_function

import argparse
import sys
from utils import DefaultHelpParser

if __name__ == "__main__":

    parser = DefaultHelpParser(
        description='Transplant vertex poses from one g2o file to another.')

    parser.add_argument("input",
                        type=argparse.FileType('r'),
                        help="g2o file to transplant poses to.")
    parser.add_argument("poses",
                        type=argparse.FileType('r'),
                        help="g2o file to transplant poses from.")
    parser.add_argument("output",
                        type=argparse.FileType('w'),
                        help="Output g2o file.")

    args = parser.parse_args()

    poses = dict()

    for l in args.poses:
        e = l.split()

        if e[0] == "VERTEX_SE2" or e[0] == "VERTEX_SE3:QUAT":
        for b in e.motion_batches:
            for m in b.motions:
                w = m.weight
                self.out.write(
                    " %s %s %d %d %s" %
                    (self.edge_tag, str(w * b.batch_weight), e.reference,
                     b.target, " ".join([str(x) for x in m])))

        self.out.write("\n")


if __name__ == "__main__":

    parser = DefaultHelpParser(
        description=
        'Convert a pair of original g2o file with corresponding outliers to hyper maxmixture graph.'
    )

    parser.add_argument(
        "input",
        type=argparse.FileType('r'),
        help="Path to the original dataset file (in g2o format).")
    parser.add_argument("outliers",
                        type=argparse.FileType('r'),
                        help="Outliers will be read from this file.")
    parser.add_argument("output",
                        type=argparse.FileType('w'),
                        help="Plain graph will be written into this file.")
    parser.add_argument(
        "--make-all-loops-hyperedges",
        default=False,
Ejemplo n.º 3
0
#!/usr/bin/python

import argparse
import sys
import os
import glob
import traceback
from subprocess import check_call
from utils import DefaultHelpParser

if __name__ == "__main__":

	parser = DefaultHelpParser(description='Convert many outlier files with a single original dataset with any of the one-shot converters. Additional arguments are passed on to worker conversion script.')

	parser.add_argument("worker", help="Script to use for conversion")
	parser.add_argument("input", help = "Path to the original dataset file (in g2o format).")
	parser.add_argument("outliers", nargs="+", help = "Filenames or glob patterns matching outlier files.")
	parser.add_argument("--output-dir", help="Optional output directory other than the directory containing outliers")
	parser.add_argument("--output-prefix", help="Optional prefix that is prepended to the output file name")
	parser.add_argument("--output-suffix", help="Optional suffix that is prepended to the output file name")
	

	(args, extra_args) = parser.parse_known_args()

	print "Extra args to be passed on are: ", extra_args

	if not os.path.exists(args.worker) or not os.path.exists(args.input):
		print "ERROR: worker script or input file does not exist!"
		exit(1)

	args.worker = os.path.realpath(args.worker)
Ejemplo n.º 4
0
                  i,
                  "not in reference file!",
                  file=sys.stderr)
            return

        v_ref = self.ref.V[i]
        (err_tr, err_rot) = pu.errors(v_ref, v)

        self.errors_tr.append(err_tr)
        self.errors_rot.append(err_rot)


if __name__ == "__main__":

    parser = DefaultHelpParser(
        description=
        'Compute RMSE errors for translation and rotation (based on angle only) for a set of g2o graph files, given a reference g2o graph file (e.g. ground truth).'
    )

    parser.add_argument("reference",
                        type=argparse.FileType('r'),
                        help="Path to the reference (in g2o format).")
    parser.add_argument(
        "graphs",
        nargs="+",
        help="Filenames or glob patterns matching g2o files to be processed.")
    parser.add_argument(
        "-o",
        "--output",
        type=argparse.FileType('a+'),
        help="Output file to append the errors to. Default: stdout")
    parser.add_argument(
Ejemplo n.º 5
0
#!/usr/bin/python

from __future__ import print_function

import argparse
import sys
import graph as G
from utils import DefaultHelpParser


if __name__ == "__main__":

	parser = DefaultHelpParser(description='Read g2o file and filter out duplicate edges and so on.')

	parser.add_argument("input", type=argparse.FileType('r'), help = "Path to the original dataset file (in g2o format).")
	parser.add_argument("output", type=argparse.FileType('w'), help = "Output graph will be written into this file.")
	parser.add_argument("--zero-poses", default=False, dest="do_zero", action='store_true', help="If given, set all poses to identity.")

	args = parser.parse_args()


	g = G.readg2o(args.input)

	if args.do_zero:
		g.setNonfixedPosesToZero()

	g.writeg2o(args.output)
Ejemplo n.º 6
0
#!/usr/bin/python

from __future__ import print_function

import argparse
import sys
import graph as G
from utils import DefaultHelpParser

if __name__ == "__main__":

    parser = DefaultHelpParser(description='Read g2o file set poses to zero.')

    parser.add_argument(
        "input",
        type=argparse.FileType('r'),
        help="Path to the original dataset file (in g2o format).")
    parser.add_argument("output",
                        type=argparse.FileType('w'),
                        help="Output graph will be written into this file.")

    args = parser.parse_args()

    g = G.readg2o(args.input)

    g.setNonfixedPosesToZero()

    g.writeg2o(args.output)
from utils import DefaultHelpParser


class plain_output(G.base_g2o_output):
    def output_edge(self, i, e):
        for b in e.motion_batches:
            for m in b.motions:
                print("%s %d %d %s" % (self.edge_tag, e.reference, b.target,
                                       " ".join([str(x) for x in m])),
                      file=self.out)


if __name__ == "__main__":

    parser = DefaultHelpParser(
        description=
        'Convert a pair of original g2o file with corresponding outliers to plain g2o graph where all outliers are normal edges.'
    )

    parser.add_argument(
        "input",
        type=argparse.FileType('r'),
        help="Path to the original dataset file (in g2o format).")
    parser.add_argument("outliers",
                        type=argparse.FileType('r'),
                        help="Outliers will be read from this file.")
    parser.add_argument("output",
                        type=argparse.FileType('w'),
                        help="Plain graph will be written into this file.")
    parser.add_argument(
        "--make-all-loops-hyperedges",
        default=False,
Ejemplo n.º 8
0
#!/usr/bin/python


import argparse
import sys
import os
import glob
import traceback
from subprocess import check_call
from utils import DefaultHelpParser

if __name__ == "__main__":

	parser = DefaultHelpParser(description='Run g2o command line executable with options for many g2o files. Additional command line options are passed on to g2o.')

	parser.add_argument("graphs", nargs="+", help = "Filenames or glob patterns matching g2o files to be optimized.")
	parser.add_argument("--g2o", default="/opt/g2o/bin/g2o", help="Path to the g2o executable")
	parser.add_argument("--solver", default="gn_var_cholmod", help="Solver to use in g2o, default: gn_var_cholmod")
	parser.add_argument("--max-iterations", type=int, default=20, help="Number of iterations to run, default: 20")
	parser.add_argument("--env", default=["LD_LIBRARY_PATH=/opt/g2o/lib"], nargs="*", help="List of environment variables to set for subprocess calling g2o. e.g. LD_LIBRARY_PATH+=bla. = assigns, += appends (with semicolon)")
	parser.add_argument("--output-dir", help="Optional output directory other than the directory containing g2o files")
	parser.add_argument("--output-prefix", help="Optional prefix that is prepended to the output file name")
	parser.add_argument("--output-suffix", help="Optional suffix that is prepended to the output file name")

	(args, extra_args) = parser.parse_known_args()


	print "Going to pass these args on to g2o:", extra_args

	if not os.path.exists(args.g2o):
		print "ERROR: g2o executable not valid!"
Ejemplo n.º 9
0
                print("VERTEX_SWITCH %d %s" % (self.max_vertex_id, str(prior)),
                      file=self.out)
                print("EDGE_SWITCH_PRIOR %d %s %s" %
                      (self.max_vertex_id, str(prior), str(self.switch_inf)),
                      file=self.out)
                print("%s %d %d %d %s" %
                      (self.switchable_edge_tag, e.reference, b.target,
                       self.max_vertex_id, " ".join([str(x) for x in m])),
                      file=self.out)


if __name__ == "__main__":

    parser = DefaultHelpParser(
        description=
        'Convert a pair of original g2o file with corresponding outliers to a switchable constraints graph.'
    )

    parser.add_argument(
        "input",
        type=argparse.FileType('r'),
        help="Path to the original dataset file (in g2o format).")
    parser.add_argument("outliers",
                        type=argparse.FileType('r'),
                        help="Outliers will be read from this file.")
    parser.add_argument("output",
                        type=argparse.FileType('w'),
                        help="Plain graph will be written into this file.")
    parser.add_argument(
        "--make-all-loops-hyperedges",
        default=False,