arrow not showing in rviz
I was trying to display an arrow inside rviz by using below code:
#include <ros/ros.h>
#include <visualization_msgs/Marker.h>
#include <cmath>
int main( int argc, char** argv )
{
ros::init(argc, argv, "lines");
ros::NodeHandle n;
ros::Rate r(1);
ros::Publisher marker_pub = n.advertise<visualization_msgs::Marker>("lines", 10);
while (ros::ok())
{
visualization_msgs::Marker arrow;
arrow.header.frame_id = "/camera_depth_frame";
arrow.header.stamp = ros::Time::now();
arrow.ns = "lines";
arrow.id = 1;
arrow.type = visualization_msgs::Marker::ARROW;
arrow.action = visualization_msgs::Marker::ADD;
arrow.pose.position.x = 1;
arrow.pose.position.y = 1;
arrow.pose.position.z = 1;
arrow.pose.orientation.x = 0.0;
arrow.pose.orientation.y = 0.0;
arrow.pose.orientation.z = 0.0;
arrow.pose.orientation.w = 1.0;
arrow.scale.x=1.0;
arrow.scale.y=1.0;
arrow.scale.z = 1.0;
arrow.color.g = 1.0f;
arrow.color.a = 1.0;
arrow.color.r = 0.0f;
arrow.color.b = 0.0f;
arrow.lifetime = ros::Duration();
while (marker_pub.getNumSubscribers() < 1)
{
if (!ros::ok())
{
return 0;
}
ROS_WARN_ONCE("Please create a subscriber to the marker");
sleep(1);
}
marker_pub.publish(arrow);
r.sleep();
}
}
but when i run rviz, what i'm seeing is a cylinder with a circle at the bottom. i'm not getting arrow marker. As i saw in tutorial code display shpae
in this page also same shape comes in the name of arrow but what i want was an arrow line,vector with fixed position and direction no some shpae,my CmakeLists.txt is:
cmake_minimum_required(VERSION 2.8.3)
project(using_markers)
find_package(catkin REQUIRED COMPONENTS roscpp visualization_msgs)
catkin_package()
include_directories(${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})
add_executable(lines src/lines.cpp)
target_link_libraries(lines ${catkin_LIBRARIES})
Im using ros indigo. shouldn't i get a vector or line segment when i use arrow marker, i dont understand it.