Skip to content

Commit 0e37700

Browse files
authored
Add Sphere marker
Add Sphere marker
2 parents 888fe1c + 1ee0a21 commit 0e37700

File tree

4 files changed

+30
-0
lines changed

4 files changed

+30
-0
lines changed

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ Currently support:
2525
- Line List
2626
- Cylinder
2727
- Cube
28+
- Sphere
2829
- Arrow
2930
- Text
3031
- Frame (Axes-type Pose)

include/ros_viz_tools/ros_viz_tools.h

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,13 @@ class RosVizTools {
7878
const ColorRGBA &color,
7979
const std::string &frame_id);
8080

81+
static Marker newSphere(const double &scale,
82+
const geometry_msgs::Pose &pose,
83+
const std::string &ns,
84+
const int32_t &id,
85+
const ColorRGBA &color,
86+
const std::string &frame_id);
87+
8188
static Marker newArrow(const geometry_msgs::Vector3 &scale,
8289
const geometry_msgs::Pose &pose,
8390
const std::string &ns,

src/demo_node.cpp

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -115,6 +115,15 @@ int main( int argc, char** argv )
115115
visualization_msgs::Marker marker_cube = RosVizTools::newCube(1.0, pose , ns, 0, ros_viz_tools::WHITE, frame_id);
116116
markers.append(marker_cube);
117117

118+
// Cube
119+
ns = "sphere";
120+
pose.position.x = -3.0;
121+
pose.position.y = -3.0;
122+
pose.position.z = -3.0;
123+
pose.orientation = tf2::toMsg(tf2::Quaternion(0 * M_PI / 180, 45 * M_PI / 180, 45 * M_PI / 180));
124+
visualization_msgs::Marker marker_sphere = RosVizTools::newSphere(0.5, pose , ns, 0, ros_viz_tools::RED, frame_id);
125+
markers.append(marker_sphere);
126+
118127
// Arrow
119128
ns = "arrow";
120129
scale.x = 1.0;

src/ros_viz_tools.cpp

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -124,6 +124,19 @@ Marker RosVizTools::newCube(const double &scale,
124124
return newMaker(vec_scale, pose, ns, id, color, frame_id, visualization_msgs::Marker::CUBE);
125125
}
126126

127+
Marker RosVizTools::newSphere(const double &scale,
128+
const geometry_msgs::Pose &pose,
129+
const std::string &ns,
130+
const int32_t &id,
131+
const ColorRGBA &color,
132+
const std::string &frame_id) {
133+
geometry_msgs::Vector3 vec_scale;
134+
vec_scale.x = scale;
135+
vec_scale.y = scale;
136+
vec_scale.z = scale;
137+
return newMaker(vec_scale, pose, ns, id, color, frame_id, visualization_msgs::Marker::SPHERE);
138+
}
139+
127140
Marker RosVizTools::newArrow(const geometry_msgs::Vector3 &scale,
128141
const geometry_msgs::Pose &pose,
129142
const std::string &ns,

0 commit comments

Comments
 (0)