Code Monkey home page Code Monkey logo

ros_viz_tools's Introduction

ros_viz_tools

This package is a visualization tool for easier Rviz marker plotting.

Dependencies

  • Tested on Ubuntu 16.04 LTS & ROS kinetic
  • tf2_geometry_msgs

Quick Start

Build this package under your catkin workspace, run demo node and Rviz (frame: ros_viz_tools, topic: demo_marker) for a quick look:

roslaunch ros_viz_tools demo_node.launch

demo

Currently support:

  • Cube list
  • Sphere list
  • Line Strip
  • Line List
  • Cylinder
  • Cube
  • Sphere
  • Arrow
  • Text
  • Frame (Axes-type Pose)

Usage

Set catkin package dependencies in your CMakeLists.txt and package.xml,

# CMakeLists.txt
find_package(catkin REQUIRED COMPONENTS
  ...
  ros_viz_tools
)
<!-- package.xml -->
<?xml version="1.0"?>
<package format="2">
  ...  
  <depend>ros_viz_tools</depend>
  ...
</package>

Include the header file in your codes,

#include "ros_viz_tools/ros_viz_tools.h"

Markers

Initialize a RosVizTools instance named markers,

ros::NodeHandle n;
std::string topic = "demo_marker";
ros_viz_tools::RosVizTools markers(n, topic);

Create a new marker and append it to markers. Let's take cube list marker for example.

// set marker frame id, namespace and id
std::string frame_id = "ros_viz_tools";
std::string ns = "cube_list";
int id = 0;

You can initialize a new marker by two approaches:

// intialize new marker by calling static member function in RosVizTools directly (recommended)
visualization_msgs::Marker marker = ros_viz_tools::RosVizTools::newCubeList(0.5, ns, id, ros_viz_tools::WHITE, frame_id);
// or by accessing the function through the instance
visualization_msgs::Marker marker = markers.newCubeList(0.5, ns, id, ros_viz_tools::WHITE, frame_id);

If the new marker involves a list (cube list, sphere list, line list or line strip), you also need to set a point list.

// modify marker, cube list, for example, also needs a point list.
for (int i = 0; i < 10; ++i) {
    geometry_msgs::Point p;
    p.x = i;
    p.y = pow(p.x, 2.0);
    p.z = 1.0;
    marker.points.push_back(p);
    std_msgs::ColorRGBA color = ros_viz_tools::newColorRGBA(randRGB(e), randRGB(e), randRGB(e));
    marker.colors.push_back(color);
}

Append new marker to RosVizTools instance markers:

// append to markers
markers.append(marker);

At the end, call publish() function.

markers.publish();

Then you can open Rviz and see the markers published in the frame ros_viz_tools and topic demo_marker. Don't forget clear your markers at the beginning of every loop:

markers.clear();

You can see demo_node.cpp for better understanding of the usage for each marker type.

Colors

To support colorful marker plotting, ros_viz_tools also defines functions and class for easier color settings. Now there are two approaches supported for generating colors:

  • function newColorRGBA (also with some pre-defined colors in color.h) or
  • class ColorMap (See demo_node.cpp for examples)

License

This repository licensed under the MIT License.

ros_viz_tools's People

Contributors

magic-wei avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

ros_viz_tools's Issues

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.