Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
W
wolf_ros_imu
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Deploy
Releases
Model registry
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor 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_ros
wolf_ros_imu
Commits
3edab92c
Commit
3edab92c
authored
4 years ago
by
Idril-Tadzio Geer Cousté
Browse files
Options
Downloads
Patches
Plain Diff
fixed publising of bias
parent
bf9cebfb
No related branches found
No related tags found
2 merge requests
!5
After cmake and const refactor
,
!3
new release
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/subscriber_imu.cpp
+34
-7
34 additions, 7 deletions
src/subscriber_imu.cpp
with
34 additions
and
7 deletions
src/subscriber_imu.cpp
+
34
−
7
View file @
3edab92c
...
@@ -38,6 +38,9 @@ SubscriberImu::SubscriberImu(const std::string& _unique_name,
...
@@ -38,6 +38,9 @@ SubscriberImu::SubscriberImu(const std::string& _unique_name,
imu_x_neg_
=
imu_x_axis
<
0
;
imu_x_neg_
=
imu_x_axis
<
0
;
imu_y_neg_
=
imu_y_axis
<
0
;
imu_y_neg_
=
imu_y_axis
<
0
;
imu_z_neg_
=
imu_z_axis
<
0
;
imu_z_neg_
=
imu_z_axis
<
0
;
//WOLF_INFO("SubscriberImu: parameters: imu_x_axis = ", imu_x_axis, " imu_y_axis = ", imu_y_axis, " imu_z_axis = ", imu_z_axis);
//WOLF_INFO("SubscriberImu: parameters: imu_x_axis_ = ", imu_x_axis_, " imu_y_axis_ = ", imu_y_axis_, " imu_z_axis_ = ", imu_z_axis_);
//WOLF_INFO("SubscriberImu: parameters: imu_x_neg_ = ", imu_x_neg_, " imu_y_neg_ = ", imu_y_neg_, " imu_z_neg_ = ", imu_z_neg_);
}
}
catch
(...)
catch
(...)
{
{
...
@@ -88,10 +91,10 @@ void SubscriberImu::callback(const sensor_msgs::Imu::ConstPtr& msg)
...
@@ -88,10 +91,10 @@ void SubscriberImu::callback(const sensor_msgs::Imu::ConstPtr& msg)
data
(
imu_y_axis_
+
3
)
=
(
imu_y_neg_
?
-
msg
->
angular_velocity
.
y
:
msg
->
angular_velocity
.
y
)
*
(
in_degrees_
?
M_PI
/
180.0
:
1.0
);
data
(
imu_y_axis_
+
3
)
=
(
imu_y_neg_
?
-
msg
->
angular_velocity
.
y
:
msg
->
angular_velocity
.
y
)
*
(
in_degrees_
?
M_PI
/
180.0
:
1.0
);
data
(
imu_z_axis_
+
3
)
=
(
imu_z_neg_
?
-
msg
->
angular_velocity
.
z
:
msg
->
angular_velocity
.
z
)
*
(
in_degrees_
?
M_PI
/
180.0
:
1.0
);
data
(
imu_z_axis_
+
3
)
=
(
imu_z_neg_
?
-
msg
->
angular_velocity
.
z
:
msg
->
angular_velocity
.
z
)
*
(
in_degrees_
?
M_PI
/
180.0
:
1.0
);
WOLF_
DEBUG
(
"imu_x_axis_ = "
,
imu_x_neg_
?
-
(
imu_x_axis_
+
1
)
:
(
imu_x_axis_
+
1
));
//
WOLF_
INFO
("imu_x_axis_ = ", imu_x_neg_ ? -(imu_x_axis_+1) : (imu_x_axis_+1));
WOLF_
DEBUG
(
"imu_y_axis_ = "
,
imu_y_neg_
?
-
(
imu_y_axis_
+
1
)
:
(
imu_y_axis_
+
1
));
//
WOLF_
INFO
("imu_y_axis_ = ", imu_y_neg_ ? -(imu_y_axis_+1) : (imu_y_axis_+1));
WOLF_
DEBUG
(
"imu_z_axis_ = "
,
imu_z_neg_
?
-
(
imu_z_axis_
+
1
)
:
(
imu_z_axis_
+
1
));
//
WOLF_
INFO
("imu_z_axis_ = ", imu_z_neg_ ? -(imu_z_axis_+1) : (imu_z_axis_+1));
WOLF_
DEBUG
(
"data = "
,
data
.
transpose
());
//
WOLF_
INFO
("data = ", data.transpose());
Eigen
::
Matrix6d
cov
(
Eigen
::
Matrix6d
::
Zero
());
Eigen
::
Matrix6d
cov
(
Eigen
::
Matrix6d
::
Zero
());
if
(
cov_source_
==
"msg"
)
if
(
cov_source_
==
"msg"
)
...
@@ -108,9 +111,18 @@ void SubscriberImu::callback(const sensor_msgs::Imu::ConstPtr& msg)
...
@@ -108,9 +111,18 @@ void SubscriberImu::callback(const sensor_msgs::Imu::ConstPtr& msg)
cov
.
topLeftCorner
<
3
,
3
>
().
isApprox
(
Eigen
::
Matrix3d
::
Zero
(),
1e-9
)
or
cov
.
topLeftCorner
<
3
,
3
>
().
isApprox
(
Eigen
::
Matrix3d
::
Zero
(),
1e-9
)
or
cov
.
bottomRightCorner
<
3
,
3
>
().
isApprox
(
Eigen
::
Matrix3d
::
Zero
(),
1e-9
))
cov
.
bottomRightCorner
<
3
,
3
>
().
isApprox
(
Eigen
::
Matrix3d
::
Zero
(),
1e-9
))
{
{
cov
=
sensor_ptr_
->
getNoiseCov
();
if
(
sensor_ptr_
->
getProblem
()
->
getDim
()
==
3
)
{
cov
=
sensor_ptr_
->
getNoiseCov
();
}
else
{
cov
.
topLeftCorner
<
2
,
2
>
()
=
sensor_ptr_
->
getNoiseCov
().
topLeftCorner
<
2
,
2
>
();
cov
.
topRightCorner
<
2
,
1
>
()
=
sensor_ptr_
->
getNoiseCov
().
topRightCorner
<
2
,
1
>
();
cov
.
bottomLeftCorner
<
1
,
2
>
()
=
sensor_ptr_
->
getNoiseCov
().
bottomLeftCorner
<
1
,
2
>
();
cov
(
5
,
5
)
=
sensor_ptr_
->
getNoiseCov
()(
2
,
2
);
}
}
}
// Create capture and process
// Create capture and process
auto
capture
=
std
::
make_shared
<
CaptureImu
>
(
TimeStamp
(
msg
->
header
.
stamp
.
sec
,
msg
->
header
.
stamp
.
nsec
),
auto
capture
=
std
::
make_shared
<
CaptureImu
>
(
TimeStamp
(
msg
->
header
.
stamp
.
sec
,
msg
->
header
.
stamp
.
nsec
),
sensor_ptr_
,
sensor_ptr_
,
...
@@ -189,7 +201,22 @@ void SubscriberImu::callback(const sensor_msgs::Imu::ConstPtr& msg)
...
@@ -189,7 +201,22 @@ void SubscriberImu::callback(const sensor_msgs::Imu::ConstPtr& msg)
pub_imu_corrected_
.
publish
(
imu_corrected
);
pub_imu_corrected_
.
publish
(
imu_corrected
);
}
}
WOLF_WARN_COND
(
sensor_ptr_
->
getProblem
()
->
getDim
()
==
2
,
"SubscriberImu: Corrected IMU not implemented in 2D"
);
else
{
// fill and publish
sensor_msgs
::
Imu
imu_corrected
=
*
msg
;
imu_corrected
.
linear_acceleration
.
x
=
data
(
0
)
-
bias
(
0
);
imu_corrected
.
linear_acceleration
.
y
=
data
(
1
)
-
bias
(
1
);
imu_corrected
.
linear_acceleration
.
z
=
data
(
2
);
imu_corrected
.
angular_velocity
.
x
=
data
(
3
);
imu_corrected
.
angular_velocity
.
y
=
data
(
4
);
imu_corrected
.
angular_velocity
.
z
=
data
(
5
)
-
bias
(
5
);
pub_imu_corrected_
.
publish
(
imu_corrected
);
}
}
}
// Publish IMU message with axis remapping
// Publish IMU message with axis remapping
if
(
pub_imu_remapped_
.
getNumSubscribers
()
!=
0
)
if
(
pub_imu_remapped_
.
getNumSubscribers
()
!=
0
)
...
...
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