tools
Recovery
tools/Recovery/main.cpp
Go to the documentation of this file.
1
/*
2
Copyright (c) 2010-2016, Mathieu Labbe - IntRoLab - Universite de Sherbrooke
3
All rights reserved.
4
5
Redistribution and use in source and binary forms, with or without
6
modification, are permitted provided that the following conditions are met:
7
* Redistributions of source code must retain the above copyright
8
notice, this list of conditions and the following disclaimer.
9
* Redistributions in binary form must reproduce the above copyright
10
notice, this list of conditions and the following disclaimer in the
11
documentation and/or other materials provided with the distribution.
12
* Neither the name of the Universite de Sherbrooke nor the
13
names of its contributors may be used to endorse or promote products
14
derived from this software without specific prior written permission.
15
16
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
17
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
18
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
19
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY
20
DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
21
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
22
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
23
ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
24
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
25
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26
*/
27
28
#include <
rtabmap/core/Recovery.h
>
29
#include <
rtabmap/core/ProgressState.h
>
30
#include <stdio.h>
31
#include <string.h>
32
#include <stdlib.h>
33
#include <signal.h>
34
35
using namespace
rtabmap
;
36
37
void
showUsage
()
38
{
39
printf(
"\nUsage:\n"
40
"rtabmap-recovery [-d] \"my_corrupted_map.db\""
41
" Options:\n"
42
" -d Delete database backup on success (\"*.backup.db\").\n"
43
"\n"
);
44
exit(1);
45
}
46
47
class
RecoveryProgressState
:
public
ProgressState
48
{
49
virtual
bool
callback
(
const
std::string & msg)
const
50
{
51
if
(!
msg
.empty())
52
printf(
"%s\n"
,
msg
.c_str());
53
return
true
;
54
}
55
};
56
RecoveryProgressState
state
;
57
58
// catch ctrl-c
59
void
sighandler
(
int
sig)
60
{
61
printf(
"\nSignal %d caught...\n"
, sig);
62
state
.
setCanceled
(
true
);
63
}
64
65
int
main
(
int
argc,
char
*
argv
[])
66
{
67
signal(SIGABRT, &
sighandler
);
68
signal(SIGTERM, &
sighandler
);
69
signal(SIGINT, &
sighandler
);
70
71
ULogger::setType
(
ULogger::kTypeConsole
);
72
ULogger::setLevel
(
ULogger::kError
);
73
74
if
(argc < 2)
75
{
76
showUsage
();
77
}
78
79
bool
keepBackup =
true
;
80
for
(
int
i
=1;
i
<argc; ++
i
)
81
{
82
if
(strcmp(
argv
[
i
],
"-d"
) == 0)
83
{
84
keepBackup =
false
;
85
}
86
}
87
88
std::string databasePath =
argv
[argc-1];
89
90
std::string errorMsg;
91
printf(
"Recovering \"%s\"\n"
, databasePath.c_str());
92
if
(!
databaseRecovery
(databasePath, keepBackup, &errorMsg, &
state
))
93
{
94
printf(
"Error: %s\n"
, errorMsg.c_str());
95
return
1;
96
}
97
98
return
0;
99
}
ULogger::kError
@ kError
Definition:
ULogger.h:252
ULogger::kTypeConsole
@ kTypeConsole
Definition:
ULogger.h:244
ULogger::setLevel
static void setLevel(ULogger::Level level)
Definition:
ULogger.h:339
rtabmap::ProgressState::setCanceled
void setCanceled(bool canceled)
Definition:
ProgressState.h:47
showUsage
void showUsage()
Definition:
tools/Recovery/main.cpp:37
state
RecoveryProgressState state
Definition:
tools/Recovery/main.cpp:56
ProgressState.h
main
int main(int argc, char *argv[])
Definition:
tools/Recovery/main.cpp:65
rtabmap_netvlad.argv
argv
Definition:
rtabmap_netvlad.py:15
rtabmap::ProgressState
Definition:
ProgressState.h:35
RecoveryProgressState::callback
virtual bool callback(const std::string &msg) const
Definition:
tools/Recovery/main.cpp:49
ULogger::setType
static void setType(Type type, const std::string &fileName=kDefaultLogFileName, bool append=true)
Definition:
ULogger.cpp:176
RecoveryProgressState
Definition:
tools/Recovery/main.cpp:47
sighandler
void sighandler(int sig)
Definition:
tools/Recovery/main.cpp:59
rtabmap
Definition:
CameraARCore.cpp:35
rtabmap::databaseRecovery
bool RTABMAP_CORE_EXPORT databaseRecovery(const std::string &corruptedDatabase, bool keepCorruptedDatabase=true, std::string *errorMsg=0, ProgressState *progressState=0)
Definition:
Recovery.cpp:39
i
int i
Recovery.h
msg
msg
rtabmap
Author(s): Mathieu Labbe
autogenerated on Thu Jul 25 2024 02:50:12