0
$\begingroup$

Rosanswers logo

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 ' 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/
<font color="#8AE234"><b>dvdv@dvdv-ROS</b></font>:<font color="#729FCF"><b>~/ws_robotplatform/src/moveit_tutorials</b></font>$ 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.


Originally posted by BrandDebiel on ROS Answers with karma: 47 on 2020-04-29

Post score: 0

$\endgroup$

1 Answer 1

0
$\begingroup$

Rosanswers logo

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


Originally posted by gvdhoorn with karma: 86574 on 2020-04-29

This answer was ACCEPTED on the original site

Post score: 2


Original comments

Comment by BrandDebiel on 2020-04-30:
Thanks for your quick reply. This helpt a lot!

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.