Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
I
iri_imu_msg_fix
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
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
labrobotica
ros
sensors
imu
iri_imu_msg_fix
Commits
794377e3
Commit
794377e3
authored
4 years ago
by
Sergi Hernandez
Browse files
Options
Downloads
Patches
Plain Diff
Added the conversion from NED to ENU.
parent
3c71cf94
No related branches found
Branches containing commit
No related tags found
Tags containing commit
1 merge request
!1
Added the conversion from NED to ENU.
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
cfg/ImuMsgFix.cfg
+13
-5
13 additions, 5 deletions
cfg/ImuMsgFix.cfg
include/imu_msg_fix_alg_node.h
+0
-5
0 additions, 5 deletions
include/imu_msg_fix_alg_node.h
launch/node.launch
+2
-1
2 additions, 1 deletion
launch/node.launch
src/imu_msg_fix_alg_node.cpp
+75
-20
75 additions, 20 deletions
src/imu_msg_fix_alg_node.cpp
with
90 additions
and
31 deletions
cfg/ImuMsgFix.cfg
+
13
−
5
View file @
794377e3
...
@@ -37,12 +37,20 @@ from dynamic_reconfigure.parameter_generator_catkin import *
...
@@ -37,12 +37,20 @@ from dynamic_reconfigure.parameter_generator_catkin import *
gen
= ParameterGenerator()
gen
= ParameterGenerator()
enum_imu_reference
= gen.enum([
gen.const("NED",
int_t, 0, "North East Down"),
gen.const("ENU",
int_t, 1, "East North Up"),
],
"Possible reference systems for the IMU.")
# Name
Type Reconfiguration level Description Default Min Max
# Name
Type Reconfiguration level Description Default Min Max
#gen.add("velocity_scale_factor",
double_t, 0, "Maximum velocity scale factor", 0.5, 0.0, 1.0)
#gen.add("velocity_scale_factor",
double_t, 0, "Maximum velocity scale factor", 0.5, 0.0, 1.0)
gen.add("frame_id",
str_t, 0, "frame_id name to override msg with", "")
gen.add("fix_frame_id",
bool_t, 0, "enable frame_id fix", False)
gen.add("fix_cov",
bool_t, 0, "enable covariance fix", False)
gen.add("frame_id",
str_t, 0, "frame_id name to override msg with", "")
gen.add("cov_orientation",
double_t, 0, "orientation covariance value to be set", 0.01, 0.0, 100.0)
gen.add("fix_cov",
bool_t, 0, "enable covariance fix", False)
gen.add("cov_vel",
double_t, 0, "velocity covariance value to be set", 0.000001, 0.0, 100.0)
gen.add("cov_orientation",
double_t, 0, "orientation covariance value to be set", 0.01, 0.0, 100.0)
gen.add("cov_acc",
double_t, 0, "acceleration covariance value to be set", 0.000001, 0.0, 100.0)
gen.add("cov_vel",
double_t, 0, "velocity covariance value to be set", 0.000001, 0.0, 100.0)
gen.add("cov_acc",
double_t, 0, "acceleration covariance value to be set", 0.000001, 0.0, 100.0)
gen.add("imu_reference",
int_t, 0, "IMU reference system", 0, 0, 1, edit_method=enum_imu_reference)
exit(gen.generate(PACKAGE,
"ImuMsgFixAlgorithm", "ImuMsgFix"))
exit(gen.generate(PACKAGE,
"ImuMsgFixAlgorithm", "ImuMsgFix"))
This diff is collapsed.
Click to expand it.
include/imu_msg_fix_alg_node.h
+
0
−
5
View file @
794377e3
...
@@ -44,13 +44,9 @@ class ImuMsgFixAlgNode : public algorithm_base::IriBaseAlgorithm<ImuMsgFixAlgori
...
@@ -44,13 +44,9 @@ class ImuMsgFixAlgNode : public algorithm_base::IriBaseAlgorithm<ImuMsgFixAlgori
{
{
private:
private:
// [publisher attributes]
// [publisher attributes]
ros
::
Publisher
pose_publisher_
;
geometry_msgs
::
PoseStamped
pose_PoseStamped_msg_
;
ros
::
Publisher
imu_out_publisher_
;
ros
::
Publisher
imu_out_publisher_
;
sensor_msgs
::
Imu
imu_out_Imu_msg_
;
sensor_msgs
::
Imu
imu_out_Imu_msg_
;
// [subscriber attributes]
// [subscriber attributes]
ros
::
Subscriber
imu_in_subscriber_
;
ros
::
Subscriber
imu_in_subscriber_
;
void
imu_in_callback
(
const
sensor_msgs
::
Imu
::
ConstPtr
&
msg
);
void
imu_in_callback
(
const
sensor_msgs
::
Imu
::
ConstPtr
&
msg
);
...
@@ -58,7 +54,6 @@ class ImuMsgFixAlgNode : public algorithm_base::IriBaseAlgorithm<ImuMsgFixAlgori
...
@@ -58,7 +54,6 @@ class ImuMsgFixAlgNode : public algorithm_base::IriBaseAlgorithm<ImuMsgFixAlgori
void
imu_in_mutex_enter
(
void
);
void
imu_in_mutex_enter
(
void
);
void
imu_in_mutex_exit
(
void
);
void
imu_in_mutex_exit
(
void
);
// [service attributes]
// [service attributes]
// [client attributes]
// [client attributes]
...
...
This diff is collapsed.
Click to expand it.
launch/node.launch
+
2
−
1
View file @
794377e3
...
@@ -6,5 +6,6 @@
...
@@ -6,5 +6,6 @@
<node pkg="imu_msg_fix" name="imu_msg_fix" type="imu_msg_fix" output="screen">
<node pkg="imu_msg_fix" name="imu_msg_fix" type="imu_msg_fix" output="screen">
<remap from="~imu_in" to="$(arg imu_in)"/>
<remap from="~imu_in" to="$(arg imu_in)"/>
<remap from="~imu_out" to="$(arg imu_out)"/>
<remap from="~imu_out" to="$(arg imu_out)"/>
</node>
</node>
</launch>
</launch>
\ No newline at end of file
This diff is collapsed.
Click to expand it.
src/imu_msg_fix_alg_node.cpp
+
75
−
20
View file @
794377e3
...
@@ -7,13 +7,11 @@ ImuMsgFixAlgNode::ImuMsgFixAlgNode(void) :
...
@@ -7,13 +7,11 @@ ImuMsgFixAlgNode::ImuMsgFixAlgNode(void) :
//this->loop_rate_ = 2;//in [Hz]
//this->loop_rate_ = 2;//in [Hz]
// [init publishers]
// [init publishers]
this
->
pose_publisher_
=
this
->
public_node_handle_
.
advertise
<
geometry_msgs
::
PoseStamped
>
(
"pose"
,
1
);
this
->
imu_out_publisher_
=
this
->
public_node_handle_
.
advertise
<
sensor_msgs
::
Imu
>
(
"imu_out"
,
1
);
this
->
imu_out_publisher_
=
this
->
public_node_handle_
.
advertise
<
sensor_msgs
::
Imu
>
(
"imu_out"
,
1
);
// [init subscribers]
// [init subscribers]
this
->
imu_in_subscriber_
=
this
->
public_node_handle_
.
subscribe
(
"imu_in"
,
1
,
&
ImuMsgFixAlgNode
::
imu_in_callback
,
this
);
this
->
imu_in_subscriber_
=
this
->
public_node_handle_
.
subscribe
(
"imu_in"
,
1
,
&
ImuMsgFixAlgNode
::
imu_in_callback
,
this
);
pthread_mutex_init
(
&
this
->
imu_in_mutex_
,
NULL
);
pthread_mutex_init
(
&
this
->
imu_in_mutex_
,
NULL
);
// [init services]
// [init services]
...
@@ -61,37 +59,94 @@ void ImuMsgFixAlgNode::imu_in_callback(const sensor_msgs::Imu::ConstPtr& msg)
...
@@ -61,37 +59,94 @@ void ImuMsgFixAlgNode::imu_in_callback(const sensor_msgs::Imu::ConstPtr& msg)
//use appropiate mutex to shared variables if necessary
//use appropiate mutex to shared variables if necessary
//this->alg_.lock();
//this->alg_.lock();
//this->imu_in_mutex_enter();
//this->imu_in_mutex_enter();
this
->
imu_out_Imu_msg_
=
*
msg
;
std
::
string
frame
;
std
::
string
frame
;
if
(
this
->
config_
.
frame_id
.
size
()
!=
0
)
if
(
this
->
config_
.
fix_frame_id
)
{
frame
=
this
->
config_
.
frame_id
;
frame
=
this
->
config_
.
frame_id
;
}
else
else
{
{
frame
=
this
->
imu_out_Imu_msg_
.
header
.
frame_id
;
frame
=
msg
->
header
.
frame_id
;
//if(!strncmp(frame, "/", strlen("/")))
if
(
frame
[
0
]
==
'/'
)
if
(
frame
[
0
]
==
'/'
)
frame
.
erase
(
0
,
1
);
frame
.
erase
(
0
,
1
);
}
}
if
(
this
->
config_
.
fix_cov
)
if
(
this
->
config_
.
imu_reference
==
1
)
{
{
this
->
imu_out_Imu_msg_
.
orientation_covariance
[
0
]
=
this
->
config_
.
cov_orientation
;
if
(
this
->
config_
.
fix_cov
)
this
->
imu_out_Imu_msg_
.
orientation_covariance
[
4
]
=
this
->
config_
.
cov_orientation
;
{
this
->
imu_out_Imu_msg_
.
orientation_covariance
[
8
]
=
this
->
config_
.
cov_orientation
;
this
->
imu_out_Imu_msg_
.
orientation_covariance
[
0
]
=
this
->
config_
.
cov_orientation
;
this
->
imu_out_Imu_msg_
.
orientation_covariance
[
4
]
=
this
->
config_
.
cov_orientation
;
this
->
imu_out_Imu_msg_
.
orientation_covariance
[
8
]
=
this
->
config_
.
cov_orientation
;
this
->
imu_out_Imu_msg_
.
angular_velocity_covariance
[
0
]
=
this
->
config_
.
cov_vel
;
this
->
imu_out_Imu_msg_
.
angular_velocity_covariance
[
0
]
=
this
->
config_
.
cov_vel
;
this
->
imu_out_Imu_msg_
.
angular_velocity_covariance
[
4
]
=
this
->
config_
.
cov_vel
;
this
->
imu_out_Imu_msg_
.
angular_velocity_covariance
[
4
]
=
this
->
config_
.
cov_vel
;
this
->
imu_out_Imu_msg_
.
angular_velocity_covariance
[
8
]
=
this
->
config_
.
cov_vel
;
this
->
imu_out_Imu_msg_
.
angular_velocity_covariance
[
8
]
=
this
->
config_
.
cov_vel
;
this
->
imu_out_Imu_msg_
.
linear_acceleration_covariance
[
0
]
=
this
->
config_
.
cov_acc
;
this
->
imu_out_Imu_msg_
.
linear_acceleration_covariance
[
0
]
=
this
->
config_
.
cov_acc
;
this
->
imu_out_Imu_msg_
.
linear_acceleration_covariance
[
4
]
=
this
->
config_
.
cov_acc
;
this
->
imu_out_Imu_msg_
.
linear_acceleration_covariance
[
4
]
=
this
->
config_
.
cov_acc
;
this
->
imu_out_Imu_msg_
.
linear_acceleration_covariance
[
8
]
=
this
->
config_
.
cov_acc
;
this
->
imu_out_Imu_msg_
.
linear_acceleration_covariance
[
8
]
=
this
->
config_
.
cov_acc
;
}
else
{
this
->
imu_out_Imu_msg_
.
orientation_covariance
[
0
]
=
msg
->
orientation_covariance
[
4
];
this
->
imu_out_Imu_msg_
.
orientation_covariance
[
1
]
=
msg
->
orientation_covariance
[
3
];
this
->
imu_out_Imu_msg_
.
orientation_covariance
[
4
]
=
msg
->
orientation_covariance
[
0
];
this
->
imu_out_Imu_msg_
.
orientation_covariance
[
3
]
=
msg
->
orientation_covariance
[
1
];
this
->
imu_out_Imu_msg_
.
orientation_covariance
[
8
]
=
msg
->
orientation_covariance
[
8
];
this
->
imu_out_Imu_msg_
.
angular_velocity_covariance
[
0
]
=
msg
->
angular_velocity_covariance
[
4
];
this
->
imu_out_Imu_msg_
.
angular_velocity_covariance
[
1
]
=
msg
->
angular_velocity_covariance
[
3
];
this
->
imu_out_Imu_msg_
.
angular_velocity_covariance
[
4
]
=
msg
->
angular_velocity_covariance
[
0
];
this
->
imu_out_Imu_msg_
.
angular_velocity_covariance
[
3
]
=
msg
->
angular_velocity_covariance
[
1
];
this
->
imu_out_Imu_msg_
.
angular_velocity_covariance
[
8
]
=
msg
->
angular_velocity_covariance
[
8
];
this
->
imu_out_Imu_msg_
.
linear_acceleration_covariance
[
0
]
=
msg
->
linear_acceleration_covariance
[
4
];
this
->
imu_out_Imu_msg_
.
linear_acceleration_covariance
[
1
]
=
msg
->
linear_acceleration_covariance
[
3
];
this
->
imu_out_Imu_msg_
.
linear_acceleration_covariance
[
4
]
=
msg
->
linear_acceleration_covariance
[
0
];
this
->
imu_out_Imu_msg_
.
linear_acceleration_covariance
[
3
]
=
msg
->
linear_acceleration_covariance
[
1
];
this
->
imu_out_Imu_msg_
.
linear_acceleration_covariance
[
8
]
=
msg
->
linear_acceleration_covariance
[
8
];
}
this
->
imu_out_Imu_msg_
.
orientation
.
x
=
msg
->
orientation
.
y
;
this
->
imu_out_Imu_msg_
.
orientation
.
y
=
msg
->
orientation
.
x
;
this
->
imu_out_Imu_msg_
.
orientation
.
z
=-
msg
->
orientation
.
z
;
this
->
imu_out_Imu_msg_
.
orientation
.
w
=-
msg
->
orientation
.
w
;
this
->
imu_out_Imu_msg_
.
angular_velocity
.
x
=
msg
->
angular_velocity
.
y
;
this
->
imu_out_Imu_msg_
.
angular_velocity
.
y
=
msg
->
angular_velocity
.
x
;
this
->
imu_out_Imu_msg_
.
angular_velocity
.
z
=-
msg
->
angular_velocity
.
z
;
this
->
imu_out_Imu_msg_
.
linear_acceleration
.
x
=
msg
->
linear_acceleration
.
y
;
this
->
imu_out_Imu_msg_
.
linear_acceleration
.
y
=
msg
->
linear_acceleration
.
x
;
this
->
imu_out_Imu_msg_
.
linear_acceleration
.
z
=-
msg
->
linear_acceleration
.
z
;
}
}
else
{
if
(
this
->
config_
.
fix_cov
)
{
this
->
imu_out_Imu_msg_
.
orientation_covariance
[
0
]
=
this
->
config_
.
cov_orientation
;
this
->
imu_out_Imu_msg_
.
orientation_covariance
[
4
]
=
this
->
config_
.
cov_orientation
;
this
->
imu_out_Imu_msg_
.
orientation_covariance
[
8
]
=
this
->
config_
.
cov_orientation
;
this
->
imu_out_Imu_msg_
.
angular_velocity_covariance
[
0
]
=
this
->
config_
.
cov_vel
;
this
->
imu_out_Imu_msg_
.
angular_velocity_covariance
[
4
]
=
this
->
config_
.
cov_vel
;
this
->
imu_out_Imu_msg_
.
angular_velocity_covariance
[
8
]
=
this
->
config_
.
cov_vel
;
this
->
imu_out_Imu_msg_
.
linear_acceleration_covariance
[
0
]
=
this
->
config_
.
cov_acc
;
this
->
imu_out_Imu_msg_
.
linear_acceleration_covariance
[
4
]
=
this
->
config_
.
cov_acc
;
this
->
imu_out_Imu_msg_
.
linear_acceleration_covariance
[
8
]
=
this
->
config_
.
cov_acc
;
}
else
{
this
->
imu_out_Imu_msg_
.
orientation_covariance
=
msg
->
orientation_covariance
;
this
->
imu_out_Imu_msg_
.
angular_velocity_covariance
=
msg
->
angular_velocity_covariance
;
this
->
imu_out_Imu_msg_
.
linear_acceleration_covariance
=
msg
->
linear_acceleration_covariance
;
}
this
->
imu_out_Imu_msg_
.
orientation
=
msg
->
orientation
;
this
->
imu_out_Imu_msg_
.
angular_velocity
=
msg
->
angular_velocity
;
this
->
imu_out_Imu_msg_
.
linear_acceleration
=
msg
->
linear_acceleration
;
}
this
->
imu_out_Imu_msg_
.
header
.
frame_id
=
frame
;
this
->
imu_out_Imu_msg_
.
header
.
frame_id
=
frame
;
this
->
imu_out_Imu_msg_
.
header
.
stamp
=
msg
->
header
.
stamp
;
this
->
imu_out_publisher_
.
publish
(
this
->
imu_out_Imu_msg_
);
this
->
imu_out_publisher_
.
publish
(
this
->
imu_out_Imu_msg_
);
// this->pose_PoseStamped_msg_.header = msg->header;
// this->pose_PoseStamped_msg_.header = msg->header;
...
...
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