From 22813d7c7a71997e8e07f56d238363f89a9d8732 Mon Sep 17 00:00:00 2001 From: Eric Cousineau Date: Fri, 5 Apr 2019 20:08:10 -0400 Subject: [PATCH] DNM ros2: Start porting - Add standard bits - Upgrade `visualization_marker_tutorials` - Add `COLCON_IGNORE` for packages not yet ported --- CONTRIBUTING.md | 4 + LICENSE | 1 + README.md | 23 ++++ interactive_marker_tutorials/COLCON_IGNORE | 0 librviz_tutorial/COLCON_IGNORE | 0 rviz_plugin_tutorials/COLCON_IGNORE | 0 rviz_python_tutorial/COLCON_IGNORE | 0 visualization_marker_tutorials/CHANGELOG.rst | 4 + visualization_marker_tutorials/CMakeLists.txt | 58 +++------ visualization_marker_tutorials/README.md | 16 +++ visualization_marker_tutorials/config.rviz | 115 ++++++++++++++++++ visualization_marker_tutorials/package.xml | 18 +-- .../src/basic_shapes.cpp | 93 +++++--------- .../src/points_and_lines.cpp | 62 ++++------ visualization_tutorials/CHANGELOG.rst | 26 ---- visualization_tutorials/CMakeLists.txt | 4 - visualization_tutorials/package.xml | 29 ----- 17 files changed, 246 insertions(+), 207 deletions(-) create mode 100644 CONTRIBUTING.md create mode 100644 LICENSE create mode 100644 README.md create mode 100644 interactive_marker_tutorials/COLCON_IGNORE create mode 100644 librviz_tutorial/COLCON_IGNORE create mode 100644 rviz_plugin_tutorials/COLCON_IGNORE create mode 100644 rviz_python_tutorial/COLCON_IGNORE create mode 100644 visualization_marker_tutorials/README.md create mode 100644 visualization_marker_tutorials/config.rviz delete mode 100644 visualization_tutorials/CHANGELOG.rst delete mode 100644 visualization_tutorials/CMakeLists.txt delete mode 100644 visualization_tutorials/package.xml diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md new file mode 100644 index 00000000..f68ab7d0 --- /dev/null +++ b/CONTRIBUTING.md @@ -0,0 +1,4 @@ +Any contribution that you make to this repository will +be under the BSD??? License, ... + +WHAT TO DO??? diff --git a/LICENSE b/LICENSE new file mode 100644 index 00000000..57d9d1ef --- /dev/null +++ b/LICENSE @@ -0,0 +1 @@ +BSD? diff --git a/README.md b/README.md new file mode 100644 index 00000000..ff687310 --- /dev/null +++ b/README.md @@ -0,0 +1,23 @@ +# RViz Tutorials + +**WARNING**: This is under development! At present, these tutorials are being +ported to ROS2 Crystal. + +The following tutorials have been ported: + +* `visualization_marker_tutorials` + * `basic_shapes` + * `points_and_lines` + +All other tutorials have **not** been ported, and have been marked with +`COLCON_IGNORE`: + +* `interactive_marker_tutorials` +* `librviz_tutorial` +* `rviz_plugin_tutorials` +* `rviz_python_tutorial` + +## ROS1 + +See [old ROS1 Wiki](http://wiki.ros.org/rviz/Tutorials). For source, see +[`ros-visualization/visualization_tutorials@kinetic-devel`](https://github.com/ros-visualization/visualization_tutorials/tree/kinetic-devel). diff --git a/interactive_marker_tutorials/COLCON_IGNORE b/interactive_marker_tutorials/COLCON_IGNORE new file mode 100644 index 00000000..e69de29b diff --git a/librviz_tutorial/COLCON_IGNORE b/librviz_tutorial/COLCON_IGNORE new file mode 100644 index 00000000..e69de29b diff --git a/rviz_plugin_tutorials/COLCON_IGNORE b/rviz_plugin_tutorials/COLCON_IGNORE new file mode 100644 index 00000000..e69de29b diff --git a/rviz_python_tutorial/COLCON_IGNORE b/rviz_python_tutorial/COLCON_IGNORE new file mode 100644 index 00000000..e69de29b diff --git a/visualization_marker_tutorials/CHANGELOG.rst b/visualization_marker_tutorials/CHANGELOG.rst index 7f741d07..3e653d60 100644 --- a/visualization_marker_tutorials/CHANGELOG.rst +++ b/visualization_marker_tutorials/CHANGELOG.rst @@ -2,6 +2,10 @@ Changelog for package visualization_marker_tutorials ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +0.11.0 (2019-04-05) +------------------- +* Initial porting to ROS2 Crystal + 0.10.3 (2018-05-09) ------------------- diff --git a/visualization_marker_tutorials/CMakeLists.txt b/visualization_marker_tutorials/CMakeLists.txt index 5033a9d6..8d588d72 100644 --- a/visualization_marker_tutorials/CMakeLists.txt +++ b/visualization_marker_tutorials/CMakeLists.txt @@ -1,48 +1,20 @@ -cmake_minimum_required(VERSION 2.8.3) +cmake_minimum_required(VERSION 3.5) project(visualization_marker_tutorials) -find_package(catkin REQUIRED COMPONENTS roscpp visualization_msgs) +find_package(ament_cmake REQUIRED) +find_package(rclcpp REQUIRED) +find_package(visualization_msgs REQUIRED) -################################### -## catkin specific configuration ## -################################### -## The catkin_package macro generates cmake config files for your package -## Declare things to be passed to dependent projects -## LIBRARIES: libraries you create in this project that dependent projects also need -## CATKIN_DEPENDS: catkin_packages dependent projects also need -## DEPENDS: system dependencies of this project that dependent projects also need +function(custom_executable target) + add_executable(${target} src/${target}.cpp) + ament_target_dependencies(${target} + "rclcpp" + "visualization_msgs") + install(TARGETS ${target} + DESTINATION lib/${PROJECT_NAME}) +endfunction() -catkin_package( - CATKIN_DEPENDS roscpp visualization_msgs -) +custom_executable(basic_shapes) +custom_executable(points_and_lines) -########### -## Build ## -########### - -include_directories(include - ${catkin_INCLUDE_DIRS} -) - -add_executable(basic_shapes src/basic_shapes.cpp) -target_link_libraries(basic_shapes - ${catkin_LIBRARIES} -) - -add_executable(points_and_lines src/points_and_lines.cpp) -target_link_libraries(points_and_lines - ${catkin_LIBRARIES} -) - -############# -## Install ## -############# - -## Mark executables and/or libraries for installation -install(TARGETS - basic_shapes - points_and_lines - ARCHIVE DESTINATION ${CATKIN_PACKAGE_LIB_DESTINATION} - LIBRARY DESTINATION ${CATKIN_PACKAGE_LIB_DESTINATION} - RUNTIME DESTINATION ${CATKIN_PACKAGE_BIN_DESTINATION} -) +ament_package() diff --git a/visualization_marker_tutorials/README.md b/visualization_marker_tutorials/README.md new file mode 100644 index 00000000..52f186f8 --- /dev/null +++ b/visualization_marker_tutorials/README.md @@ -0,0 +1,16 @@ +# Visualization Marker Tutorials + +See Old ROS1 for User Interface instructions: + +* [Markers: Sending Basic Shapes (C++)](http://wiki.ros.org/rviz/Tutorials/Markers%3A%20Basic%20Shapes) +* [Markers: Points and Lines (C++)](http://wiki.ros.org/rviz/Tutorials/Markers%3A%20Points%20and%20Lines) + +To run this with your workspace built and sourced: + +```sh +rviz2 -d ./config.rviz & +ros2 run visualization_marker_tutorials basic_shapes +# Look at pretty shapes! Then Ctrl+C it. +ros2 run visualization_marker_tutorials points_and_lines +# Look at the pretty colors! +``` diff --git a/visualization_marker_tutorials/config.rviz b/visualization_marker_tutorials/config.rviz new file mode 100644 index 00000000..d6ea1675 --- /dev/null +++ b/visualization_marker_tutorials/config.rviz @@ -0,0 +1,115 @@ +Panels: + - Class: rviz_common/Displays + Help Height: 78 + Name: Displays + Property Tree Widget: + Expanded: + - /Global Options1 + - /Marker1 + Splitter Ratio: 0.5 + Tree Height: 623 + - Class: rviz_common/Selection + Name: Selection + - Class: rviz_common/Tool Properties + Expanded: + - /2D Nav Goal1 + - /Publish Point1 + Name: Tool Properties + Splitter Ratio: 0.5886790156364441 + - Class: rviz_common/Views + Expanded: + - /Current View1 + Name: Views + Splitter Ratio: 0.5 +Visualization Manager: + Class: "" + Displays: + - Alpha: 0.5 + Cell Size: 1 + Class: rviz_default_plugins/Grid + Color: 160; 160; 164 + Enabled: true + Line Style: + Line Width: 0.029999999329447746 + Value: Lines + Name: Grid + Normal Cell Count: 0 + Offset: + X: 0 + Y: 0 + Z: 0 + Plane: XY + Plane Cell Count: 10 + Reference Frame: + Value: true + - Class: rviz_default_plugins/Marker + Enabled: true + Name: Marker + Namespaces: + basic_shapes: true + Queue Size: 10 + Topic: /visualization_marker + Unreliable: false + Value: true + Enabled: true + Global Options: + Background Color: 48; 48; 48 + Fixed Frame: my_frame + Frame Rate: 30 + Name: root + Tools: + - Class: rviz_default_plugins/MoveCamera + - Class: rviz_default_plugins/Select + - Class: rviz_default_plugins/FocusCamera + - Class: rviz_default_plugins/Measure + Line color: 128; 128; 0 + - Class: rviz_default_plugins/SetInitialPose + Topic: /initialpose + - Class: rviz_default_plugins/SetGoal + Topic: /move_base_simple/goal + - Class: rviz_default_plugins/PublishPoint + Single click: true + Topic: /clicked_point + Transformation: + Current: + Class: rviz_default_plugins/TF + Value: true + Views: + Current: + Class: rviz_default_plugins/Orbit + Distance: 5.878479480743408 + Enable Stereo Rendering: + Stereo Eye Separation: 0.05999999865889549 + Stereo Focal Distance: 1 + Swap Stereo Eyes: false + Value: false + Focal Point: + X: 0 + Y: 0 + Z: 0 + Focal Shape Fixed Size: false + Focal Shape Size: 0.05000000074505806 + Invert Z Axis: false + Name: Current View + Near Clip Distance: 0.009999999776482582 + Pitch: 0.9553979635238647 + Target Frame: + Value: Orbit (rviz) + Yaw: 2.0403969287872314 + Saved: ~ +Window Geometry: + Displays: + collapsed: false + Height: 846 + Hide Left Dock: false + Hide Right Dock: false + QMainWindow State: 000000ff00000000fd000000040000000000000156000002f8fc0200000008fb0000001200530065006c0065006300740069006f006e00000001e10000009b0000005c00fffffffb0000001e0054006f006f006c002000500072006f007000650072007400690065007302000001ed0000021500000185000000a3fb000000120056006900650077007300200054006f006f02000001df000002110000018500000122fb000000200054006f006f006c002000500072006f0070006500720074006900650073003203000002880000011d000002210000017afb000000100044006900730070006c006100790073010000003b000002f8000000c700fffffffb0000002000730065006c0065006300740069006f006e00200062007500660066006500720200000138000000aa0000023a00000294fb00000014005700690064006500530074006500720065006f02000000e6000000d2000003ee0000030bfb0000000c004b0069006e0065006300740200000186000001060000030c00000261000000010000010f000002f8fc0200000003fb0000001e0054006f006f006c002000500072006f00700065007200740069006500730100000041000000780000000000000000fb0000000a00560069006500770073010000003b000002f8000000a000fffffffb0000001200530065006c0065006300740069006f006e010000025a000000b200000000000000000000000200000490000000a9fc0100000001fb0000000a00560069006500770073030000004e00000080000002e10000019700000003000004420000003efc0100000002fb0000000800540069006d00650100000000000004420000000000000000fb0000000800540069006d006501000000000000045000000000000000000000023f000002f800000004000000040000000800000008fc0000000100000002000000010000000a0054006f006f006c00730100000000ffffffff0000000000000000 + Selection: + collapsed: false + Tool Properties: + collapsed: false + Views: + collapsed: false + Width: 1200 + X: 1539 + Y: 690 diff --git a/visualization_marker_tutorials/package.xml b/visualization_marker_tutorials/package.xml index 2db45f42..bcef709b 100644 --- a/visualization_marker_tutorials/package.xml +++ b/visualization_marker_tutorials/package.xml @@ -1,7 +1,8 @@ - + + visualization_marker_tutorials - 0.10.3 + 0.11.0 The visulalization_marker_tutorials package William Woodall @@ -11,12 +12,15 @@ Josh Faust - catkin + ament_cmake - roscpp + rclcpp visualization_msgs - roscpp - visualization_msgs + rclcpp + visualization_msgs - \ No newline at end of file + + ament_cmake + + diff --git a/visualization_marker_tutorials/src/basic_shapes.cpp b/visualization_marker_tutorials/src/basic_shapes.cpp index 935601c6..abbea999 100644 --- a/visualization_marker_tutorials/src/basic_shapes.cpp +++ b/visualization_marker_tutorials/src/basic_shapes.cpp @@ -27,54 +27,42 @@ * POSSIBILITY OF SUCH DAMAGE. */ -// %Tag(FULLTEXT)% -// %Tag(INCLUDES)% -#include -#include -// %EndTag(INCLUDES)% +#include +#include +#include + +using visualization_msgs::msg::Marker; -// %Tag(INIT)% int main( int argc, char** argv ) { - ros::init(argc, argv, "basic_shapes"); - ros::NodeHandle n; - ros::Rate r(1); - ros::Publisher marker_pub = n.advertise("visualization_marker", 1); -// %EndTag(INIT)% + using namespace std::chrono_literals; + + rclcpp::init(argc, argv); + auto node = std::make_shared("basic_shapes"); + auto marker_pub = node->create_publisher("visualization_marker"); // Set our initial shape type to be a cube -// %Tag(SHAPE_INIT)% - uint32_t shape = visualization_msgs::Marker::CUBE; -// %EndTag(SHAPE_INIT)% + uint32_t shape = Marker::CUBE; -// %Tag(MARKER_INIT)% - while (ros::ok()) + auto callback = [&]() { - visualization_msgs::Marker marker; + Marker marker; // Set the frame ID and timestamp. See the TF tutorials for information on these. marker.header.frame_id = "/my_frame"; - marker.header.stamp = ros::Time::now(); -// %EndTag(MARKER_INIT)% + marker.header.stamp = rclcpp::Clock().now(); // Set the namespace and id for this marker. This serves to create a unique ID // Any marker sent with the same namespace and id will overwrite the old one -// %Tag(NS_ID)% marker.ns = "basic_shapes"; marker.id = 0; -// %EndTag(NS_ID)% // Set the marker type. Initially this is CUBE, and cycles between that and SPHERE, ARROW, and CYLINDER -// %Tag(TYPE)% marker.type = shape; -// %EndTag(TYPE)% // Set the marker action. Options are ADD, DELETE, and new in ROS Indigo: 3 (DELETEALL) -// %Tag(ACTION)% - marker.action = visualization_msgs::Marker::ADD; -// %EndTag(ACTION)% + marker.action = Marker::ADD; // Set the pose of the marker. This is a full 6DOF pose relative to the frame/time specified in the header -// %Tag(POSE)% marker.pose.position.x = 0; marker.pose.position.y = 0; marker.pose.position.z = 0; @@ -82,63 +70,42 @@ int main( int argc, char** argv ) marker.pose.orientation.y = 0.0; marker.pose.orientation.z = 0.0; marker.pose.orientation.w = 1.0; -// %EndTag(POSE)% // Set the scale of the marker -- 1x1x1 here means 1m on a side -// %Tag(SCALE)% marker.scale.x = 1.0; marker.scale.y = 1.0; marker.scale.z = 1.0; -// %EndTag(SCALE)% // Set the color -- be sure to set alpha to something non-zero! -// %Tag(COLOR)% marker.color.r = 0.0f; marker.color.g = 1.0f; marker.color.b = 0.0f; marker.color.a = 1.0; -// %EndTag(COLOR)% -// %Tag(LIFETIME)% - marker.lifetime = ros::Duration(); -// %EndTag(LIFETIME)% + marker.lifetime = rclcpp::Duration(0.0); // Publish the marker -// %Tag(PUBLISH)% - while (marker_pub.getNumSubscribers() < 1) - { - if (!ros::ok()) - { - return 0; - } - ROS_WARN_ONCE("Please create a subscriber to the marker"); - ros::Duration(1.0).sleep(); - } - marker_pub.publish(marker); -// %EndTag(PUBLISH)% + marker_pub->publish(marker); // Cycle between different shapes -// %Tag(CYCLE_SHAPES)% switch (shape) { - case visualization_msgs::Marker::CUBE: - shape = visualization_msgs::Marker::SPHERE; + case Marker::CUBE: + shape = Marker::SPHERE; break; - case visualization_msgs::Marker::SPHERE: - shape = visualization_msgs::Marker::ARROW; + case Marker::SPHERE: + shape = Marker::ARROW; break; - case visualization_msgs::Marker::ARROW: - shape = visualization_msgs::Marker::CYLINDER; + case Marker::ARROW: + shape = Marker::CYLINDER; break; - case visualization_msgs::Marker::CYLINDER: - shape = visualization_msgs::Marker::CUBE; + case Marker::CYLINDER: + shape = Marker::CUBE; break; } -// %EndTag(CYCLE_SHAPES)% - -// %Tag(SLEEP_END)% - r.sleep(); - } -// %EndTag(SLEEP_END)% + }; + rclcpp::TimerBase::SharedPtr timer = node->create_wall_timer(1s, callback); + rclcpp::spin(node); + rclcpp::shutdown(); + return 0; } -// %EndTag(FULLTEXT)% diff --git a/visualization_marker_tutorials/src/points_and_lines.cpp b/visualization_marker_tutorials/src/points_and_lines.cpp index b3a50180..95eca137 100644 --- a/visualization_marker_tutorials/src/points_and_lines.cpp +++ b/visualization_marker_tutorials/src/points_and_lines.cpp @@ -27,45 +27,42 @@ * POSSIBILITY OF SUCH DAMAGE. */ -// %Tag(FULLTEXT)% -#include -#include +#include +#include +#include +#include #include +using geometry_msgs::msg::Point; +using visualization_msgs::msg::Marker; + int main( int argc, char** argv ) { - ros::init(argc, argv, "points_and_lines"); - ros::NodeHandle n; - ros::Publisher marker_pub = n.advertise("visualization_marker", 10); + using namespace std::chrono_literals; - ros::Rate r(30); + rclcpp::init(argc, argv); + auto node = std::make_shared("basic_shapes"); + auto marker_pub = node->create_publisher("visualization_marker"); float f = 0.0; - while (ros::ok()) + auto callback = [&]() { -// %Tag(MARKER_INIT)% - visualization_msgs::Marker points, line_strip, line_list; + Marker points, line_strip, line_list; points.header.frame_id = line_strip.header.frame_id = line_list.header.frame_id = "/my_frame"; - points.header.stamp = line_strip.header.stamp = line_list.header.stamp = ros::Time::now(); + points.header.stamp = line_strip.header.stamp = line_list.header.stamp = rclcpp::Clock().now(); points.ns = line_strip.ns = line_list.ns = "points_and_lines"; - points.action = line_strip.action = line_list.action = visualization_msgs::Marker::ADD; + points.action = line_strip.action = line_list.action = Marker::ADD; points.pose.orientation.w = line_strip.pose.orientation.w = line_list.pose.orientation.w = 1.0; -// %EndTag(MARKER_INIT)% -// %Tag(ID)% points.id = 0; line_strip.id = 1; line_list.id = 2; -// %EndTag(ID)% -// %Tag(TYPE)% - points.type = visualization_msgs::Marker::POINTS; - line_strip.type = visualization_msgs::Marker::LINE_STRIP; - line_list.type = visualization_msgs::Marker::LINE_LIST; -// %EndTag(TYPE)% + points.type = Marker::POINTS; + line_strip.type = Marker::LINE_STRIP; + line_list.type = Marker::LINE_LIST; -// %Tag(SCALE)% // POINTS markers use x and y scale for width/height respectively points.scale.x = 0.2; points.scale.y = 0.2; @@ -73,9 +70,7 @@ int main( int argc, char** argv ) // LINE_STRIP/LINE_LIST markers use only the x component of scale, for the line width line_strip.scale.x = 0.1; line_list.scale.x = 0.1; -// %EndTag(SCALE)% -// %Tag(COLOR)% // Points are green points.color.g = 1.0f; points.color.a = 1.0; @@ -87,16 +82,14 @@ int main( int argc, char** argv ) // Line list is red line_list.color.r = 1.0; line_list.color.a = 1.0; -// %EndTag(COLOR)% -// %Tag(HELIX)% // Create the vertices for the points and lines for (uint32_t i = 0; i < 100; ++i) { float y = 5 * sin(f + i / 100.0f * 2 * M_PI); float z = 5 * cos(f + i / 100.0f * 2 * M_PI); - geometry_msgs::Point p; + Point p; p.x = (int32_t)i - 50; p.y = y; p.z = z; @@ -109,16 +102,15 @@ int main( int argc, char** argv ) p.z += 1.0; line_list.points.push_back(p); } -// %EndTag(HELIX)% - - marker_pub.publish(points); - marker_pub.publish(line_strip); - marker_pub.publish(line_list); - r.sleep(); + marker_pub->publish(points); + marker_pub->publish(line_strip); + marker_pub->publish(line_list); f += 0.04; - } + }; + auto period = static_cast(1e6 / 30) * 1us; + rclcpp::TimerBase::SharedPtr timer = node->create_wall_timer(period, callback); + rclcpp::spin(node); + rclcpp::shutdown(); } -// %EndTag(FULLTEXT)% - diff --git a/visualization_tutorials/CHANGELOG.rst b/visualization_tutorials/CHANGELOG.rst deleted file mode 100644 index 821564d2..00000000 --- a/visualization_tutorials/CHANGELOG.rst +++ /dev/null @@ -1,26 +0,0 @@ -^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -Changelog for package visualization_tutorials -^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - -0.10.3 (2018-05-09) -------------------- - -0.10.2 (2018-01-05) -------------------- - -0.10.1 (2016-04-21) -------------------- - -0.10.0 (2016-04-21) -------------------- - -0.9.2 (2015-09-21) ------------------- - -0.9.1 (2015-01-26) ------------------- - -0.9.0 (2014-03-24) ------------------- -* set myself (william) as maintainer -* Contributors: William Woodall diff --git a/visualization_tutorials/CMakeLists.txt b/visualization_tutorials/CMakeLists.txt deleted file mode 100644 index 389a5422..00000000 --- a/visualization_tutorials/CMakeLists.txt +++ /dev/null @@ -1,4 +0,0 @@ -cmake_minimum_required(VERSION 2.8.3) -project(visualization_tutorials) -find_package(catkin REQUIRED) -catkin_metapackage() diff --git a/visualization_tutorials/package.xml b/visualization_tutorials/package.xml deleted file mode 100644 index 39e22ba2..00000000 --- a/visualization_tutorials/package.xml +++ /dev/null @@ -1,29 +0,0 @@ - - visualization_tutorials - 0.10.3 - - Metapackage referencing tutorials related to rviz and visualization. - - William Woodall - BSD - - http://ros.org/wiki/visualization_tutorials - Dave Hershberger - David Gossow - Josh Faust - - catkin - - interactive_marker_tutorials - librviz_tutorial - rviz_plugin_tutorials - rviz_python_tutorial - visualization_marker_tutorials - - - - - - - -