Added camera component
This commit is contained in:
parent
1177140a0c
commit
209e99a4b3
9 changed files with 168 additions and 8 deletions
68
env_components/camera_component/CMakeLists.txt
Normal file
68
env_components/camera_component/CMakeLists.txt
Normal file
|
@ -0,0 +1,68 @@
|
||||||
|
cmake_minimum_required(VERSION 3.5)
|
||||||
|
project(camera_component)
|
||||||
|
|
||||||
|
if(NOT CMAKE_C_STANDARD)
|
||||||
|
set(CMAKE_C_STANDARD 99)
|
||||||
|
endif()
|
||||||
|
|
||||||
|
if(NOT CMAKE_CXX_STANDARD)
|
||||||
|
set(CMAKE_CXX_STANDARD 17)
|
||||||
|
endif()
|
||||||
|
|
||||||
|
set(CMAKE_CXX_STANDARD_REQUIRED True)
|
||||||
|
|
||||||
|
if(CMAKE_COMPILER_IS_GNUCXX OR CMAKE_CXX_COMPILER_ID MATCHES "Clang")
|
||||||
|
add_compile_options(-Wall -Wextra -Wpedantic)
|
||||||
|
endif()
|
||||||
|
|
||||||
|
find_package(ament_cmake REQUIRED)
|
||||||
|
find_package(ament_cmake_ros REQUIRED)
|
||||||
|
find_package(image_transport REQUIRED)
|
||||||
|
find_package(ros_gz_bridge REQUIRED)
|
||||||
|
find_package(rclcpp REQUIRED)
|
||||||
|
find_package(rclcpp_components REQUIRED)
|
||||||
|
find_package(sensor_msgs REQUIRED)
|
||||||
|
find_package(env_manager REQUIRED)
|
||||||
|
|
||||||
|
find_package(ignition-transport11 REQUIRED)
|
||||||
|
set(GZ_TRANSPORT_VER ${ignition-transport11_VERSION_MAJOR})
|
||||||
|
|
||||||
|
find_package(ignition-msgs8 REQUIRED)
|
||||||
|
set(GZ_MSGS_VER ${ignition-msgs8_VERSION_MAJOR})
|
||||||
|
|
||||||
|
set(GZ_TARGET_PREFIX ignition)
|
||||||
|
|
||||||
|
add_library(ign_camera_component SHARED
|
||||||
|
src/ign_camera_component.cpp)
|
||||||
|
target_compile_definitions(ign_camera_component
|
||||||
|
PRIVATE "COMPOSITION_BUILDING_DLL")
|
||||||
|
target_link_libraries(ign_camera_component
|
||||||
|
${GZ_TARGET_PREFIX}-msgs${GZ_MSGS_VER}::core
|
||||||
|
${GZ_TARGET_PREFIX}-transport${GZ_TRANSPORT_VER}::core
|
||||||
|
)
|
||||||
|
ament_target_dependencies(ign_camera_component
|
||||||
|
"image_transport"
|
||||||
|
"ros_gz_bridge"
|
||||||
|
"rclcpp"
|
||||||
|
"rclcpp_components"
|
||||||
|
"sensor_msgs"
|
||||||
|
"env_manager")
|
||||||
|
rclcpp_components_register_nodes(ign_camera_component "camera_component::IgnCameraComponent")
|
||||||
|
set(node_plugins "${node_plugins}camera_component::IgnCameraComponent;$<TARGET_FILE:camera_component>\n")
|
||||||
|
|
||||||
|
install(TARGETS ign_camera_component
|
||||||
|
DESTINATION lib)
|
||||||
|
|
||||||
|
if(BUILD_TESTING)
|
||||||
|
find_package(ament_lint_auto REQUIRED)
|
||||||
|
# the following line skips the linter which checks for copyrights
|
||||||
|
# comment the line when a copyright and license is added to all source files
|
||||||
|
set(ament_cmake_copyright_FOUND TRUE)
|
||||||
|
# the following line skips cpplint (only works in a git repo)
|
||||||
|
# comment the line when this package is in a git repo and when
|
||||||
|
# a copyright and license is added to all source files
|
||||||
|
set(ament_cmake_cpplint_FOUND TRUE)
|
||||||
|
ament_lint_auto_find_test_dependencies()
|
||||||
|
endif()
|
||||||
|
|
||||||
|
ament_package()
|
30
env_components/camera_component/package.xml
Normal file
30
env_components/camera_component/package.xml
Normal file
|
@ -0,0 +1,30 @@
|
||||||
|
<?xml version="1.0"?>
|
||||||
|
<?xml-model href="http://download.ros.org/schema/package_format3.xsd" schematypens="http://www.w3.org/2001/XMLSchema"?>
|
||||||
|
<package format="3">
|
||||||
|
<name>camera_component</name>
|
||||||
|
<version>0.0.0</version>
|
||||||
|
<description>TODO: Package description</description>
|
||||||
|
<maintainer email="rom.andrianov1984@gmail.com">splinter1984</maintainer>
|
||||||
|
<license>TODO: License declaration</license>
|
||||||
|
|
||||||
|
<buildtool_depend>ament_cmake</buildtool_depend>
|
||||||
|
<buildtool_depend>pkg-config</buildtool_depend>
|
||||||
|
|
||||||
|
<depend>image_transport</depend>
|
||||||
|
<depend>ros_gz_bridge</depend>
|
||||||
|
<depend>rclcpp</depend>
|
||||||
|
<depend>rclcpp_components</depend>
|
||||||
|
<depend>sensor_msgs</depend>
|
||||||
|
<depend>env_manager</depend>
|
||||||
|
|
||||||
|
<depend condition="$GZ_VERSION == fortress or $IGNITION_VERSION == fortress">ignition-msgs8</depend>
|
||||||
|
<depend condition="$GZ_VERSION == fortress or $IGNITION_VERSION == fortress">ignition-transport11</depend>
|
||||||
|
<depend condition="$GZ_VERSION == '' and $IGNITION_VERSION == ''">ignition-msgs8</depend>
|
||||||
|
<depend condition="$GZ_VERSION == '' and $IGNITION_VERSION == ''">ignition-transport11</depend>
|
||||||
|
|
||||||
|
<test_depend>ament_lint_auto</test_depend>
|
||||||
|
<test_depend>ament_lint_common</test_depend>
|
||||||
|
<export>
|
||||||
|
<build_type>ament_cmake</build_type>
|
||||||
|
</export>
|
||||||
|
</package>
|
42
env_components/camera_component/src/ign_camera_component.cpp
Normal file
42
env_components/camera_component/src/ign_camera_component.cpp
Normal file
|
@ -0,0 +1,42 @@
|
||||||
|
#include <component_manager/publisher_component.hpp>
|
||||||
|
|
||||||
|
#include <iostream>
|
||||||
|
#include <memory>
|
||||||
|
#include <string>
|
||||||
|
#include <vector>
|
||||||
|
|
||||||
|
#include <ignition/transport/Node.hh>
|
||||||
|
#include <rclcpp/rclcpp.hpp>
|
||||||
|
#include <image_transport/image_transport.hpp>
|
||||||
|
#include <ros_gz_bridge/convert.hpp>
|
||||||
|
|
||||||
|
#include <sensor_msgs/msg/image.hpp>
|
||||||
|
|
||||||
|
namespace camera_component
|
||||||
|
{
|
||||||
|
|
||||||
|
class IgnCameraComponent: public env_manager::component_manager::PublisherComponent<sensor_msgs::msg::Image>
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
explicit IgnCameraComponent(const rclcpp::NodeOptions &options)
|
||||||
|
: env_manager::component_manager::PublisherComponent<sensor_msgs::msg::Image>(options)
|
||||||
|
{
|
||||||
|
auto topic_name = "/camera";
|
||||||
|
_ign_node = std::make_shared<ignition::transport::Node>();
|
||||||
|
_ign_node->Subscribe(topic_name, &IgnCameraComponent::on_image, this);
|
||||||
|
}
|
||||||
|
|
||||||
|
private:
|
||||||
|
void on_image(const ignition::msgs::Image& img)
|
||||||
|
{
|
||||||
|
sensor_msgs::msg::Image rimg;
|
||||||
|
ros_gz_bridge::convert_gz_to_ros(img, rimg);
|
||||||
|
populate_publication(rimg);
|
||||||
|
}
|
||||||
|
|
||||||
|
std::shared_ptr<ignition::transport::Node> _ign_node;
|
||||||
|
};
|
||||||
|
} // namespace pub_component
|
||||||
|
#include "rclcpp_components/register_node_macro.hpp"
|
||||||
|
|
||||||
|
RCLCPP_COMPONENTS_REGISTER_NODE(camera_component::IgnCameraComponent)
|
|
@ -6,7 +6,7 @@ if(NOT CMAKE_C_STANDARD)
|
||||||
set(CMAKE_C_STANDARD 99)
|
set(CMAKE_C_STANDARD 99)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
# Default to C++14
|
# Default to C++17
|
||||||
if(NOT CMAKE_CXX_STANDARD)
|
if(NOT CMAKE_CXX_STANDARD)
|
||||||
set(CMAKE_CXX_STANDARD 17)
|
set(CMAKE_CXX_STANDARD 17)
|
||||||
endif()
|
endif()
|
||||||
|
@ -31,7 +31,7 @@ find_package(rcutils REQUIRED)
|
||||||
find_package(glog 0.4.0 REQUIRED)
|
find_package(glog 0.4.0 REQUIRED)
|
||||||
find_package(Lua 5.3 REQUIRED)
|
find_package(Lua 5.3 REQUIRED)
|
||||||
|
|
||||||
add_library(env_manager STATIC
|
add_library(env_manager SHARED
|
||||||
src/component_manager/component_manager.cpp
|
src/component_manager/component_manager.cpp
|
||||||
src/config/config_file_resolver.cpp
|
src/config/config_file_resolver.cpp
|
||||||
src/config/lua_file_resolver.cpp
|
src/config/lua_file_resolver.cpp
|
||||||
|
@ -79,7 +79,7 @@ ament_target_dependencies(
|
||||||
rclcpp
|
rclcpp
|
||||||
glog
|
glog
|
||||||
Lua
|
Lua
|
||||||
)
|
)
|
||||||
|
|
||||||
install(DIRECTORY config DESTINATION config)
|
install(DIRECTORY config DESTINATION config)
|
||||||
|
|
||||||
|
|
|
@ -9,7 +9,7 @@ include "environments/ground_true.lua"
|
||||||
-- env_manager configuration
|
-- env_manager configuration
|
||||||
ENV_MANAGER = {
|
ENV_MANAGER = {
|
||||||
environments = {
|
environments = {
|
||||||
SIMULATOR, GROUND_TRUE
|
GROUND_TRUE
|
||||||
},
|
},
|
||||||
nodes = NODES
|
nodes = NODES
|
||||||
}
|
}
|
||||||
|
|
|
@ -2,6 +2,7 @@
|
||||||
GROUND_TRUE = {
|
GROUND_TRUE = {
|
||||||
namespace = "ground_true",
|
namespace = "ground_true",
|
||||||
components = {
|
components = {
|
||||||
|
--[[
|
||||||
talker_node = {
|
talker_node = {
|
||||||
lib = "libpub_component.so",
|
lib = "libpub_component.so",
|
||||||
class = "pub_component::Publisher",
|
class = "pub_component::Publisher",
|
||||||
|
@ -9,6 +10,10 @@ GROUND_TRUE = {
|
||||||
service_node = {
|
service_node = {
|
||||||
lib = "libsrv_component.so",
|
lib = "libsrv_component.so",
|
||||||
class = "srv_component::Service"
|
class = "srv_component::Service"
|
||||||
}
|
},]]--
|
||||||
|
camera_node = {
|
||||||
|
lib = "libign_camera_component.so",
|
||||||
|
class = "camera_component::IgnCameraComponent"
|
||||||
|
},
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -2,6 +2,7 @@
|
||||||
SIMULATOR = {
|
SIMULATOR = {
|
||||||
namespace = "simulator_env",
|
namespace = "simulator_env",
|
||||||
components = {
|
components = {
|
||||||
|
--[[
|
||||||
talker_node = {
|
talker_node = {
|
||||||
lib = "libpub_component.so",
|
lib = "libpub_component.so",
|
||||||
class = "pub_component::Publisher",
|
class = "pub_component::Publisher",
|
||||||
|
@ -9,6 +10,10 @@ SIMULATOR = {
|
||||||
service_node = {
|
service_node = {
|
||||||
lib = "libsrv_component.so",
|
lib = "libsrv_component.so",
|
||||||
class = "srv_component::Service"
|
class = "srv_component::Service"
|
||||||
}
|
},]]--
|
||||||
|
camera_node = {
|
||||||
|
lib = "libign_camera_component.so",
|
||||||
|
class = "camera_component::IgnCameraComponent"
|
||||||
|
},
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,4 +1,5 @@
|
||||||
NODES = {
|
NODES = {
|
||||||
|
--[[
|
||||||
talker_node = {
|
talker_node = {
|
||||||
name = "talker",
|
name = "talker",
|
||||||
type = "Publisher",
|
type = "Publisher",
|
||||||
|
@ -8,5 +9,10 @@ NODES = {
|
||||||
name = "add_two_ints",
|
name = "add_two_ints",
|
||||||
type = "Service",
|
type = "Service",
|
||||||
msg_type = "example_interfaces/AddTwoInts"
|
msg_type = "example_interfaces/AddTwoInts"
|
||||||
}
|
},]]--
|
||||||
|
camera_node = {
|
||||||
|
name = "camera_node",
|
||||||
|
type = "Publisher",
|
||||||
|
msg_type = "sensor_msgs/Image"
|
||||||
|
},
|
||||||
}
|
}
|
||||||
|
|
|
@ -14,4 +14,8 @@ repositories:
|
||||||
behavior_tree:
|
behavior_tree:
|
||||||
type: git
|
type: git
|
||||||
url: https://github.com/solid-sinusoid/behavior_tree.git
|
url: https://github.com/solid-sinusoid/behavior_tree.git
|
||||||
version: master
|
version: master
|
||||||
|
ros_gz:
|
||||||
|
type: git
|
||||||
|
url: https://github.com/gazebosim/ros_gz.git
|
||||||
|
version: humble
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue