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

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'.

Source:

//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;
collision_object_hBeam.id = "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);

objectsQuaternionTransformation.setRPY(0,0,0);
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;

collision_object_hBeam.meshes.push_back(mesh);
collision_object_hBeam.mesh_poses.push_back(hBeamPose);
collision_objects.push_back(collision_object_hBeam);

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

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
done 

File is present:

dvdv@dvdv-ROS:~/ws_robotplatform$ cd src/moveit_tutorials/
dvdv@dvdv-ROS:~/ws_robotplatform/src/moveit_tutorials$ ls
build_locally.sh  conf.py  index.rst       mark_tool_text.stl  README.md    _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
2

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:

file:///home/dvdv/ws_robotplatform/src/moveit_tutorials/markerTool.stl

The three consecutive forward slashes are not a typo.

edit flag offensive delete link more

Comments

Thanks for your quick reply. This helpt a lot!

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

Question Tools

2 followers

Stats

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

Seen: 1,019 times

Last updated: Apr 29 '20