From 9673b9cff9d0e1965e7a6f18f7cb7868bc29433a Mon Sep 17 00:00:00 2001 From: Jihoon Lee Date: Wed, 11 Mar 2015 17:39:16 +0900 Subject: [PATCH] migrate interactive markers from turtlebot_interactions --- turtlebot_apps/package.xml | 1 + turtlebot_interactive_markers/.cproject | 43 ++++++ turtlebot_interactive_markers/.gitignore | 2 + turtlebot_interactive_markers/.project | 79 ++++++++++ turtlebot_interactive_markers/CHANGELOG.rst | 39 +++++ turtlebot_interactive_markers/CMakeLists.txt | 22 +++ .../launch/interactive_markers.launch | 15 ++ turtlebot_interactive_markers/package.xml | 23 +++ .../src/turtlebot_marker_server.cpp | 141 ++++++++++++++++++ turtlebot_rapps/package.xml | 2 + .../interactive_markers_control.interface | 5 + .../interactive_markers_control.launch | 3 + .../interactive_markers_control.rapp | 6 + 13 files changed, 381 insertions(+) create mode 100644 turtlebot_interactive_markers/.cproject create mode 100644 turtlebot_interactive_markers/.gitignore create mode 100644 turtlebot_interactive_markers/.project create mode 100644 turtlebot_interactive_markers/CHANGELOG.rst create mode 100644 turtlebot_interactive_markers/CMakeLists.txt create mode 100644 turtlebot_interactive_markers/launch/interactive_markers.launch create mode 100644 turtlebot_interactive_markers/package.xml create mode 100644 turtlebot_interactive_markers/src/turtlebot_marker_server.cpp create mode 100644 turtlebot_rapps/rapps/interactive_markers_control/interactive_markers_control.interface create mode 100644 turtlebot_rapps/rapps/interactive_markers_control/interactive_markers_control.launch create mode 100644 turtlebot_rapps/rapps/interactive_markers_control/interactive_markers_control.rapp diff --git a/turtlebot_apps/package.xml b/turtlebot_apps/package.xml index 8ecbcac1..2d45cd98 100644 --- a/turtlebot_apps/package.xml +++ b/turtlebot_apps/package.xml @@ -25,6 +25,7 @@ turtlebot_follower turtlebot_navigation turtlebot_panorama + turtlebot_interactiver_markers diff --git a/turtlebot_interactive_markers/.cproject b/turtlebot_interactive_markers/.cproject new file mode 100644 index 00000000..47db4e3b --- /dev/null +++ b/turtlebot_interactive_markers/.cproject @@ -0,0 +1,43 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/turtlebot_interactive_markers/.gitignore b/turtlebot_interactive_markers/.gitignore new file mode 100644 index 00000000..c7459193 --- /dev/null +++ b/turtlebot_interactive_markers/.gitignore @@ -0,0 +1,2 @@ +bin +build diff --git a/turtlebot_interactive_markers/.project b/turtlebot_interactive_markers/.project new file mode 100644 index 00000000..2d7a4f02 --- /dev/null +++ b/turtlebot_interactive_markers/.project @@ -0,0 +1,79 @@ + + + turtlebot_interactive_markers + + + + + + org.eclipse.cdt.managedbuilder.core.genmakebuilder + clean,full,incremental, + + + ?name? + + + + org.eclipse.cdt.make.core.append_environment + true + + + org.eclipse.cdt.make.core.autoBuildTarget + all + + + org.eclipse.cdt.make.core.buildArguments + + + + org.eclipse.cdt.make.core.buildCommand + make + + + org.eclipse.cdt.make.core.cleanBuildTarget + clean + + + org.eclipse.cdt.make.core.contents + org.eclipse.cdt.make.core.activeConfigSettings + + + org.eclipse.cdt.make.core.enableAutoBuild + false + + + org.eclipse.cdt.make.core.enableCleanBuild + true + + + org.eclipse.cdt.make.core.enableFullBuild + true + + + org.eclipse.cdt.make.core.fullBuildTarget + all + + + org.eclipse.cdt.make.core.stopOnError + true + + + org.eclipse.cdt.make.core.useDefaultBuildCmd + true + + + + + org.eclipse.cdt.managedbuilder.core.ScannerConfigBuilder + full,incremental, + + + + + + org.eclipse.cdt.core.cnature + org.eclipse.cdt.core.ccnature + org.eclipse.cdt.managedbuilder.core.managedBuildNature + org.eclipse.cdt.managedbuilder.core.ScannerConfigNature + + diff --git a/turtlebot_interactive_markers/CHANGELOG.rst b/turtlebot_interactive_markers/CHANGELOG.rst new file mode 100644 index 00000000..4bf28325 --- /dev/null +++ b/turtlebot_interactive_markers/CHANGELOG.rst @@ -0,0 +1,39 @@ +^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +Changelog for package turtlebot_interactive_markers +^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +2.3.2 (2015-01-21) +------------------ + +2.3.0 (2014-12-30) +------------------ + +2.2.2 (2013-10-25) +------------------ +* Correct reference to renamed launcher. +* Add missing install rule for the server. + +2.2.1 (2013-09-11) +------------------ + +2.2.0 (2013-08-30) +------------------ +* Add bugtracker and repo info URLs. +* Changelogs at package level. + + +2.1.x - hydro, unstable +======================= + +2.1.1 (2013-07-23) +------------------ + +2.1.0 (2013-07-16) +------------------ +* Catkinized + + +Previous versions, bugfixing +============================ + +Available in ROS wiki: http://ros.org/wiki/turtlebot_viz/ChangeList diff --git a/turtlebot_interactive_markers/CMakeLists.txt b/turtlebot_interactive_markers/CMakeLists.txt new file mode 100644 index 00000000..f10ba7c5 --- /dev/null +++ b/turtlebot_interactive_markers/CMakeLists.txt @@ -0,0 +1,22 @@ +cmake_minimum_required(VERSION 2.8.3) + +project(turtlebot_interactive_markers) + +find_package(catkin REQUIRED COMPONENTS roscpp + visualization_msgs + interactive_markers) + +catkin_package() + +include_directories(${catkin_INCLUDE_DIRS}) + +add_executable(turtlebot_marker_server src/turtlebot_marker_server.cpp) + +target_link_libraries(turtlebot_marker_server ${catkin_LIBRARIES}) + +install(TARGETS turtlebot_marker_server DESTINATION ${CATKIN_PACKAGE_BIN_DESTINATION}) + +install(DIRECTORY launch DESTINATION ${CATKIN_PACKAGE_SHARE_DESTINATION}) + + + diff --git a/turtlebot_interactive_markers/launch/interactive_markers.launch b/turtlebot_interactive_markers/launch/interactive_markers.launch new file mode 100644 index 00000000..4aa8b4f0 --- /dev/null +++ b/turtlebot_interactive_markers/launch/interactive_markers.launch @@ -0,0 +1,15 @@ + + + + + + + + + + + + + + diff --git a/turtlebot_interactive_markers/package.xml b/turtlebot_interactive_markers/package.xml new file mode 100644 index 00000000..85334757 --- /dev/null +++ b/turtlebot_interactive_markers/package.xml @@ -0,0 +1,23 @@ + + + turtlebot_interactive_markers + 2.3.2 + Interactive control for the TurtleBot using RViz and interactive markers + Daniel Stonier + BSD + http://ros.org/wiki/turtlebot_interactive_markers + https://github.com/turtlebot/turtlebot_apps + https://github.com/turtlebot/turtlebot_apps/issues + Helen Oleynikova + + catkin + + roscpp + visualization_msgs + interactive_markers + + roscpp + visualization_msgs + interactive_markers + turtlebot_bringup + diff --git a/turtlebot_interactive_markers/src/turtlebot_marker_server.cpp b/turtlebot_interactive_markers/src/turtlebot_marker_server.cpp new file mode 100644 index 00000000..54d4512e --- /dev/null +++ b/turtlebot_interactive_markers/src/turtlebot_marker_server.cpp @@ -0,0 +1,141 @@ +/* + * Copyright (c) 2011, Willow Garage, Inc. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * * Neither the name of the Willow Garage, Inc. nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE + * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + */ + +#include +#include +#include +#include +#include +#include + +using namespace visualization_msgs; + +class TurtlebotMarkerServer +{ + public: + TurtlebotMarkerServer() + : nh("~"), server("turtlebot_marker_server") + { + std::string cmd_vel_topic; + + nh.param("link_name", link_name, "/base_link"); + nh.param("linear_scale", linear_scale, 1.0); + nh.param("angular_scale", angular_scale, 2.2); + + vel_pub = nh.advertise("/cmd_vel", 1); + createInteractiveMarkers(); + + ROS_INFO("[turtlebot_marker_server] Initialized."); + } + + void processFeedback( + const InteractiveMarkerFeedbackConstPtr &feedback ); + + private: + void createInteractiveMarkers(); + + ros::NodeHandle nh; + ros::Publisher vel_pub; + interactive_markers::InteractiveMarkerServer server; + + double linear_scale; + double angular_scale; + + std::string link_name; +}; + +void TurtlebotMarkerServer::processFeedback( + const InteractiveMarkerFeedbackConstPtr &feedback ) +{ + // Handle angular change (yaw is the only direction in which you can rotate) + double yaw = tf::getYaw(feedback->pose.orientation); + + geometry_msgs::Twist vel; + vel.angular.z = angular_scale*yaw; + vel.linear.x = linear_scale*feedback->pose.position.x; + + vel_pub.publish(vel); + + // Make the marker snap back to turtlebot + server.setPose("turtlebot_marker", geometry_msgs::Pose()); + + server.applyChanges(); +} + +void TurtlebotMarkerServer::createInteractiveMarkers() +{ + // create an interactive marker for our server + InteractiveMarker int_marker; + int_marker.header.frame_id = link_name; + int_marker.name = "turtlebot_marker"; + //int_marker.description = "Move the turtlebot"; + + InteractiveMarkerControl control; + + control.orientation_mode = InteractiveMarkerControl::FIXED; + control.orientation.w = 1; + control.orientation.x = 1; + control.orientation.y = 0; + control.orientation.z = 0; + control.name = "move_x"; + control.interaction_mode = InteractiveMarkerControl::MOVE_AXIS; + int_marker.controls.push_back(control); + + control.orientation.w = 1; + control.orientation.x = 0; + control.orientation.y = 1; + control.orientation.z = 0; + control.name = "rotate_z"; + + control.interaction_mode = InteractiveMarkerControl::MOVE_ROTATE; + //control.interaction_mode = InteractiveMarkerControl::ROTATE_AXIS; + int_marker.controls.push_back(control); + + // Commented out for non-holonomic turtlebot. If holonomic, can move in y. + /*control.orientation.w = 1; + control.orientation.x = 0; + control.orientation.y = 0; + control.orientation.z = 1; + control.name = "move_y"; + control.interaction_mode = InteractiveMarkerControl::MOVE_AXIS; + int_marker.controls.push_back(control);*/ + + server.insert(int_marker, boost::bind( &TurtlebotMarkerServer::processFeedback, this, _1 )); + + server.applyChanges(); +} + + +int main(int argc, char** argv) +{ + ros::init(argc, argv, "turtlebot_marker_server"); + TurtlebotMarkerServer turtleserver; + + ros::spin(); +} diff --git a/turtlebot_rapps/package.xml b/turtlebot_rapps/package.xml index 5d461bde..c3a5f427 100644 --- a/turtlebot_rapps/package.xml +++ b/turtlebot_rapps/package.xml @@ -19,6 +19,7 @@ turtlebot_navigation turtlebot_panorama turtlebot_teleop + turtlebot_interactive_markers robot_pose_publisher @@ -46,6 +47,7 @@ rapps/panorama/panorama.rapp rapps/follower/follower.rapp rapps/3dsensor/3dsensor.rapp + rapps/interactive_markers_control/interactive_markers_control.rapp diff --git a/turtlebot_rapps/rapps/interactive_markers_control/interactive_markers_control.interface b/turtlebot_rapps/rapps/interactive_markers_control/interactive_markers_control.interface new file mode 100644 index 00000000..e0b2550b --- /dev/null +++ b/turtlebot_rapps/rapps/interactive_markers_control/interactive_markers_control.interface @@ -0,0 +1,5 @@ +publishers: [] +subscribers: [] +services: [] +action_clients: [] +action_servers: [] \ No newline at end of file diff --git a/turtlebot_rapps/rapps/interactive_markers_control/interactive_markers_control.launch b/turtlebot_rapps/rapps/interactive_markers_control/interactive_markers_control.launch new file mode 100644 index 00000000..174f48cb --- /dev/null +++ b/turtlebot_rapps/rapps/interactive_markers_control/interactive_markers_control.launch @@ -0,0 +1,3 @@ + + + diff --git a/turtlebot_rapps/rapps/interactive_markers_control/interactive_markers_control.rapp b/turtlebot_rapps/rapps/interactive_markers_control/interactive_markers_control.rapp new file mode 100644 index 00000000..5704ba0a --- /dev/null +++ b/turtlebot_rapps/rapps/interactive_markers_control/interactive_markers_control.rapp @@ -0,0 +1,6 @@ +display: Interactive Markers Control +description: Control turtlebit using interactive markers +compatibility: rocon:/turtlebot +launch: interactive_markers_control.launch +public_interface: interactive_markers_control.interface +#icon: interactive_markers_control.png