Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
wolf
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container Registry
Model registry
Operate
Environments
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
mobile_robotics
wolf_projects
wolf_lib
wolf
Commits
84f2cbf8
Commit
84f2cbf8
authored
4 years ago
by
Joan Vallvé Navarro
Browse files
Options
Downloads
Patches
Plain Diff
WIP
parent
6d9c4c2f
No related branches found
No related tags found
1 merge request
!411
Draft: Resolve "SensorBase: extrinsic and intrinsic initialization and prior"
Pipeline
#6374
failed
4 years ago
Changes
3
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
include/core/sensor/sensor_base.h
+82
-2
82 additions, 2 deletions
include/core/sensor/sensor_base.h
include/core/sensor/sensor_diff_drive.h
+1
-1
1 addition, 1 deletion
include/core/sensor/sensor_diff_drive.h
src/sensor/sensor_base.cpp
+65
-0
65 additions, 0 deletions
src/sensor/sensor_base.cpp
with
148 additions
and
3 deletions
include/core/sensor/sensor_base.h
+
82
−
2
View file @
84f2cbf8
...
...
@@ -65,7 +65,13 @@ SensorBasePtr create(const std::string& _unique_name, const Eigen::VectorXd& _ex
} \
struct
ParamsStateBlock
{
Eigen
::
VectorXd
state
;
std
::
string
prior_mode
;
Eigen
::
VectorXd
sigma
;
bool
dynamic
;
};
/** \brief base struct for intrinsic sensor parameters
*
...
...
@@ -74,8 +80,71 @@ SensorBasePtr create(const std::string& _unique_name, const Eigen::VectorXd& _ex
struct
ParamsSensorBase
:
public
ParamsBase
{
std
::
string
prefix
=
"sensor/"
;
int
dim
;
std
::
unordered_map
<
char
,
ParamsStateBlock
>
state_blocks
;
ParamsSensorBase
()
=
default
;
ParamsSensorBase
(
std
::
string
_unique_name
,
const
ParamsServer
&
_server
)
:
ParamsBase
(
_unique_name
,
_server
)
{
dim
=
_server
.
getParam
<
int
>
(
"problem/dimension"
);
if
(
dim
!=
2
and
dim
!=
3
)
{
WOLF_ERROR
(
"ParamsSensorBase: parameter 'problem/dimension' should be 2 or 3. Value provided: "
,
dim
);
throw
std
::
runtime_error
(
"ParamsSensorBase wrong 'problem/dimension'"
);
}
// P
state_blocks
.
emplace
(
'P'
,
ParamsStateBlock
());
if
(
dim
==
2
)
{
state_blocks
[
'P'
].
state
=
_server
.
getParam
<
Eigen
::
Vector2d
>
(
prefix
+
_unique_name
+
"/P/state"
);
state_blocks
[
'P'
].
prior_mode
=
_server
.
getParam
<
std
::
string
>
(
prefix
+
_unique_name
+
"/P/prior_mode"
);
state_blocks
[
'P'
].
dynamic
=
_server
.
getParam
<
bool
>
(
prefix
+
_unique_name
+
"/P/is_dynamic"
);
if
(
state_blocks
[
'P'
].
prior_mode
==
"factor"
)
state_blocks
[
'P'
].
sigma
=
_server
.
getParam
<
Eigen
::
Vector2d
>
(
prefix
+
_unique_name
+
"/P/sigma"
);
}
else
if
(
dim
==
3
)
{
state_blocks
[
'P'
].
state
=
_server
.
getParam
<
Eigen
::
Vector3d
>
(
prefix
+
_unique_name
+
"/P/state"
);
state_blocks
[
'P'
].
prior_mode
=
_server
.
getParam
<
std
::
string
>
(
prefix
+
_unique_name
+
"/P/prior_mode"
);
state_blocks
[
'P'
].
dynamic
=
_server
.
getParam
<
bool
>
(
prefix
+
_unique_name
+
"/P/is_dynamic"
);
if
(
state_blocks
[
'P'
].
prior_mode
==
"factor"
)
state_blocks
[
'P'
].
sigma
=
_server
.
getParam
<
Eigen
::
Vector3d
>
(
prefix
+
_unique_name
+
"/P/sigma"
);
}
// O
state_blocks
.
emplace
(
'O'
,
ParamsStateBlock
());
if
(
dim
==
2
)
{
state_blocks
[
'O'
].
state
=
_server
.
getParam
<
Eigen
::
Vector1d
>
(
prefix
+
_unique_name
+
"/O/state"
);
state_blocks
[
'O'
].
prior_mode
=
_server
.
getParam
<
std
::
string
>
(
prefix
+
_unique_name
+
"/O/prior_mode"
);
state_blocks
[
'O'
].
dynamic
=
_server
.
getParam
<
bool
>
(
prefix
+
_unique_name
+
"/O/is_dynamic"
);
if
(
state_blocks
[
'O'
].
prior_mode
==
"factor"
)
state_blocks
[
'O'
].
sigma
=
_server
.
getParam
<
Eigen
::
Vector1d
>
(
prefix
+
_unique_name
+
"/O/sigma"
);
}
else
if
(
dim
==
3
)
{
state_blocks
[
'O'
].
state
=
_server
.
getParam
<
Eigen
::
Vector4d
>
(
prefix
+
_unique_name
+
"/O/state"
);
state_blocks
[
'O'
].
prior_mode
=
_server
.
getParam
<
std
::
string
>
(
prefix
+
_unique_name
+
"/O/prior_mode"
);
state_blocks
[
'O'
].
dynamic
=
_server
.
getParam
<
bool
>
(
prefix
+
_unique_name
+
"/O/is_dynamic"
);
if
(
state_blocks
[
'O'
].
prior_mode
==
"factor"
)
state_blocks
[
'O'
].
sigma
=
_server
.
getParam
<
Eigen
::
Vector3d
>
(
prefix
+
_unique_name
+
"/O/sigma"
);
}
// I
state_blocks
.
emplace
(
'I'
,
ParamsStateBlock
());
state_blocks
[
'I'
].
state
=
_server
.
getParam
<
Eigen
::
VectorXd
>
(
prefix
+
_unique_name
+
"/I/state"
);
state_blocks
[
'I'
].
prior_mode
=
_server
.
getParam
<
std
::
string
>
(
prefix
+
_unique_name
+
"/I/prior_mode"
);
state_blocks
[
'I'
].
dynamic
=
_server
.
getParam
<
bool
>
(
prefix
+
_unique_name
+
"/I/is_dynamic"
);
if
(
state_blocks
[
'I'
].
prior_mode
==
"factor"
)
state_blocks
[
'I'
].
sigma
=
_server
.
getParam
<
Eigen
::
VectorXd
>
(
prefix
+
_unique_name
+
"/I/sigma"
);
}
~
ParamsSensorBase
()
override
=
default
;
using
ParamsBase
::
ParamsBase
;
std
::
string
print
()
const
override
{
return
""
;
...
...
@@ -108,6 +177,17 @@ class SensorBase : public NodeBase, public HasStateBlocks, public std::enable_sh
void
setProblem
(
ProblemPtr
_problem
)
override
final
;
public:
/** \brief Constructor with params struct
*
* Constructor with parameter struct
* \param _tp Type of the sensor (types defined at wolf.h)
* \param _params ParamsSensorBasePtr pointer to params struct
*
**/
SensorBase
(
const
std
::
string
&
_type
,
ParamsSensorBasePtr
_params
,
const
int
&
_intrinsics_size
);
/** \brief Constructor with noise size
*
* Constructor with parameter vector
...
...
This diff is collapsed.
Click to expand it.
include/core/sensor/sensor_diff_drive.h
+
1
−
1
View file @
84f2cbf8
...
...
@@ -26,7 +26,7 @@ struct ParamsSensorDiffDrive : public ParamsSensorBase
double
ticks_cov_factor
;
ParamsSensorDiffDrive
()
=
default
;
ParamsSensorDiffDrive
(
std
::
string
_unique_name
,
const
wolf
::
ParamsServer
&
_server
)
ParamsSensorDiffDrive
(
std
::
string
_unique_name
,
const
ParamsServer
&
_server
)
:
ParamsSensorBase
(
_unique_name
,
_server
)
{
radius_left
=
_server
.
getParam
<
double
>
(
prefix
+
_unique_name
+
"/radius_left"
);
...
...
This diff is collapsed.
Click to expand it.
src/sensor/sensor_base.cpp
+
65
−
0
View file @
84f2cbf8
...
...
@@ -9,6 +9,71 @@ namespace wolf {
unsigned
int
SensorBase
::
sensor_id_count_
=
0
;
SensorBase
::
SensorBase
(
const
std
::
string
&
_type
,
ParamsSensorBasePtr
_params
,
const
int
&
_intrinsics_size
)
:
NodeBase
(
"SENSOR"
,
_type
),
HasStateBlocks
(
""
),
hardware_ptr_
(),
sensor_id_
(
++
sensor_id_count_
),
// simple ID factory
last_capture_
(
nullptr
)
{
for
(
auto
sb_pair
:
_params
->
state_blocks
)
{
const
char
&
key
=
sb_pair
.
first
;
const
ParamsStateBlock
&
sb_param
=
sb_pair
.
second
;
if
(
key
==
'I'
and
_intrinsics_size
==
0
)
continue
;
addStateBlock
(
key
,
(
key
!=
'O'
?
std
::
make_shared
<
StateBlock
>
(
sb_param
.
state
,
sb_param
.
prior_mode
==
"fix"
)
:
(
_params
->
dim
==
2
?
std
::
static_pointer_cast
<
StateBlock
>
(
std
::
make_shared
<
StateAngle
>
(
sb_param
.
state
,
sb_param
.
prior_mode
==
"fix"
))
:
std
::
static_pointer_cast
<
StateBlock
>
(
std
::
make_shared
<
StateQuaternion
>
(
sb_param
.
state
,
sb_param
.
prior_mode
==
"fix"
))
)
),
sb_param
.
dynamic
);
if
(
sb_param
.
prior_mode
==
"factor"
)
addPriorParameter
(
key
,
sb_param
.
state
,
sb_param
.
sigma
.
asDiagonal
());
}
/*// P
addStateBlock('P',
std::make_shared<StateBlock>(_params->state_blocks.at('P').state,
_params->state_blocks.at('P').prior_mode == "fix"),
_params->state_blocks.at('P').dynamic);
if (_params->state_blocks.at('P').prior_mode == "factor")
addPriorP(_params->state_blocks.at('P').state, _params->state_blocks.at('P').sigma.asDiagonal());
// O
addStateBlock('O',
(_params->dim == 2 ?
std::make_shared<StateAngle>(_params->state_blocks.at('O').state,
_params->state_blocks.at('O').prior_mode == "fix") :
std::make_shared<StateQuaternion>(_params->state_blocks.at('O').state,
_params->state_blocks.at('O').prior_mode == "fix") ),
_params->o_dynamic);
if (_params->state_blocks.at('O').prior_mode == "factor")
addPriorO(_params->p_state, _params->p_cov);
// I
if (_intrinsics_size != 0)
{
addStateBlock('I',
std::make_shared<StateBlock>(_params->state_blocks.at('I').state,
_params->state_blocks.at('I').prior_mode == "fix"),
_params->state_blocks.at('I').dynamic);
if (_params->state_blocks.at('I').prior_mode == "factor")
addPriorI(_params->state_blocks.at('I').state, _params->state_blocks.at('I').sigma.asDiagonal());
}*/
}
SensorBase
::
SensorBase
(
const
std
::
string
&
_type
,
StateBlockPtr
_p_ptr
,
StateBlockPtr
_o_ptr
,
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment