Open Luckykantnayak opened 2 years ago
Looks like the gazebo_ros camera plugin is missing a header that should be included.
As a workaround in your plugin, you can try including the missing the rclcpp header(s) before including gazebo_ros_camera.hpp
. E.g. #include "rclcpp/rclcpp.hpp"
I've proposed a fix in https://github.com/ros-simulation/gazebo_ros_pkgs/pull/1408
Bug report
Required Info:
Operating System:Ubuntu 20.04
Installation type: ROS2 Foxy, Gazebo Classic
Client library (if applicable):rclcpp
packages required : gazebo_plugins
Trying to convert this Gazebo plugin written in ROS1 into ROS2
Steps to reproduce issue
light_sensor_plugin.hpp
include "gazebo_light_sensor/visibility_control.h"
include <gazebo_plugins/gazebo_ros_camera.hpp>
include
include <rclcpp/rclcpp.hpp>
include <sensor_msgs/msg/illuminance.hpp>
namespace gazebo {
class LightSensorPlugin : public gazebo_plugins::GazeboRosCamera { public: LightSensorPlugin();
};
} // namespace gazebo_light_sensor
endif // GAZEBO_LIGHT_SENSOR__LIGHT_SENSOR_PLUGINHPP
include "gazebo_light_sensor/light_sensor_plugin.hpp"
include <gazebo/common/Plugin.hh>
include
include <gazebo/sensors/Sensor.hh>
include <gazebo/sensors/CameraSensor.hh>
include <gazebo/sensors/SensorTypes.hh>
include <sensor_msgs/msg/illuminance.hpp>
namespace gazebo { //GZ_REGISTER_SENSOR_PLUGIN(LightSensorPlugin) LightSensorPlugin::LightSensorPlugin() :_fov(6),_range(10) {
}
LightSensorPlugin::~LightSensorPlugin() { RCLCPP_DEBUG_STREAM(rosnode->get_logger(), "Camera unloaded"); } void LightSensorPlugin::Load(gazebo::sensors::SensorPtr _parent, sdf::ElementPtr _sdf) { gazebo_plugins::GazeboRosCamera::Load(_parent,_sdf); if(!rclcpp::ok()) { RCLCPP_FATAL_STREAM(rosnode->get_logger(),"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; }
sensorpub = rosnode->create_publisher("lightSensor",1);
} void LightSensorPlugin::OnNewFrame(const unsigned char *_image, unsigned int _width, unsigned int _height, unsigned int _depth, const std::string &_format) {
}
} // namespace gazebo_light_sensor