You must call ros::init() before creating the first NodeHandle
Hi all,
I got some strange and annoying problems after installing Gazebo 1.9 from source to be able to compile the gazebo_ros_pkgs.
I followed the installation instructions as shown in Installing_gazebo_ros_Packages and Compiling_From_Source. At this time the link pointing to the compiling_from_source of version 1.6. wasn't crossed out.
After the installation I was able to compile the gazebo_ros_pkgs in my catkin folder. But I got problems starting my models in Gazebo due to some ROS problems, saying something like:
"Not loading plugin since ROS hasn't been properly initialized".
I wasn't able to fix that. But because I achieved to compile the plugin package I went back to Gazebo 1.8.6 and ROS 1.9.45. Therefore I completely uninstalled all the old Gazebo and ROS versions.
What happens now is - when I try to start my models in Gazebo, using some self made plugins, I got the following error message:
file = /tmp/buildd/ros-groovy-roscpp-1.9.44-0precise-20130325-1240/src/libros/node_handle.cpp
line=151
I got two plugins and both of them worked fine before I made the previously mentioned changes.
The strange thing is, this error message appears only with one of the plugins. And they both initialize ros in the same way.
public: void Load(physics::ModelPtr _parent, sdf::ElementPtr _sdf)
{
// Start up ROS
std::string name = "scitos_gazebo_platform_control";
int argc = 0;
ros::init(argc, NULL, name);
// ROS Nodehandle
this->my_rosnode = new ros::NodeHandle("~");
...
When I try to comment the rosnode or to get an message to the console by only using std::cout the error message stay the same.
Thank you for your help.
Christoph
The Code you posted here does not seem to be the Problem!
btw. std::cout does not pipe the message directly to the console(it is buffered first). If you want to use an console output for debuging use std::err. this is the same for all C/C++ apllications.
The Code you posted here does not seem to be the Problem!
btw. std::cout does not pipe the message directly to the console(it is buffered first). If you want to use an console output for debuging use std::err. this is the same for all C/C++ apllications.
you seem to have two questions here... 1) properly installing and running gazebo and 2) fixing your custom plugin. it would be easier if we had 1 question per topic. for 1) how are you starting gazebo?
@evilBiber: I used std:err during my problem analysis, but that didn't give me an output either. Thanks for the information about the operation principles of std::cout though. @davetcoleman: before I tried Gazebo 1.9. everything worked fine for me. At some point I installed DRCSim too, to get the laser plugin. I start Gazebo from the console typing "gazebo" and then insert my model from the gui.