Rename. Add position publisher. Don't pulish image at 100Hz...
This commit is contained in:
parent
1c50e01ed1
commit
b897f1793b
|
|
@ -1,5 +1,5 @@
|
||||||
cmake_minimum_required(VERSION 3.8)
|
cmake_minimum_required(VERSION 3.8)
|
||||||
project(image_publisher)
|
project(data_simulator)
|
||||||
|
|
||||||
if(CMAKE_COMPILER_IS_GNUCXX OR CMAKE_CXX_COMPILER_ID MATCHES "Clang")
|
if(CMAKE_COMPILER_IS_GNUCXX OR CMAKE_CXX_COMPILER_ID MATCHES "Clang")
|
||||||
add_compile_options(-Wall -Wextra -Wpedantic)
|
add_compile_options(-Wall -Wextra -Wpedantic)
|
||||||
|
|
@ -34,9 +34,26 @@ rclcpp_components_register_node(image_publisher_component
|
||||||
EXECUTABLE image_publisher
|
EXECUTABLE image_publisher
|
||||||
)
|
)
|
||||||
|
|
||||||
ament_export_targets(export_image_publisher_component)
|
add_library(position_publisher_component SHARED src/PositionPublisher.cpp)
|
||||||
install(TARGETS image_publisher_component
|
target_include_directories(position_publisher_component PUBLIC
|
||||||
EXPORT export_image_publisher_component
|
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>
|
||||||
|
$<INSTALL_INTERFACE:include/${PROJECT_NAME}>)
|
||||||
|
target_compile_features(position_publisher_component PUBLIC c_std_99 cxx_std_17) # Require C99 and C++17
|
||||||
|
target_link_libraries(position_publisher_component
|
||||||
|
rclcpp::rclcpp
|
||||||
|
rclcpp_components::component
|
||||||
|
${sensor_msgs_TARGETS}
|
||||||
|
${std_msgs_TARGETS}
|
||||||
|
)
|
||||||
|
|
||||||
|
rclcpp_components_register_node(position_publisher_component
|
||||||
|
PLUGIN "j7s::PositionPublisher"
|
||||||
|
EXECUTABLE position_publisher
|
||||||
|
)
|
||||||
|
|
||||||
|
ament_export_targets(export_${PROJECT_NAME} HAS_LIBRARY_TARGET)
|
||||||
|
install(TARGETS image_publisher_component position_publisher_component
|
||||||
|
EXPORT export_${PROJECT_NAME}
|
||||||
ARCHIVE DESTINATION lib
|
ARCHIVE DESTINATION lib
|
||||||
LIBRARY DESTINATION lib
|
LIBRARY DESTINATION lib
|
||||||
RUNTIME DESTINATION bin
|
RUNTIME DESTINATION bin
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,7 @@
|
||||||
<?xml version="1.0"?>
|
<?xml version="1.0"?>
|
||||||
<?xml-model href="http://download.ros.org/schema/package_format3.xsd" schematypens="http://www.w3.org/2001/XMLSchema"?>
|
<?xml-model href="http://download.ros.org/schema/package_format3.xsd" schematypens="http://www.w3.org/2001/XMLSchema"?>
|
||||||
<package format="3">
|
<package format="3">
|
||||||
<name>image_publisher</name>
|
<name>data_simulator</name>
|
||||||
<version>0.0.0</version>
|
<version>0.0.0</version>
|
||||||
<description>TODO: Package description</description>
|
<description>TODO: Package description</description>
|
||||||
<maintainer email="jpace121@gmail.com">jimmy</maintainer>
|
<maintainer email="jpace121@gmail.com">jimmy</maintainer>
|
||||||
|
|
|
||||||
|
|
@ -33,7 +33,7 @@ namespace j7s {
|
||||||
m_compressedPublisher(this->create_publisher<sensor_msgs::msg::CompressedImage>("image/compressed", 1)),
|
m_compressedPublisher(this->create_publisher<sensor_msgs::msg::CompressedImage>("image/compressed", 1)),
|
||||||
m_timer{}
|
m_timer{}
|
||||||
{
|
{
|
||||||
m_timer = this->create_timer(10ms, [this]() -> void {
|
m_timer = this->create_timer(33ms, [this]() -> void {
|
||||||
const auto [image, compressedImage] = draw_image();
|
const auto [image, compressedImage] = draw_image();
|
||||||
m_publisher->publish(*image);
|
m_publisher->publish(*image);
|
||||||
m_compressedPublisher->publish(*compressedImage);
|
m_compressedPublisher->publish(*compressedImage);
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,37 @@
|
||||||
|
#include <rclcpp/rclcpp.hpp>
|
||||||
|
#include <sensor_msgs/msg/nav_sat_fix.hpp>
|
||||||
|
#include <std_msgs/msg/header.hpp>
|
||||||
|
|
||||||
|
#include <chrono>
|
||||||
|
|
||||||
|
using namespace std::chrono_literals;
|
||||||
|
|
||||||
|
|
||||||
|
namespace j7s {
|
||||||
|
class PositionPublisher : public rclcpp::Node {
|
||||||
|
public:
|
||||||
|
PositionPublisher(const rclcpp::NodeOptions& options);
|
||||||
|
private:
|
||||||
|
std::shared_ptr<rclcpp::Publisher<sensor_msgs::msg::NavSatFix>> m_publisher;
|
||||||
|
rclcpp::TimerBase::SharedPtr m_timer;
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
|
namespace j7s {
|
||||||
|
PositionPublisher::PositionPublisher(const rclcpp::NodeOptions& options):
|
||||||
|
Node("position_publisher", options),
|
||||||
|
m_publisher(this->create_publisher<sensor_msgs::msg::NavSatFix>("navsatfix", 1)),
|
||||||
|
m_timer{}
|
||||||
|
{
|
||||||
|
m_timer = this->create_timer(10ms, [this]() -> void {
|
||||||
|
sensor_msgs::msg::NavSatFix navSatMsg;
|
||||||
|
navSatMsg.header.stamp = this->now();
|
||||||
|
navSatMsg.latitude = 40.4387;
|
||||||
|
navSatMsg.longitude = 79.9972;
|
||||||
|
m_publisher->publish(navSatMsg);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
#include <rclcpp_components/register_node_macro.hpp>
|
||||||
|
RCLCPP_COMPONENTS_REGISTER_NODE(j7s::PositionPublisher)
|
||||||
Loading…
Reference in New Issue