trouble loading .stl as mesh into RVIZ
I'm trying to load a .stl file as a mesh in RVIZ and having problems seeing anything. I have tweaked the rviz marker tutorial(http://wiki.ros.org/rviz/Tutorials/Markers%3A%20Basic%20Shapes) to attempt to display a binary .stl file from a local directory (~/catkin_ws/src/my_package/stl/mesh.stl). My code looks like this:
#include <ros/ros.h>
#include <visualization_msgs/Marker.h>
int main( int argc, char** argv )
{
ros::init(argc, argv, "basic_shapes");
ros::NodeHandle n;
ros::Rate r(1);
ros::Publisher marker_pub = n.advertise<visualization_msgs::Marker>("visualization_marker", 1);
while (ros::ok())
{
visualization_msgs::Marker marker;
// Set the frame ID and timestamp. See the TF tutorials for information on these.
marker.header.frame_id = "/my_frame";
marker.header.stamp = ros::Time::now();
// Set the namespace and id for this marker. This serves to create a unique ID
// Any marker sent with the same namespace and id will overwrite the old one
marker.ns = "basic_shapes";
marker.id = 0;
// Set the marker type
marker.type = visualization_msgs::Marker::MESH_RESOURCE;
// Set the marker action. Options are ADD and DELETE
marker.action = visualization_msgs::Marker::ADD;
// Set the pose of the marker. This is a full 6DOF pose relative to the frame/time specified in the header
marker.pose.position.x = 0;
marker.pose.position.y = 0;
marker.pose.position.z = 0;
marker.pose.orientation.x = 0.0;
marker.pose.orientation.y = 0.0;
marker.pose.orientation.z = 0.0;
marker.pose.orientation.w = 1.0;
// Set the scale of the marker -- 1x1x1 here means 1m on a side
marker.scale.x = 1.0;
marker.scale.y = 1.0;
marker.scale.z = 1.0;
// Set the color -- be sure to set alpha to something non-zero!
marker.color.r = 0.0f;
marker.color.g = 1.0f;
marker.color.b = 0.0f;
marker.color.a = 1.0;
marker.lifetime = ros::Duration();
// Publish the marker
marker.mesh_resource = "package://my_package/stl/mesh.stl";
marker_pub.publish(marker);
r.sleep();
}
}
I'm pretty sure the line marker.mesh_resource = "package://my_package/stl/mesh.stl"; is my problem. Any help is greatly appreciated!
Thanks!
Is RViz showing any error messages in the Marker display status? Have you set your fixed frame in RViz to "/my_frame"? Maybe also try to play around with the marker.mesh_use_embedded_materials flag, and if possible, try a DAE file instead of STL.
Great suggestion using a DAE instead of STL file. I got it to work with some sample DAE files I pulled from the internet. With the same setup that I have working for the DAE file, when I simply replace the DAE with the STL I get a seg fault. I guess now I have a bit of work to do converting my STL file to a DAE file. Any simple suggestions for that?