## page was renamed from rviz/Tutorials/Markers: Points and Lines (C++) ## For instruction on writing tutorials ## http://www.ros.org/wiki/WritingTutorials #################################### ##FILL ME IN #################################### ## for a custom note with links: ## note = ## for the canned note of "This tutorial assumes that you have completed the previous tutorials:" just add the links ## note.0= [[rviz/Tutorials/Markers: Basic Shapes|Markers: Basic Shapes]] ## descriptive title for the tutorial ## title = Markers: Points and Lines (C++) ## multi-line description to be displayed in search ## description = Teaches how to use the <> message to send points and lines to rviz. ## the next tutorial description (optional) ## next = ## links to next tutorial (optional) ## next.0.link=[[rviz/Tutorials/Interactive Markers: Getting Started|Interactive Markers: Getting Started]] ## next.1.link= ## what level user is this tutorial for ## level= BeginnerCategory ## keywords = #################################### <> <> == Intro == In the [[rviz/Tutorials/Markers: Basic Shapes|Markers: Basic Shapes]] you learned how to send simple shapes to rviz using visualization markers. You can send more than just simple shapes though, and this tutorial will introduce you to the `POINTS`, `LINE_STRIP` and `LINE_LIST` marker types. For a full list of types, see the [[rviz/DisplayTypes/Marker|Marker Display page]]. == Using Points, Line Strips, and Line Lists == The `POINTS`, `LINE_STRIP` and `LINE_LIST` markers all use the `points` member of the <> message. The `POINTS` type places a point at each point added. The `LINE_STRIP` type uses each point as a vertex in a connected set of lines, where point 0 is connected to point 1, 1 to 2, 2 to 3, etc. The `LINE_LIST` type creates unconnected lines out of each pair of points, i.e. point 0 to 1, 2 to 3, etc. Anyway, let's get to the code: === The Code === <> === The Code Explained === Now let's break down the code, skipping things that were explained in the previous tutorial. The overall effect created is a rotating helix with lines sticking upwards from each vertex. <> Here we create three <> messages and initialize all of their shared data. We take advantage of the fact that message members default to 0 and only set the `w` member of the pose. <> We assign three different ids to the three markers. The use of the `points_and_lines` namespace ensures they won't collide with other broadcasters. <> Here we set the marker types to `POINTS`, `LINE_STRIP` and `LINE_LIST`. <> The `scale` member means different things for these marker types. The `POINTS` marker uses the `x` and `y` members for width and height respectively, while the `LINE_STRIP` and `LINE_LIST` markers only use the `x` component, which defines the line width. Scale values are in meters. <> Here we set the points to green, the line strip to blue, and the line list to red. <> We use sine and cosine to generate a helix. The `POINTS` and `LINE_STRIP` markers both require only a point for each vertex, while the `LINE_LIST` marker requires 2. === Viewing the Markers === Set up rviz the same way you did in the last tutorial, which is as follows: Edit the `CMakeLists.txt` file in your `using_markers` package, and add to the bottom: <> {{{{#!wiki buildsystem rosbuild {{{ rosbuild_add_executable(points_and_lines src/points_and_lines.cpp) }}} Then, {{{ $ rosmake using_markers }}} }}}} {{{{#!wiki buildsystem catkin {{{ add_executable(points_and_lines src/points_and_lines.cpp) target_link_libraries(points_and_lines ${catkin_LIBRARIES}) }}} Then, {{{ $ catkin_make }}} }}}} Then, {{{ $ rosrun rviz rviz & $ rosrun using_markers points_and_lines }}} You should see a rotating helix that looks something like this: {{attachment:points_and_lines_marker_tutorial.png|Basic Shapes|width="768"}} == Next Steps == The [[rviz/DisplayTypes/Marker|Marker Display page]] has a list of all the markers and options supported by rviz. Try out some of the other markers! ## AUTOGENERATED DO NOT DELETE ## TutorialCategory ## FILL IN THE STACK TUTORIAL CATEGORY HERE