ROS Resources: Documentation | Support | Discussion Forum | Index | Service Status | ros @ Robotics Stack Exchange
Ask Your Question
0

trouble loading .stl as mesh into RVIZ

asked 2014-03-26 12:17:32 -0500

pnyholm gravatar image

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!

edit retag flag offensive close merge delete

Comments

1

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.

timm gravatar image timm  ( 2014-03-27 03:59:06 -0500 )edit

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?

pnyholm gravatar image pnyholm  ( 2014-03-27 12:15:10 -0500 )edit

1 Answer

Sort by ยป oldest newest most voted
0

answered 2014-06-07 16:06:57 -0500

Tanmay gravatar image

updated 2014-06-07 16:07:27 -0500

Hey pnyholm,

This is worth checking out.

It looks like the STL file needs to be contained within a package (pre-existing or something you've made - it doesn't matter). You could try configuring your launch file to include.

<param name="robot_description" textfile="$(find package_name)" /path/to/your/stl/file>
edit flag offensive delete link more

Question Tools

Stats

Asked: 2014-03-26 12:17:32 -0500

Seen: 3,190 times

Last updated: Jun 07 '14