Rviz or package not functioning
Hello all,
I am using a Raspberry Pi 3, lubuntu 16.04, ROS Kinetic, a Tim561 Lidar and the package sick_scan. I am able to get sick_scan to run correctly and publish data to the topic cloud. I am using rviz to make sure.
I am now trying to follow this tutorial in order to down sample the pointcloud2 data. I am however having some issues. I believe I followed the steps correctly, however when I try to visualize the data in rviz nothing shows up. In addition, when I run rostopic echo output
nothing appears. I would also add that on the tutorial it says to select the fixed frame as "camera_depth_frame" however this option does not appear for me(in fact no options appear). I have tried typing it in but rviz continues being blank.
Could this be an issue with the fixed frame selection or rather with my code (which I will paste below)?
Thanks.
example.cpp
#include <ros/ros.h>
// PCL specific includes
#include <sensor_msgs/PointCloud2.h>
#include <pcl_conversions/pcl_conversions.h>
#include <pcl/point_cloud.h>
#include <pcl/point_types.h>
#include <pcl/filters/voxel_grid.h>
ros::Publisher pub;
void
cloud_cb (const sensor_msgs::PointCloud2ConstPtr& cloud_msg)
{
// Container for original & filtered data
pcl::PCLPointCloud2* cloud = new pcl::PCLPointCloud2;
pcl::PCLPointCloud2ConstPtr cloudPtr(cloud);
pcl::PCLPointCloud2 cloud_filtered;
// Convert to PCL data type
pcl_conversions::toPCL(*cloud_msg, *cloud);
// Perform the actual filtering
pcl::VoxelGrid<pcl::PCLPointCloud2> sor;
sor.setInputCloud (cloudPtr);
sor.setLeafSize (0.1, 0.1, 0.1);
sor.filter (cloud_filtered);
// Convert to ROS data type
sensor_msgs::PointCloud2 output;
pcl_conversions::moveFromPCL(cloud_filtered, output);
// Publish the data
pub.publish (output);
}
int
main (int argc, char** argv)
{
// Initialize ROS
ros::init (argc, argv, "my_pcl_tutorial");
ros::NodeHandle nh;
// Create a ROS subscriber for the input point cloud
ros::Subscriber sub = nh.subscribe ("input", 1, cloud_cb);
// Create a ROS publisher for the output point cloud
pub = nh.advertise<sensor_msgs::PointCloud2> ("output", 1);
// Spin
ros::spin ();
}
package.xml
<?xml version="1.0"?>
<package format="2">
<name>my_pcl_tutorial</name>
<version>0.0.0</version>
<description>The my_pcl_tutorial package</description>
<maintainer email="ubuntu@todo.todo">ubuntu</maintainer>
<license>TODO</license>
<buildtool_depend>catkin</buildtool_depend>
<build_depend>pcl_conversions</build_depend>
<build_depend>pcl_ros</build_depend>
<build_depend>roscpp</build_depend>
<build_depend>sensor_msgs</build_depend>
<build_export_depend>pcl_conversions</build_export_depend>
<build_export_depend>pcl_ros</build_export_depend>
<build_export_depend>roscpp</build_export_depend>
<build_export_depend>sensor_msgs</build_export_depend>
<exec_depend>pcl_conversions</exec_depend>
<exec_depend>pcl_ros</exec_depend>
<exec_depend>roscpp</exec_depend>
<exec_depend>sensor_msgs</exec_depend>
<build_depend>libpcl-all-dev</build_depend>
<exec_depend>libpcl-all</exec_depend>
<export>
</export>
</package>
CMakeLists.txt
cmake_minimum_required(VERSION 2.8.3)
project(my_pcl_tutorial)
find_package(catkin REQUIRED COMPONENTS
pcl_conversions
pcl_ros
roscpp
sensor_msgs
)
catkin_package()
include_directories(${catkin_INCLUDE_DIRS})
add_executable(example src/example.cpp)
target_link_libraries(example ${catkin_LIBRARIES})
I shortened your question significantly by removing the comments in your CMakeLists.txt and package.xml files.
Ah ok thank you! Any idea on how to solve my issue?