Skip to content

Commit 13ecd6a

Browse files
committed
[mc_bin_utils] Add an option to show stored calibration/initialization in logs
1 parent 5ab6cc3 commit 13ecd6a

File tree

2 files changed

+39
-1
lines changed

2 files changed

+39
-1
lines changed

doc/_i18n/en/tutorials/tools/mc_log_utils.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ Available commands:
1717
Use mc_bin_utils <command> --help for usage of each command
1818
```
1919

20-
We will covert the `extract` and `convert` commands. `show` and `split` are self-explanatory.
20+
We will cover the `extract` and `convert` commands. `show` and `split` are self-explanatory.
2121

2222
### `mc_bin_utils extract`
2323

utils/mc_bin_utils.in.cpp

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -111,10 +111,14 @@ int show(int argc, char * argv[])
111111
{
112112
po::variables_map vm;
113113
po::options_description tool("mc_bin_utils show options");
114+
bool print_calib = false;
114115
bool print_events = false;
116+
bool print_init = false;
115117
// clang-format off
116118
tool.add_options()
117119
("help", "Produce this message")
120+
("print-init", po::bool_switch(&print_init), "Show initial positions/configurations of the robots")
121+
("print-calib", po::bool_switch(&print_calib), "Show the stored force sensor calibration")
118122
("print-events", po::bool_switch(&print_events), "Show GUI events in the log")
119123
("in", po::value<std::string>(), "Input file");
120124
// clang-format on
@@ -165,6 +169,40 @@ int show(int argc, char * argv[])
165169
std::cout << "Timestep: " << meta->timestep << "\n";
166170
std::cout << "MainRobot: " << meta->main_robot << "\n";
167171
std::cout << "MainRobotParams: " << mc_rtc::io::to_string(meta->main_robot_module) << "\n";
172+
if(print_init)
173+
{
174+
for(const auto & [r, init_pos] : meta->init)
175+
{
176+
std::cout << r << " initial pose:\n";
177+
std::cout << " translation: " << init_pos.translation().transpose() << "\n";
178+
const auto & q = Eigen::Quaterniond(init_pos.rotation());
179+
std::cout << " rotation: [" << mc_rtc::io::to_string(std::array{q.w(), q.x(), q.y(), q.z()}) << "]\n";
180+
}
181+
for(const auto & [r, init_q] : meta->init_q)
182+
{
183+
std::cout << r << " initial configuration:\n";
184+
std::cout << "["
185+
<< mc_rtc::io::to_string(init_q,
186+
[](const auto & qi) { return "[" + mc_rtc::io::to_string(qi) + "]"; })
187+
<< "]\n";
188+
}
189+
}
190+
if(print_calib)
191+
{
192+
for(const auto & [r, calibs] : meta->calibs)
193+
{
194+
if(calibs.empty())
195+
{
196+
std::cout << r << ": No calibration data\n";
197+
continue;
198+
}
199+
for(const auto & [sensor, calib] : calibs)
200+
{
201+
std::cout << r << "::" << sensor << ":\n";
202+
std::cout << calib.dump(true, true) << "\n";
203+
}
204+
}
205+
}
168206
}
169207
std::cout << "Entries: " << keys.size() << "\n";
170208
std::cout << "GUI events: " << n_events << "\n";

0 commit comments

Comments
 (0)