Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
W
wolf_ros_node
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_node
Commits
d31db361
Commit
d31db361
authored
5 years ago
by
Joan Vallvé Navarro
Browse files
Options
Downloads
Patches
Plain Diff
pose publisher trajectory marker and/or pose array
parent
beb7c7f0
No related branches found
No related tags found
2 merge requests
!11
new release
,
!10
new release
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
include/publisher_pose.h
+16
-1
16 additions, 1 deletion
include/publisher_pose.h
src/publisher_pose.cpp
+66
-20
66 additions, 20 deletions
src/publisher_pose.cpp
with
82 additions
and
21 deletions
include/publisher_pose.h
+
16
−
1
View file @
d31db361
...
@@ -8,12 +8,25 @@
...
@@ -8,12 +8,25 @@
#include
"publisher.h"
#include
"publisher.h"
/**************************
* ROS includes *
**************************/
#include
<ros/ros.h>
#include
<geometry_msgs/PoseArray.h>
#include
<visualization_msgs/Marker.h>
namespace
wolf
namespace
wolf
{
{
class
PublisherPose
:
public
Publisher
class
PublisherPose
:
public
Publisher
{
{
std
::
string
map_frame_id_
;
bool
pose_array_
,
marker_
;
geometry_msgs
::
PoseArray
pose_array_msg_
;
visualization_msgs
::
Marker
marker_msg_
;
std_msgs
::
ColorRGBA
marker_color_
;
ros
::
Publisher
pub_pose_array_
,
pub_marker_
;
public:
public:
PublisherPose
(
const
std
::
string
&
_unique_name
,
PublisherPose
(
const
std
::
string
&
_unique_name
,
...
@@ -26,6 +39,8 @@ class PublisherPose: public Publisher
...
@@ -26,6 +39,8 @@ class PublisherPose: public Publisher
void
initialize
(
ros
::
NodeHandle
&
nh
,
const
std
::
string
&
topic
)
override
;
void
initialize
(
ros
::
NodeHandle
&
nh
,
const
std
::
string
&
topic
)
override
;
void
publishDerived
()
override
;
void
publishDerived
()
override
;
void
publishPose
(
const
geometry_msgs
::
Pose
pose
,
const
ros
::
Time
&
stamp
);
};
};
WOLF_REGISTER_PUBLISHER
(
PublisherPose
)
WOLF_REGISTER_PUBLISHER
(
PublisherPose
)
...
...
This diff is collapsed.
Click to expand it.
src/publisher_pose.cpp
+
66
−
20
View file @
d31db361
...
@@ -5,7 +5,6 @@
...
@@ -5,7 +5,6 @@
**************************/
**************************/
#include
<ros/ros.h>
#include
<ros/ros.h>
#include
"tf/transform_datatypes.h"
#include
"tf/transform_datatypes.h"
#include
<nav_msgs/Odometry.h>
namespace
wolf
namespace
wolf
{
{
...
@@ -15,12 +14,42 @@ PublisherPose::PublisherPose(const std::string& _unique_name,
...
@@ -15,12 +14,42 @@ PublisherPose::PublisherPose(const std::string& _unique_name,
const
ProblemPtr
_problem
)
:
const
ProblemPtr
_problem
)
:
Publisher
(
_unique_name
,
_server
,
_problem
)
Publisher
(
_unique_name
,
_server
,
_problem
)
{
{
pose_array_
=
_server
.
getParam
<
bool
>
(
prefix_
+
"/pose_array_msg"
);
marker_
=
_server
.
getParam
<
bool
>
(
prefix_
+
"/marker_msg"
);
if
(
marker_
)
{
Eigen
::
Vector4d
col
=
_server
.
getParam
<
Eigen
::
Vector4d
>
(
prefix_
+
"/marker_color"
);
marker_color_
.
r
=
col
(
0
);
marker_color_
.
g
=
col
(
1
);
marker_color_
.
b
=
col
(
2
);
marker_color_
.
a
=
col
(
3
);
}
}
}
void
PublisherPose
::
initialize
(
ros
::
NodeHandle
&
nh
,
const
std
::
string
&
topic
)
void
PublisherPose
::
initialize
(
ros
::
NodeHandle
&
nh
,
const
std
::
string
&
topic
)
{
{
publisher_
=
nh
.
advertise
<
nav_msgs
::
Odometry
>
(
topic
,
1
);
std
::
string
map_frame_id
;
nh
.
param
<
std
::
string
>
(
"map_frame_id"
,
map_frame_id_
,
"map"
);
nh
.
param
<
std
::
string
>
(
"map_frame_id"
,
map_frame_id
,
"map"
);
// initialize msg and publisher
if
(
pose_array_
)
{
pose_array_msg_
.
header
.
frame_id
=
map_frame_id
;
pub_pose_array_
=
nh
.
advertise
<
geometry_msgs
::
PoseArray
>
(
topic
+
"_pose_array"
,
1
);
}
if
(
marker_
)
{
marker_msg_
.
header
.
frame_id
=
map_frame_id
;
marker_msg_
.
type
=
visualization_msgs
::
Marker
::
LINE_STRIP
;
marker_msg_
.
action
=
visualization_msgs
::
Marker
::
ADD
;
marker_msg_
.
ns
=
"trajectory"
;
marker_msg_
.
scale
.
x
=
0.1
;
marker_msg_
.
color
=
marker_color_
;
marker_msg_
.
pose
.
orientation
=
tf
::
createQuaternionMsgFromYaw
(
0
);
pub_marker_
=
nh
.
advertise
<
visualization_msgs
::
Marker
>
(
topic
+
"_marker"
,
1
);
}
}
}
void
PublisherPose
::
publishDerived
()
void
PublisherPose
::
publishDerived
()
...
@@ -36,34 +65,51 @@ void PublisherPose::publishDerived()
...
@@ -36,34 +65,51 @@ void PublisherPose::publishDerived()
return
;
return
;
}
}
// Fill PoseStamped msg
// Fill Pose msg
nav_msgs
::
Odometry
msg
;
geometry_msgs
::
Pose
pose_msg
;
msg
.
header
.
frame_id
=
map_frame_id_
;
msg
.
header
.
stamp
=
ros
::
Time
(
loc_ts
.
getSeconds
(),
loc_ts
.
getNanoSeconds
());
// 2D
// 2D
if
(
problem_
->
getDim
()
==
2
)
if
(
problem_
->
getDim
()
==
2
)
{
{
msg
.
pose
.
pose
.
position
.
x
=
current_state
[
'P'
](
0
);
pose
_msg
.
position
.
x
=
current_state
[
'P'
](
0
);
msg
.
pose
.
pose
.
position
.
y
=
current_state
[
'P'
](
1
);
pose
_msg
.
position
.
y
=
current_state
[
'P'
](
1
);
msg
.
pose
.
pose
.
position
.
z
=
0
;
pose
_msg
.
position
.
z
=
0
;
msg
.
pose
.
pose
.
orientation
=
tf
::
createQuaternionMsgFromYaw
(
current_state
[
'O'
](
0
));
pose
_msg
.
orientation
=
tf
::
createQuaternionMsgFromYaw
(
current_state
[
'O'
](
0
));
}
}
// 3D
// 3D
else
else
{
{
msg
.
pose
.
pose
.
position
.
x
=
current_state
[
'P'
](
0
);
pose
_msg
.
position
.
x
=
current_state
[
'P'
](
0
);
msg
.
pose
.
pose
.
position
.
y
=
current_state
[
'P'
](
1
);
pose
_msg
.
position
.
y
=
current_state
[
'P'
](
1
);
msg
.
pose
.
pose
.
position
.
z
=
current_state
[
'P'
](
2
);
pose
_msg
.
position
.
z
=
current_state
[
'P'
](
2
);
msg
.
pose
.
pose
.
orientation
.
x
=
current_state
[
'O'
](
0
);
pose
_msg
.
orientation
.
x
=
current_state
[
'O'
](
0
);
msg
.
pose
.
pose
.
orientation
.
y
=
current_state
[
'O'
](
1
);
pose
_msg
.
orientation
.
y
=
current_state
[
'O'
](
1
);
msg
.
pose
.
pose
.
orientation
.
z
=
current_state
[
'O'
](
2
);
pose
_msg
.
orientation
.
z
=
current_state
[
'O'
](
2
);
msg
.
pose
.
pose
.
orientation
.
w
=
current_state
[
'O'
](
3
);
pose
_msg
.
orientation
.
w
=
current_state
[
'O'
](
3
);
}
}
publisher_
.
publish
(
msg
);
publishPose
(
pose_msg
,
ros
::
Time
(
loc_ts
.
getSeconds
(),
loc_ts
.
getNanoSeconds
()));
}
void
PublisherPose
::
publishPose
(
const
geometry_msgs
::
Pose
pose
,
const
ros
::
Time
&
stamp
)
{
// fill msgs and publish
if
(
pose_array_
)
{
pose_array_msg_
.
header
.
stamp
=
stamp
;
pose_array_msg_
.
poses
.
push_back
(
pose
);
pub_pose_array_
.
publish
(
pose_array_msg_
);
}
if
(
marker_
)
{
marker_msg_
.
header
.
stamp
=
stamp
;
marker_msg_
.
points
.
push_back
(
pose
.
position
);
pub_marker_
.
publish
(
marker_msg_
);
}
}
}
}
}
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