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

Ros Jade Osx - compiler error robot_state_publisher

asked 2017-10-06 09:37:56 -0600

Twista3579 gravatar image

Hi @all

i would like to install ros jade on osx. i know that is in experimental state but there's no other way.

in package robot_state_publisher an error is generated.

[ 71%] Building CXX object CMakeFiles/robot_state_publisher.dir/src/joint_state_listener.cpp.o

/Users/blubb/ros_catkin_ws/src/robot_state_publisher/src/joint_state_listener.cpp:165:74: error: no viable conversion from '__map_iterator<__tree_iterator<__value_type<[...],
      std::__1::shared_ptr<urdf::Joint>>, std::__1::__tree_node<std::__1::__value_type<std::__1::basic_string<char>, std::__1::shared_ptr<urdf::Joint> >, void *> *, [...]>>' to
      '__map_iterator<__tree_iterator<__value_type<[...], boost::shared_ptr<urdf::Joint>>, std::__1::__tree_node<std::__1::__value_type<std::__1::basic_string<char>,
      boost::shared_ptr<urdf::Joint> >, void *> *, [...]>>'
 for(std::map< std::string, boost::shared_ptr< urdf::Joint > >::iterator i = model.joints_.begin(); i != model.joints_.end(); i++){

if i comment out the following lines in file ros_catkin_ws/src/robot_state_publisher/src/joint_state_listener.cpp all package are compiled successful

In main function:

for(std::map< std::string, boost::shared_ptr< urdf::Joint > >::iterator i = model.joints_.begin(); i != model.joints_.end(); i++){
    if(i->second->mimic){

      mimic.insert(make_pair(i->first, i->second->mimic));
    }
  }

its looks like the compiler can´t cast std::shared_ptr to boost::shared_ptr. On my laptop i have a working version of ROS indigo and the file looks the same and it works.

Can anybody help me?

Thanks

edit retag flag offensive close merge delete

1 Answer

Sort by » oldest newest most voted
0

answered 2017-10-15 06:53:10 -0600

IsaacT gravatar image

I had the exact same problem on Gentoo when compiling Indigo. I managed to fix it with the following changes:

--- a/joint_state_listener.cpp  2017-10-15 13:50:04.198605688 +0200
+++ b/joint_state_listener.cpp  2017-10-15 13:50:41.560552892 +0200
@@ -131,6 +131,12 @@
       last_publish_time_[state->name[i]] = state->header.stamp;
   }
 }
+// From: https://stackoverflow.com/a/12315035
+template<typename T>
+boost::shared_ptr<T> make_shared_ptr(std::shared_ptr<T>& ptr)
+{
+    return boost::shared_ptr<T>(ptr.get(), [ptr](T*) mutable {ptr.reset();});
+}

 // ----------------------------------
 // ----- MAIN -----------------------
@@ -161,9 +167,9 @@

   MimicMap mimic;

-  for(std::map< std::string, boost::shared_ptr< urdf::Joint > >::iterator i = model.joints_.begin(); i != model.joints_.end(); i++){
+  for(auto i = model.joints_.begin(); i != model.joints_.end(); i++){
     if(i->second->mimic){
-      mimic.insert(make_pair(i->first, i->second->mimic));
+      mimic.insert(make_pair(i->first, make_shared_ptr<urdf::JointMimic>(i->second->mimic)));
     }
   }

I'm not sure if this'll break anything or introduce memory leaks, but it compiles.

edit flag offensive delete link more

Question Tools

1 follower

Stats

Asked: 2017-10-06 09:37:56 -0600

Seen: 206 times

Last updated: Oct 06 '17