Gazebo | Ignition | Community
Ask Your Question
0

Plugin problem launching .launch

asked 2015-09-11 06:18:08 -0500

Alvaro Salcedo gravatar image

updated 2015-09-14 06:19:16 -0500

Hi Gazebo users:

I have just created a pkg following this page link text It just creates a plugin and a world with the plugin. My problem is that when I launch the .launch terminal says:

gzserver: symbol lookup error: /home/alcor/catkin_ws/devel/lib/libgazebo_light_sensor_plugin.so: undefined symbol: _ZN6gazebo20GazeboRosCameraUtilsC2Ev
[gazebo-1] process has died [pid 20107, exit code 127, cmd /home/alcor/catkin_ws/src/gazebo_ros_pkgs/gazebo_ros/scripts/gzserver --verbose -e ode /home/alcor/catkin_ws/src/gazebo_light_sensor_plugin/worlds/light.world __name:=gazebo __log:=/root/.ros/log/2a55e3fe-5872-11e5-af06-fcaa14787194/gazebo-1.log].
log file: /root/.ros/log/2a55e3fe-5872-11e5-af06-fcaa14787194/gazebo-1*.log

And Gazebo opens a black screen.

What am I doing wrong? How can I solve it?

Thanks a lot

EDIT:

LAUNCH FILE:

<launch>
 <!-- We resume the logic in empty_world.launch, changing only the name of the world to be launched -->
 <include file="$(find gazebo_ros)/launch/empty_world.launch">
 <arg name="verbose" value="true"/>
 <arg name="world_name" value="$(find gazebo_light_sensor_plugin)/worlds/light.world"/>
 <!-- more default parameters can be changed here -->
 </include>
 </launch>

.CPP FILE

#include <gazebo/common/Plugin.hh>
#include <ros/ros.h>
#include "/home/alcor/catkin_ws/src/gazebo_light_sensor_plugin/include/gazebo_light_sensor_plugin/light_sensor_plugin.h"

#include "gazebo_plugins/gazebo_ros_camera.h"

#include <string>

#include <gazebo/sensors/Sensor.hh>
#include <gazebo/sensors/CameraSensor.hh>
#include <gazebo/sensors/SensorTypes.hh>

#include <sensor_msgs/Illuminance.h>

namespace gazebo
{
 // Register this plugin with the simulator
 GZ_REGISTER_SENSOR_PLUGIN(GazeboRosLight)

 ////////////////////////////////////////////////////////////////////////////////
 // Constructor
 GazeboRosLight::GazeboRosLight():
 _nh("light_sensor_plugin"),
 _fov(6),
 _range(10)
 {
 _sensorPublisher = _nh.advertise<sensor_msgs::Illuminance>("lightSensor", 1);
 }

 ////////////////////////////////////////////////////////////////////////////////
 // Destructor
 GazeboRosLight::~GazeboRosLight()
 {
 ROS_DEBUG_STREAM_NAMED("camera","Unloaded");
 }

 void GazeboRosLight::Load(sensors::SensorPtr _parent, sdf::ElementPtr _sdf)
 {
 // Make sure the ROS node for Gazebo has already been initialized
 if (!ros::isInitialized())
 {
 ROS_FATAL_STREAM("A ROS node for Gazebo has not been initialized, unable to load plugin. "
 << "Load the Gazebo system plugin 'libgazebo_ros_api_plugin.so' in the gazebo_ros package)");
 return;
 }

 CameraPlugin::Load(_parent, _sdf);
 // copying from CameraPlugin into GazeboRosCameraUtils
 this->parentSensor_ = this->parentSensor;
 this->width_ = this->width;
 this->height_ = this->height;
 this->depth_ = this->depth;
 this->format_ = this->format;
 this->camera_ = this->camera;

 GazeboRosCameraUtils::Load(_parent, _sdf);
 }

 ////////////////////////////////////////////////////////////////////////////////
 // Update the controller
 void GazeboRosLight::OnNewFrame(const unsigned char *_image,
 unsigned int _width, unsigned int _height, unsigned int _depth,
 const std::string &_format)
 {
 static int seq=0;

 this->sensor_update_time_ = this->parentSensor_->GetLastUpdateTime();

 if (!this->parentSensor->IsActive())
 {
 if ((*this->image_connect_count_) > 0)
 // do this first so there's chance for sensor to run once after activated
 this->parentSensor->SetActive(true);
 }
 else
 {
 if ((*this->image_connect_count_) > 0)
 {
 common::Time cur_time = this->world_->GetSimTime();
 if (cur_time - this->last_update_time_ >= this->update_period_)
 {
 this->PutCameraData(_image);
 this->PublishCameraInfo();
 this->last_update_time_ = cur_time;

 sensor_msgs::Illuminance msg;
 msg.header.stamp = ros::Time::now();
 msg.header.frame_id = "";
 msg.header.seq = seq;

 int startingPix = _width * ( (int)(_height/2) - (int)( _fov/2)) - (int)(_fov/2);

 double illum = 0;
 for (int i=0; i<_fov ; ++i)
 {
 int index = startingPix + i*_width;
 for (int j=0; j<_fov ; ++j)
 illum += _image[index+j];
 }

 msg.illuminance = illum/(_fov*_fov);
 msg.variance = 0.0;

 _sensorPublisher.publish(msg);

 seq++;
 }
 }
 }
 }
}

.H FILE

#ifndef GAZEBO_ROS_LIGHT_SENSOR_HH
#define GAZEBO_ROS_LIGHT_SENSOR_HH

#include <string>

// library for processing camera data for gazebo / ros conversions
#include <gazebo/plugins ...
(more)
edit retag flag offensive close merge delete

Comments

Can you post a copy of your launch file?

scpeters gravatar imagescpeters ( 2015-09-14 00:50:07 -0500 )edit

Of course @scpeters . I have just edited the post

Alvaro Salcedo gravatar imageAlvaro Salcedo ( 2015-09-14 05:01:37 -0500 )edit

And also your plugin source code? I had this error not that long ago and it was something silly like having an old function declared in the header but not defined.

niall gravatar imageniall ( 2015-09-14 06:15:33 -0500 )edit

Yes! here you are! .cpp and .h @niall Thanks!

Alvaro Salcedo gravatar imageAlvaro Salcedo ( 2015-09-14 06:20:26 -0500 )edit

1 Answer

Sort by ยป oldest newest most voted
0

answered 2015-09-17 05:32:02 -0500

Alvaro Salcedo gravatar image

Can anybody help me? Thank you so much. I can not fix it.

edit flag offensive delete link more

Comments

I'm sorry, I can't find what you're doing wrong. Not a C++ guru myself. What helped me was follow this part of the error: "undefined symbol: _ZN6gazebo20GazeboRosCameraUtilsC2Ev". The gazebo part likely means the problem originates in that namespace, in the GazeboRosCameraUtils part with a function starting with "Ev". That's how I found my error.

niall gravatar imageniall ( 2015-09-17 16:19:57 -0500 )edit

I am checking the namespace Gazebo in gazeboroscamera and there is not any function starting with "Ev" @niall . I am desperate...

Alvaro Salcedo gravatar imageAlvaro Salcedo ( 2015-09-18 06:48:17 -0500 )edit
Login/Signup to Answer

Question Tools

Stats

Asked: 2015-09-11 06:18:08 -0500

Seen: 1,487 times

Last updated: Sep 17 '15