Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

Creating a CollisionObject from a mesh in indigo

im building a c++ code to move ur5_moveit_config on rviz, andvtrying to add a mesh into rviz with a ur5_moveit_config on it. i read some previous answers and use them to build my code. i believe my problem is at my code:

moveit_msgs::CollisionObject toilet; shapes::Mesh* m = shapes::createMeshFromResource("package://home/toilet seat grubcad/toiletseat2.stl"); shape_msgs::Mesh toilet_mesh; shapes::ShapeMsg toilet_mesh_msg; shapes::constructMsgFromShape(m,toilet_mesh_msg); toilet_mesh = boost::get<shape_msgs::mesh>(toilet_mesh_msg); toilet.meshes.resize(1); toilet.meshes[0] = toilet_mesh; toilet.mesh_poses.resize(1); toilet.mesh_poses[0].position.x = 1.0; toilet.mesh_poses[0].position.y = 1.0; toilet.mesh_poses[0].position.z = 0.0; toilet.mesh_poses[0].orientation.w= 1.0; toilet.mesh_poses[0].orientation.x= 0.0; toilet.mesh_poses[0].orientation.y= 0.0; toilet.mesh_poses[0].orientation.z= 0.0; //pub_co.publish(toilet);

toilet.meshes.push_back(toilet_mesh); toilet.mesh_poses.push_back(toilet.mesh_poses[0]); toilet.operation = toilet.ADD;

std::vector<moveit_msgs::collisionobject> collision_objects;
collision_objects.push_back(toilet);

// Now, let's add the collision object into the world ROS_INFO("Add an object into the world");
planning_scene_interface.addCollisionObjects(collision_objects);

when i'm trying to "catkin_make" the program i get:

Built target move_arm_server [ 50%] Built target manipulator_gazebo_generate_messages_lisp [100%] [100%] Built target manipulator_gazebo_generate_messages_py Built target manipulator_gazebo_generate_messages_cpp [100%] Built target manipulator_gazebo_generate_messages /home/noamsalo/catkin_ws/src/project/src/move_ur5_by_me.cpp:19:19: error: ‘createMeshFromResource’ is not a member of ‘shapes’ shapes::Mesh* m = shapes::createMeshFromResource("package://home/toilet seat grubcad/toiletseat2.stl"); ^ /home/noamsalo/catkin_ws/src/project/src/move_ur5_by_me.cpp:21:1: error: ‘ShapeMsg’ in namespace ‘shapes’ does not name a type shapes::ShapeMsg toilet_mesh_msg; ^ /home/noamsalo/catkin_ws/src/project/src/move_ur5_by_me.cpp:22:30: error: expected constructor, destructor, or type conversion before ‘(’ token shapes::constructMsgFromShape(m,toilet_mesh_msg); ^ /home/noamsalo/catkin_ws/src/project/src/move_ur5_by_me.cpp:23:1: error: ‘toilet_mesh’ does not name a type toilet_mesh = boost::get<shape_msgs::mesh>(toilet_mesh_msg); ^ /home/noamsalo/catkin_ws/src/project/src/move_ur5_by_me.cpp:24:1: error: ‘toilet’ does not name a type toilet.meshes.resize(1); ^ /home/noamsalo/catkin_ws/src/project/src/move_ur5_by_me.cpp:25:1: error: ‘toilet’ does not name a type toilet.meshes[0] = toilet_mesh; ^ /home/noamsalo/catkin_ws/src/project/src/move_ur5_by_me.cpp:26:1: error: ‘toilet’ does not name a type toilet.mesh_poses.resize(1); ^ /home/noamsalo/catkin_ws/src/project/src/move_ur5_by_me.cpp:27:1: error: ‘toilet’ does not name a type toilet.mesh_poses[0].position.x = 1.0; ^ /home/noamsalo/catkin_ws/src/project/src/move_ur5_by_me.cpp:28:1: error: ‘toilet’ does not name a type toilet.mesh_poses[0].position.y = 1.0; ^ /home/noamsalo/catkin_ws/src/project/src/move_ur5_by_me.cpp:29:1: error: ‘toilet’ does not name a type toilet.mesh_poses[0].position.z = 0.0; ^ /home/noamsalo/catkin_ws/src/project/src/move_ur5_by_me.cpp:30:1: error: ‘toilet’ does not name a type toilet.mesh_poses[0].orientation.w= 1.0; ^ /home/noamsalo/catkin_ws/src/project/src/move_ur5_by_me.cpp:31:1: error: ‘toilet’ does not name a type toilet.mesh_poses[0].orientation.x= 0.0; ^ /home/noamsalo/catkin_ws/src/project/src/move_ur5_by_me.cpp:32:1: error: ‘toilet’ does not name a type toilet.mesh_poses[0].orientation.y= 0.0; ^ /home/noamsalo/catkin_ws/src/project/src/move_ur5_by_me.cpp:33:1: error: ‘toilet’ does not name a type toilet.mesh_poses[0].orientation.z= 0.0; ^ /home/noamsalo/catkin_ws/src/project/src/move_ur5_by_me.cpp:36:1: error: ‘toilet’ does not name a type toilet.meshes.push_back(toilet_mesh); ^ /home/noamsalo/catkin_ws/src/project/src/move_ur5_by_me.cpp:37:1: error: ‘toilet’ does not name a type toilet.mesh_poses.push_back(toilet.mesh_poses[0]); ^ /home/noamsalo/catkin_ws/src/project/src/move_ur5_by_me.cpp:38:1: error: ‘toilet’ does not name a type toilet.operation = toilet.ADD; ^ /home/noamsalo/catkin_ws/src/project/src/move_ur5_by_me.cpp:41:1: error: ‘collision_objects’ does not name a type collision_objects.push_back(toilet);
^ In file included from /opt/ros/indigo/include/tf/transform_datatypes.h:44:0, from /opt/ros/indigo/include/tf/time_cache.h:38, from /opt/ros/indigo/include/tf/tf.h:43, from /opt/ros/indigo/include/moveit/move_group_interface/move_group.h:50, from /home/noamsalo/catkin_ws/src/project/src/move_ur5_by_me.cpp:1: /opt/ros/indigo/include/ros/console.h:369:3: error: expected unqualified-id before ‘do’ do \ ^ /opt/ros/indigo/include/ros/console.h:557:35: note: in expansion of macro ‘ROS_LOG_COND’ #define ROS_LOG(level, name, ...) ROS_LOG_COND(true, level, name, __VA_ARGS__) ^ /opt/ros/indigo/include/rosconsole/macros_generated.h:110:23: note: in expansion of macro ‘ROS_LOG’ #define ROS_INFO(...) ROS_LOG(::ros::console::levels::Info, ROSCONSOLE_DEFAULT_NAME, __VA_ARGS__) ^ /home/noamsalo/catkin_ws/src/project/src/move_ur5_by_me.cpp:44:1: note: in expansion of macro ‘ROS_INFO’ ROS_INFO("Add an object into the world");
^ make[2]: * [project/CMakeFiles/move_ur5_by_me.dir/src/move_ur5_by_me.cpp.o] Error 1 make[1]: [project/CMakeFiles/move_ur5_by_me.dir/all] Error 2 make: ** [all] Error 2

Heading

Creating a CollisionObject from a mesh in indigo

im building a c++ code to move ur5_moveit_config on rviz, andvtrying to add a mesh into rviz with a ur5_moveit_config on it. i read some previous answers and use them to build my code. i believe my problem is at my code:

moveit_msgs::CollisionObject toilet;
shapes::Mesh* m = shapes::createMeshFromResource("package://home/toilet seat grubcad/toiletseat2.stl");
shape_msgs::Mesh toilet_mesh;
shapes::ShapeMsg toilet_mesh_msg;
shapes::constructMsgFromShape(m,toilet_mesh_msg);
toilet_mesh = boost::get<shape_msgs::mesh>(toilet_mesh_msg);
boost::get<shape_msgs::Mesh>(toilet_mesh_msg);
toilet.meshes.resize(1);
toilet.meshes[0] = toilet_mesh;
toilet.mesh_poses.resize(1);
toilet.mesh_poses[0].position.x = 1.0;
toilet.mesh_poses[0].position.y = 1.0;
toilet.mesh_poses[0].position.z = 0.0;
toilet.mesh_poses[0].orientation.w= 1.0;
toilet.mesh_poses[0].orientation.x= 0.0;
toilet.mesh_poses[0].orientation.y= 0.0;
toilet.mesh_poses[0].orientation.z= 0.0;
//pub_co.publish(toilet);

//pub_co.publish(toilet); toilet.meshes.push_back(toilet_mesh); toilet.mesh_poses.push_back(toilet.mesh_poses[0]); toilet.operation = toilet.ADD;

std::vector<moveit_msgs::collisionobject> toilet.ADD; std::vector<moveit_msgs::CollisionObject> collision_objects;
collision_objects.push_back(toilet);

// Now, let's add the collision object into the world ROS_INFO("Add an object into the world");
planning_scene_interface.addCollisionObjects(collision_objects);

planning_scene_interface.addCollisionObjects(collision_objects);

when i'm trying to "catkin_make" the program i get:

Built target move_arm_server
[ 50%] Built target manipulator_gazebo_generate_messages_lisp
[100%] [100%] Built target manipulator_gazebo_generate_messages_py
Built target manipulator_gazebo_generate_messages_cpp
[100%] Built target manipulator_gazebo_generate_messages
/home/noamsalo/catkin_ws/src/project/src/move_ur5_by_me.cpp:19:19: error: ‘createMeshFromResource’ is not a member of ‘shapes’
 shapes::Mesh* m = shapes::createMeshFromResource("package://home/toilet seat grubcad/toiletseat2.stl");
                   ^
/home/noamsalo/catkin_ws/src/project/src/move_ur5_by_me.cpp:21:1: error: ‘ShapeMsg’ in namespace ‘shapes’ does not name a type
 shapes::ShapeMsg toilet_mesh_msg;
 ^
/home/noamsalo/catkin_ws/src/project/src/move_ur5_by_me.cpp:22:30: error: expected constructor, destructor, or type conversion before ‘(’ token
 shapes::constructMsgFromShape(m,toilet_mesh_msg);
                              ^
/home/noamsalo/catkin_ws/src/project/src/move_ur5_by_me.cpp:23:1: error: ‘toilet_mesh’ does not name a type
 toilet_mesh = boost::get<shape_msgs::mesh>(toilet_mesh_msg);
boost::get<shape_msgs::Mesh>(toilet_mesh_msg);
 ^
/home/noamsalo/catkin_ws/src/project/src/move_ur5_by_me.cpp:24:1: error: ‘toilet’ does not name a type
 toilet.meshes.resize(1);
 ^
/home/noamsalo/catkin_ws/src/project/src/move_ur5_by_me.cpp:25:1: error: ‘toilet’ does not name a type
 toilet.meshes[0] = toilet_mesh;
 ^
/home/noamsalo/catkin_ws/src/project/src/move_ur5_by_me.cpp:26:1: error: ‘toilet’ does not name a type
 toilet.mesh_poses.resize(1);
 ^
/home/noamsalo/catkin_ws/src/project/src/move_ur5_by_me.cpp:27:1: error: ‘toilet’ does not name a type
 toilet.mesh_poses[0].position.x = 1.0;
 ^
/home/noamsalo/catkin_ws/src/project/src/move_ur5_by_me.cpp:28:1: error: ‘toilet’ does not name a type
 toilet.mesh_poses[0].position.y = 1.0;
 ^
/home/noamsalo/catkin_ws/src/project/src/move_ur5_by_me.cpp:29:1: error: ‘toilet’ does not name a type
 toilet.mesh_poses[0].position.z = 0.0;
 ^
/home/noamsalo/catkin_ws/src/project/src/move_ur5_by_me.cpp:30:1: error: ‘toilet’ does not name a type
 toilet.mesh_poses[0].orientation.w= 1.0;
 ^
/home/noamsalo/catkin_ws/src/project/src/move_ur5_by_me.cpp:31:1: error: ‘toilet’ does not name a type
 toilet.mesh_poses[0].orientation.x= 0.0;
 ^
/home/noamsalo/catkin_ws/src/project/src/move_ur5_by_me.cpp:32:1: error: ‘toilet’ does not name a type
 toilet.mesh_poses[0].orientation.y= 0.0;
 ^
/home/noamsalo/catkin_ws/src/project/src/move_ur5_by_me.cpp:33:1: error: ‘toilet’ does not name a type
 toilet.mesh_poses[0].orientation.z= 0.0;
 ^
/home/noamsalo/catkin_ws/src/project/src/move_ur5_by_me.cpp:36:1: error: ‘toilet’ does not name a type
 toilet.meshes.push_back(toilet_mesh);
 ^
/home/noamsalo/catkin_ws/src/project/src/move_ur5_by_me.cpp:37:1: error: ‘toilet’ does not name a type
 toilet.mesh_poses.push_back(toilet.mesh_poses[0]);
 ^
/home/noamsalo/catkin_ws/src/project/src/move_ur5_by_me.cpp:38:1: error: ‘toilet’ does not name a type
 toilet.operation = toilet.ADD;
 ^
/home/noamsalo/catkin_ws/src/project/src/move_ur5_by_me.cpp:41:1: error: ‘collision_objects’ does not name a type
 collision_objects.push_back(toilet); 
^ In file included from /opt/ros/indigo/include/tf/transform_datatypes.h:44:0, from /opt/ros/indigo/include/tf/time_cache.h:38, from /opt/ros/indigo/include/tf/tf.h:43, from /opt/ros/indigo/include/moveit/move_group_interface/move_group.h:50, from /home/noamsalo/catkin_ws/src/project/src/move_ur5_by_me.cpp:1: /opt/ros/indigo/include/ros/console.h:369:3: error: expected unqualified-id before ‘do’ do \ ^ /opt/ros/indigo/include/ros/console.h:557:35: note: in expansion of macro ‘ROS_LOG_COND’ #define ROS_LOG(level, name, ...) ROS_LOG_COND(true, level, name, __VA_ARGS__) ^ /opt/ros/indigo/include/rosconsole/macros_generated.h:110:23: note: in expansion of macro ‘ROS_LOG’ #define ROS_INFO(...) ROS_LOG(::ros::console::levels::Info, ROSCONSOLE_DEFAULT_NAME, __VA_ARGS__) ^ /home/noamsalo/catkin_ws/src/project/src/move_ur5_by_me.cpp:44:1: note: in expansion of macro ‘ROS_INFO’ ROS_INFO("Add an object into the world");
^ make[2]: * *** [project/CMakeFiles/move_ur5_by_me.dir/src/move_ur5_by_me.cpp.o] Error 1 make[1]: *** [project/CMakeFiles/move_ur5_by_me.dir/all] Error 2 make: ** *** [all] Error 2

Heading

2