Skip to content

Commit

Permalink
Visualize height of UAV (both esitamted state and ground truth) in rv…
Browse files Browse the repository at this point in the history
…iz and modify the config of rviz about task1 and task3
  • Loading branch information
tongtybj committed Jun 16, 2016
1 parent 5bb8a36 commit 1e5b8dd
Show file tree
Hide file tree
Showing 6 changed files with 340 additions and 7 deletions.
20 changes: 18 additions & 2 deletions jsk_mbzirc_tasks/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,10 @@ project(jsk_mbzirc_tasks)
## Find catkin macros and libraries
## if COMPONENTS list like find_package(catkin REQUIRED COMPONENTS xyz)
## is used, also find other catkin packages
find_package(catkin REQUIRED COMPONENTS roscpp)
find_package(catkin REQUIRED COMPONENTS roscpp gazebo_ros)

# Depend on system install of Gazebo and SDFormat
find_package(gazebo REQUIRED)

###################################
## catkin specific configuration ##
Expand All @@ -14,14 +16,28 @@ catkin_package(
CATKIN_DEPENDS
)

include_directories(include ${catkin_INCLUDE_DIRS})
include_directories(include ${catkin_INCLUDE_DIRS} ${GAZEBO_INCLUDE_DIRS})

add_executable(uav_teleop_keyboard src/uav_teleop_keyboard.cpp)
target_link_libraries(uav_teleop_keyboard ${catkin_LIBRARIES})

# build plugins
add_library(mbzirc_gazebo_uav_state_display_plugin src/mbzirc_gazebo_uav_state_display_plugin.cpp)
target_link_libraries(mbzirc_gazebo_uav_state_display_plugin ${GAZEBO_LIBRARIES} ${catkin_LIBRARIES} ${Boost_LIBRARIES})

#############
## Install ##
#############

#############
## Install ##
#############
install(TARGETS
mbzirc_gazebo_uav_state_display_plugin
DESTINATION ${CATKIN_PACKAGE_BIN_DESTINATION}
LIBRARY DESTINATION ${CATKIN_PACKAGE_LIB_DESTINATION}
)

install(DIRECTORY launch urdf config
DESTINATION ${CATKIN_PACKAGE_SHARE_DESTINATION}
USE_SOURCE_PERMISSIONS)
Expand Down
62 changes: 60 additions & 2 deletions jsk_mbzirc_tasks/config/task3.rviz
Original file line number Diff line number Diff line change
@@ -1,13 +1,16 @@
Panels:
- Class: rviz/Displays
Help Height: 78
Help Height: 0
Name: Displays
Property Tree Widget:
Expanded:
- /Global Options1
- /Status1
- /OverlayText1
- /OverlayText2
- /OverlayText3
Splitter Ratio: 0.5
Tree Height: 124
Tree Height: 202
- Class: rviz/Selection
Name: Selection
- Class: rviz/Tool Properties
Expand Down Expand Up @@ -129,6 +132,7 @@ Visualization Manager:
Value: true
Visibility:
Grid: true
OverlayText: true
Remaining Time: true
UAV1 LaserScan: true
UAV1 RobotModel: true
Expand Down Expand Up @@ -342,6 +346,60 @@ Visualization Manager:
text size: 64
top: 10
width: 370
- Background Alpha: 0.8
Background Color: 0; 0; 0
Class: jsk_rviz_plugin/OverlayText
Enabled: true
Foreground Alpha: 0.8
Foreground Color: 25; 255; 240
Name: OverlayText
Overtake Color Properties: true
Overtake Position Properties: true
Topic: /UAV1/ground_truth_overlay
Value: true
font: DejaVu Sans Mono
height: 60
left: 10
line width: 2
text size: 20
top: 10
width: 330
- Background Alpha: 0.8
Background Color: 0; 0; 0
Class: jsk_rviz_plugin/OverlayText
Enabled: true
Foreground Alpha: 0.8
Foreground Color: 25; 255; 240
Name: OverlayText
Overtake Color Properties: true
Overtake Position Properties: true
Topic: /UAV2/ground_truth_overlay
Value: true
font: DejaVu Sans Mono
height: 60
left: 10
line width: 2
text size: 20
top: 80
width: 330
- Background Alpha: 0.8
Background Color: 0; 0; 0
Class: jsk_rviz_plugin/OverlayText
Enabled: true
Foreground Alpha: 0.8
Foreground Color: 25; 255; 240
Name: OverlayText
Overtake Color Properties: true
Overtake Position Properties: true
Topic: /UAV3/ground_truth_overlay
Value: true
font: DejaVu Sans Mono
height: 60
left: 10
line width: 2
text size: 20
top: 150
width: 330
Enabled: true
Global Options:
Background Color: 48; 48; 48
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,88 @@
/*
* Copyright (c) 2016, JSK Robotics Laboratory, The University of Tokyo
* 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.
*/

#ifndef JSK_MBZIRC_TASKS_MBZIRC_GAZEBO_UAV_STATE_DISPLAY_PLUGIN_H
#define JSK_MBZIRC_TASKS_MBZIRC_GAZEBO_UAV_STATE_DISPLAY_PLUGIN_H

#include <gazebo/common/Plugin.hh>
#include <gazebo/common/Time.hh>
#include <gazebo/math/Quaternion.hh>
#include <gazebo/common/Events.hh>
#include <gazebo/physics/physics.hh>

// ROS
#include <ros/ros.h>
#include <ros/callback_queue.h>

#include <nav_msgs/Odometry.h>
#include <std_msgs/String.h>

// Boost
#include <boost/thread.hpp>
#include <boost/bind.hpp>

#include <cmath>
#include <string>

namespace gazebo
{
class GazeboUavState : public ModelPlugin
{
public:
GazeboUavState();
virtual ~GazeboUavState();

protected:
virtual void Load(physics::ModelPtr _model, sdf::ElementPtr _sdf);
virtual void Update();

private:
ros::NodeHandle* node_handle_;

ros::Subscriber state_sub_, ground_truth_sub_;
ros::Publisher string_state_pub_, string_ground_truth_pub_;

ros::CallbackQueue callback_queue_;
event::ConnectionPtr update_connection_;

physics::WorldPtr world_;
physics::LinkPtr link_;
std::string link_name_;

std::string state_topic_, ground_truth_topic_;

// parameters
std::string robot_name_space_;

void stateCallback(const nav_msgs::OdometryConstPtr&);
void groundTruthCallback(const nav_msgs::OdometryConstPtr&);
};
} // namespace gazebo

#endif // JSK_MBZIRC_TASKS_MBZIRC_GAZEBO_UAV_STATE_DISPLAY_PLUGIN_H
13 changes: 11 additions & 2 deletions jsk_mbzirc_tasks/launch/jsk_mbzirc_task_1.launch
Original file line number Diff line number Diff line change
Expand Up @@ -39,17 +39,26 @@
</include>

<!-- workaround until https://github.com/ros/ros_comm/pull/728 get released -->
<!-- display time in rviz -->
<node pkg="jsk_mbzirc_tasks" name="remain_time_text_to_overlay" type="relay_field_728.py"
args="/remaining_time /remaining_time_overlay jsk_rviz_plugins/OverlayText
'text: m.data' --wait-for-start" />
<!-- display uav state in rviz -->
<node pkg="jsk_mbzirc_tasks" name="uav_state_text_to_overlay" type="relay_field_728.py"
args="/string_state /state_overlay jsk_rviz_plugins/OverlayText
'text: m.data' --wait-for-start" />
<!-- display state in rviz -->
<node pkg="jsk_mbzirc_tasks" name="uav_ground_truth_text_to_overlay" type="relay_field_728.py"
args="/string_ground_truth /ground_truth_overlay jsk_rviz_plugins/OverlayText
'text: m.data' --wait-for-start" />

<group unless="$(arg headless)" >
<node pkg="rviz" type="rviz" name="rviz" args="-d $(find jsk_mbzirc_tasks)/config/task1.rviz"/>

<node pkg="jsk_mbzirc_tasks" type="uav_teleop_keyboard" name="uav_teleop_keyboard"
launch-prefix="xterm -e">
<param name="teleopUGV" value="$(arg teleopUGV)"/>
<remap from="teleopUGV" to="uav_teleop_keyboard/teleopUGV"/>
<param name="teleopUGV" value="$(arg teleopUGV)"/>
<remap from="teleopUGV" to="uav_teleop_keyboard/teleopUGV"/>
</node>

</group>
Expand Down
26 changes: 25 additions & 1 deletion jsk_mbzirc_tasks/launch/jsk_mbzirc_task_3.launch
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,14 @@
<arg name="y" value="-25"/>
<arg name="z" value="0.3"/>
</include>
<!-- display uav state in rviz -->
<node pkg="jsk_mbzirc_tasks" name="uav_state_text_to_overlay" type="relay_field_728.py"
args="/$(arg uav1_name)/string_state /$(arg uav1_name)/state_overlay jsk_rviz_plugins/OverlayText
'text: m.data' --wait-for-start" />
<!-- display state in rviz -->
<node pkg="jsk_mbzirc_tasks" name="uav_ground_truth_text_to_overlay" type="relay_field_728.py"
args="/$(arg uav1_name)/string_ground_truth /$(arg uav1_name)/ground_truth_overlay jsk_rviz_plugins/OverlayText
'text: m.data' --wait-for-start" />
</group>
<group ns="$(arg uav2_name)">
<include file="$(find hector_quadrotor_gazebo)/launch/spawn_quadrotor.launch">
Expand All @@ -35,6 +43,14 @@
<arg name="y" value="-25"/>
<arg name="z" value="0.3"/>
</include>
<!-- display uav state in rviz -->
<node pkg="jsk_mbzirc_tasks" name="uav_state_text_to_overlay" type="relay_field_728.py"
args="/$(arg uav2_name)/string_state /$(arg uav2_name)/state_overlay jsk_rviz_plugins/OverlayText
'text: m.data' --wait-for-start" />
<!-- display state in rviz -->
<node pkg="jsk_mbzirc_tasks" name="uav_ground_truth_text_to_overlay" type="relay_field_728.py"
args="/$(arg uav2_name)/string_ground_truth /$(arg uav2_name)/ground_truth_overlay jsk_rviz_plugins/OverlayText
'text: m.data' --wait-for-start" />
</group>
<group ns="$(arg uav3_name)">
<include file="$(find hector_quadrotor_gazebo)/launch/spawn_quadrotor.launch">
Expand All @@ -45,10 +61,18 @@
<arg name="y" value="-25"/>
<arg name="z" value="0.3"/>
</include>
<!-- display uav state in rviz -->
<node pkg="jsk_mbzirc_tasks" name="uav_state_text_to_overlay" type="relay_field_728.py"
args="/$(arg uav3_name)/string_state /$(arg uav3_name)/state_overlay jsk_rviz_plugins/OverlayText
'text: m.data' --wait-for-start" />
<!-- display state in rviz -->
<node pkg="jsk_mbzirc_tasks" name="uav_ground_truth_text_to_overlay" type="relay_field_728.py"
args="/$(arg uav3_name)/string_ground_truth /$(arg uav3_name)/ground_truth_overlay jsk_rviz_plugins/OverlayText
'text: m.data' --wait-for-start" />
</group>

<!-- workaround until https://github.com/ros/ros_comm/pull/728 get released -->
<node pkg="jsk_mbzirc_tasks" name="remain_time_text_to_overlay" type="relay_field_728"
<node pkg="jsk_mbzirc_tasks" name="remain_time_text_to_overlay" type="relay_field_728.py"
args="/remaining_time /remaining_time_overlay jsk_rviz_plugins/OverlayText
'text: m.data' --wait-for-start" />

Expand Down
Loading

0 comments on commit 1e5b8dd

Please sign in to comment.