Ask Your Question

Unable to open stl file into scene in C++

asked 2020-04-29 11:43:17 -0500

BrandDebiel gravatar image

Dear All,

I am having some trouble importing an stl file into my scene. I am able to import the stl file into the scene trough the Rviz gui in the 'scene objects' tab and the part becomes visible in the Rviz 3D view. However when I try to import the file through the source code I get an error '<url> malformed'.


//Add STL object to world
ROS_INFO("Load mesh file...");
Eigen::Vector3d vectorScale(0.001, 0.001, 0.001);
moveit_msgs::CollisionObject collision_object_hBeam; = "hBeam";

std::string packagePath = ros::package::getPath("moveit_tutorials");
ROS_INFO("PackagePath: %s", packagePath.c_str());

shapes::Mesh* meshObject = shapes::createMeshFromResource(
           packagePath + "/markerTool.stl", vectorScale);

shape_msgs::Mesh mesh;
shapes::ShapeMsg meshMessage;
shapes::constructMsgFromShape(meshObject, meshMessage);    
mesh = boost::get<shape_msgs::Mesh>(meshMessage);

geometry_msgs::Pose hBeamPose;
hBeamPose.orientation.w = objectsQuaternionTransformation.w();
hBeamPose.orientation.x = objectsQuaternionTransformation.x();
hBeamPose.orientation.y = objectsQuaternionTransformation.y();
hBeamPose.orientation.z = objectsQuaternionTransformation.z();
hBeamPose.position.x = 1.0;
hBeamPose.position.y = 1.0;
hBeamPose.position.z = 1.0;


//Add objects to world
ROS_INFO_NAMED("tutorial", "Add an object into the world");

The path to the file is correct when I check it in the terminal, the error message path is the same as the path to the file:

[ INFO] [1588177076.809570135]: Load mesh file...
[ INFO] [1588177076.809648012]: PackagePath: /home/dvdv/ws_robotplatform/src/moveit_tutorials
[ERROR] [1588177076.809757275]: Error retrieving file [/home/dvdv/ws_robotplatform/src/moveit_tutorials/markerTool.stl]: <url> malformed [move_group_interface_tutorial-1] process has died [pid 20898, exit code -11, cmd /home/dvdv/ws_robotplatform/devel/lib/moveit_tutorials/move_group_interface_tutorial __name:=move_group_interface_tutorial __log:=/home/dvdv/.ros/log/f5fee402-89e5-11ea-8d3a-0800272243ce/move_group_interface_tutorial-1.log]. log file: /home/dvdv/.ros/log/f5fee402-89e5-11ea-8d3a-0800272243ce/move_group_interface_tutorial-1*.log
all processes on machine have died, roslaunch will exit
shutting down processing monitor...
... shutting down processing monitor complete

File is present:

dvdv@dvdv-ROS:~/ws_robotplatform$ cd src/moveit_tutorials/
dvdv@dvdv-ROS:~/ws_robotplatform/src/moveit_tutorials$ ls  index.rst       mark_tool_text.stl    _scripts _themes
CMakeLists.txt    doc      markerTool.stl  package.xml         rosdoc.yaml  _static dvdv@dvdv-ROS:~/ws_robotplatform/src/moveit_tutorials$ 

Something seems to go wrong with locating the file as far as I can interpreted this error message.

Does anybody have a suggestion in the right direction? Thanks in advance.

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted

answered 2020-04-29 12:07:59 -0500

gvdhoorn gravatar image

updated 2020-04-29 12:08:29 -0500

[ERROR] [1588177076.809757275]: Error retrieving file [/home/dvdv/ws_robotplatform/src/moveit_tutorials/markerTool.stl]: <url> malformed

This is indeed not a valid URL.

A path is not a URL.

It should probably be prefixed with file://. So in the end you would get:


The three consecutive forward slashes are not a typo.

edit flag offensive delete link more


Thanks for your quick reply. This helpt a lot!

BrandDebiel gravatar image BrandDebiel  ( 2020-04-30 00:48:19 -0500 )edit

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools



Asked: 2020-04-29 11:43:17 -0500

Seen: 37 times

Last updated: Apr 29