sm-cli-tf.cpp
Go to the documentation of this file.
1 /*+-------------------------------------------------------------------------+
2  | MultiVehicle simulator (libmvsim) |
3  | |
4  | Copyright (C) 2014-2023 Jose Luis Blanco Claraco |
5  | Copyright (C) 2017 Borys Tymchenko (Odessa Polytechnic University) |
6  | Distributed under 3-clause BSD License |
7  | See COPYING |
8  +-------------------------------------------------------------------------+ */
9 
10 #include <mrpt/core/exceptions.h>
11 #include <mrpt/maps/CSimpleMap.h>
12 #include <mrpt/math/CLevenbergMarquardt.h>
13 
14 #include <iostream>
15 
16 #include "sm-cli.h"
17 
18 static int printCommandsTf(bool showErrorMsg);
19 
20 int commandTf()
21 {
22  const auto& lstCmds = cli->argCmd.getValue();
23  if (cli->argHelp.isSet()) return printCommandsTf(false);
24  if (lstCmds.size() != 4) return printCommandsTf(true);
25 
26  // Take second unlabeled argument:
27  const std::string inFile = lstCmds.at(1);
28  const std::string outFile = lstCmds.at(2);
29  const std::string strTf = lstCmds.at(3);
30 
31  mrpt::maps::CSimpleMap sm = read_input_sm_from_cli(inFile);
32 
33  ASSERT_(!sm.empty());
34 
35  const auto tf = mrpt::poses::CPose3D::FromString(strTf);
36  std::cout << "tf to apply: " << tf << "\n";
37 
38  // Modify KFs:
39  for (auto& [pose, sf, twist] : sm)
40  {
41  const auto p = pose->getMeanVal();
42  // This changes both, the mean and the covariance:
43  pose->changeCoordinatesReference(tf);
44  }
45 
46  // save:
47  std::cout << "Saving result to: '" << outFile << "... " << std::endl;
48  sm.saveToFile(outFile);
49 
50  return 0;
51 }
52 
53 int printCommandsTf(bool showErrorMsg)
54 {
55  if (showErrorMsg)
56  {
58  std::cerr << "Error: missing or unknown subcommand.\n";
60  }
61 
62  fprintf(
63  stderr,
64  R"XXX(Usage:
65 
66  sm-cli tf <input.simplemap> <output.simplemap> "[x y z yaw_deg pitch_deg roll_deg]"
67 
68 )XXX");
69 
70  return showErrorMsg ? 1 : 0;
71 }
cli
std::unique_ptr< cli_flags > cli
Definition: sm-cli-main.cpp:29
testing::internal::string
::std::string string
Definition: gtest.h:1979
read_input_sm_from_cli
mrpt::maps::CSimpleMap read_input_sm_from_cli(const std::string &inFile)
Definition: sm-cli-main.cpp:119
commandTf
int commandTf()
Definition: sm-cli-tf.cpp:20
sm-cli.h
setConsoleNormalColor
void setConsoleNormalColor()
Definition: sm-cli-main.cpp:49
setConsoleErrorColor
void setConsoleErrorColor()
Definition: sm-cli-main.cpp:43
printCommandsTf
static int printCommandsTf(bool showErrorMsg)
Definition: sm-cli-tf.cpp:53


mp2p_icp
Author(s):
autogenerated on Wed Oct 23 2024 02:45:41