Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

make pacledt-compose'Node' #9

Open
wants to merge 8 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
36 changes: 36 additions & 0 deletions packet/order/power/packet_power/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
cmake_minimum_required(VERSION 3.8)
project(packet_power)

if(CMAKE_COMPILER_IS_GNUCXX OR CMAKE_CXX_COMPILER_ID MATCHES "Clang")
add_compile_options(-Wall -Wextra -Wpedantic)
endif()

# find dependencies
find_package(ament_cmake REQUIRED)
# uncomment the following section in order to fill in
# further dependencies manually.
# find_package(<dependency> REQUIRED)
find_package(rclcpp REQUIRED)
find_package(packet_interfaces REQUIRED)

add_executable(Power
src/Power_main.cpp
src/Power.cpp
)

ament_target_dependencies(Power
rclcpp
packet_interfaces
)

target_include_directories(Power
PUBLIC
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>
$<INSTALL_INTERFACE:include>
)
install(TARGETS
Power
DESTINATION lib/${PROJECT_NAME}
)

ament_package()
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
#ifndef PACKET_POWER_POWERSPACKET_HPP
#define PACKET_POWER_POWERSPACKET_HPP

#include <memory>
#include "rclcpp/rclcpp.hpp"
#include "std_msgs/msg/string.hpp"

class Power : public rclcpp::Node {
private:

std::shared_ptr<rclcpp::Publisher<std_msgs::msg::String>> _publisher;
std::shared_ptr<rclcpp::TimerBase> _timer;
unsigned int _count;
void _loop();

public:
Power();
};

#endif // PACKET_POWER_POWERSPACKET_HPP
15 changes: 15 additions & 0 deletions packet/order/power/packet_power/package.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
<?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>packet_power</name>
<version>0.0.0</version>
<description>TODO: Package description</description>
<maintainer email="[email protected]">norikonakano</maintainer>
<license>MIT</license>
<buildtool_depend>ament_cmake</buildtool_depend>
<depend>rclcpp</depend>
<depend>packet_interfaces</depend>
<export>
<build_type>ament_cmake</build_type>
</export>
</package>
28 changes: 28 additions & 0 deletions packet/order/power/packet_power/src/power.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
#include <chrono>
#include <functional>
#include <string>

#include "packet_power/powerspacket.hpp"

void Power::_loop() {
std::stringstream ss;
ss << "Hello, world! " << _count;
std_msgs::msg::String msg{};
msg.data = ss.str();
RCLCPP_INFO(this->get_logger(), "say %s", ss.str().c_str());
_publisher->publish(msg);
_count++;
}


power::Power() :
rclcpp::Node("power"),
_publisher(),
_timer(),
_count(0)
{
using namespace std::chrono_literals;
_publisher = this->create_publisher<std_msgs::msg::String>("/powerspacket", 10);
auto loop = std::bind(&Power::_loop, this);
_timer = this->create_wall_timer(500ms, loop);
}
11 changes: 11 additions & 0 deletions packet/order/power/packet_power/src/power_main.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
#include <memory>
#include <rclcpp/rclcpp.hpp>
#include "packet_power/powerspacket.hpp"

int main(int argc, char * argv[]) {
rclcpp::init(argc, argv);
auto node = std::make_shared<Power>();
rclcpp::spin(node);
rclcpp::shutdown();
return 0;
}
36 changes: 36 additions & 0 deletions packet/order/quit/packet_quit/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
cmake_minimum_required(VERSION 3.8)
project(packet_quit)

if(CMAKE_COMPILER_IS_GNUCXX OR CMAKE_CXX_COMPILER_ID MATCHES "Clang")
add_compile_options(-Wall -Wextra -Wpedantic)
endif()

# find dependencies
find_package(ament_cmake REQUIRED)
# uncomment the following section in order to fill in
# further dependencies manually.
# find_package(<dependency> REQUIRED)
find_package(rclcpp REQUIRED)
find_package(packet_interfaces REQUIRED)

add_executable(Quit
src/quit_main.cpp
src/quit.cpp
)

ament_target_dependencies(Quit
rclcpp
packet_interfaces
)

target_include_directories(Quit
PUBLIC
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>
$<INSTALL_INTERFACE:include>
)
install(TARGETS
Quit
DESTINATION lib/${PROJECT_NAME}
)

ament_package()
21 changes: 21 additions & 0 deletions packet/order/quit/packet_quit/include/packet_quit/quitspacket.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
#ifndef PACKET_QUIT_QUITSPACKET_HPP
#define PACKET_QUIT_QUITSPACKET_HPP

#include <memory>
#include "rclcpp/rclcpp.hpp"
#include "std_msgs/msg/string.hpp"

class Quit : public rclcpp::Node {
private:

std::shared_ptr<rclcpp::Publisher<std_msgs::msg::String>> _publisher;
std::shared_ptr<rclcpp::TimerBase> _timer;
unsigned int _count;
void _loop();

public:
Quit();
};

#endif // PACKET_QUIT_QUITSPACKET_HPP

15 changes: 15 additions & 0 deletions packet/order/quit/packet_quit/package.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
<?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>packet_quit</name>
<version>0.0.0</version>
<description>TODO: Package description</description>
<maintainer email="[email protected]">norikonakano</maintainer>
<license>MIT</license>
<buildtool_depend>ament_cmake</buildtool_depend>
<depend>rclcpp</depend>
<depend>packet_interfaces</depend>
<export>
<build_type>ament_cmake</build_type>
</export>
</package>
29 changes: 29 additions & 0 deletions packet/order/quit/packet_quit/src/quit.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
#include <chrono>
#include <functional>
#include <string>

#include "packet_quit/quitspacket.hpp"

void Quit::_loop() {
std::stringstream ss;
ss << "Hello, world! " << _count;
std_msgs::msg::String msg{};
msg.data = ss.str();
RCLCPP_INFO(this->get_logger(), "say %s", ss.str().c_str());
_publisher->publish(msg);
_count++;
}


Quit::Quit() :
rclcpp::Node("quit"),
_publisher(),
_timer(),
_count(0)
{
using namespace std::chrono_literals;
_publisher = this->create_publisher<std_msgs::msg::String>("/quitspacket", 10);
auto loop = std::bind(&Quit::_loop, this);
_timer = this->create_wall_timer(500ms, loop);
}

11 changes: 11 additions & 0 deletions packet/order/quit/packet_quit/src/quit_main.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
#include <memory>
#include <rclcpp/rclcpp.hpp>
#include "packet_quit/quitspacket.hpp"

int main(int argc, char * argv[]) {
rclcpp::init(argc, argv);
auto node = std::make_shared<Quit>();
rclcpp::spin(node);
rclcpp::shutdown();
return 0;
}
23 changes: 23 additions & 0 deletions packet/packet_composed/.vscode/c_cpp_properties.json
H1rono marked this conversation as resolved.
Show resolved Hide resolved
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
{
"configurations": [
{
"browse": {
"databaseFilename": "${default}",
"limitSymbolsToIncludedHeaders": false
},
"includePath": [
"/home/norikonakano/24jam_ws/install/packet_interfaces/include/**",
"/opt/ros/iron/include/**",
"/home/norikonakano/24jam_ws/src/2024_cavolinia/packet/packet_composed/include/**",
"include/**",
"/usr/include/**"
],
"name": "ROS",
"intelliSenseMode": "gcc-x64",
"compilerPath": "/usr/bin/gcc",
"cStandard": "gnu11",
"cppStandard": "c++14"
}
],
"version": 4
}
16 changes: 16 additions & 0 deletions packet/packet_composed/.vscode/settings.json
H1rono marked this conversation as resolved.
Show resolved Hide resolved
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
{
"python.autoComplete.extraPaths": [
"/home/norikonakano/24jam_ws/install/pi_i2c/lib/python3.10/site-packages",
"/home/norikonakano/24jam_ws/install/nucleo_communicate_py/lib/python3.10/site-packages",
"/home/norikonakano/24jam_ws/install/packet_interfaces/lib/python3.10/site-packages",
"/home/norikonakano/24jam_ws/install/joystick/lib/python3.10/site-packages",
"/opt/ros/iron/lib/python3.10/site-packages"
],
"python.analysis.extraPaths": [
"/home/norikonakano/24jam_ws/install/pi_i2c/lib/python3.10/site-packages",
"/home/norikonakano/24jam_ws/install/nucleo_communicate_py/lib/python3.10/site-packages",
"/home/norikonakano/24jam_ws/install/packet_interfaces/lib/python3.10/site-packages",
"/home/norikonakano/24jam_ws/install/joystick/lib/python3.10/site-packages",
"/opt/ros/iron/lib/python3.10/site-packages"
]
}
37 changes: 37 additions & 0 deletions packet/packet_composed/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
cmake_minimum_required(VERSION 3.8)
project(packet_composed)

if(CMAKE_COMPILER_IS_GNUCXX OR CMAKE_CXX_COMPILER_ID MATCHES "Clang")
add_compile_options(-Wall -Wextra -Wpedantic)
endif()

# find dependencies
find_package(ament_cmake REQUIRED)
# uncomment the following section in order to fill in
# further dependencies manually.
# find_package(<dependency> REQUIRED)
find_package(rclcpp REQUIRED)
find_package(packet_interfaces REQUIRED)

add_executable(Composed
src/composed_main.cpp
src/composed.cpp
)

ament_target_dependencies(Composed
rclcpp
packet_interfaces
)

target_include_directories(Composed
PUBLIC
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>
$<INSTALL_INTERFACE:include>
)
install(TARGETS
Composed
DESTINATION lib/${PROJECT_NAME}
)

ament_package()

20 changes: 20 additions & 0 deletions packet/packet_composed/include/packet_composed/sensorspacket.hpp
H1rono marked this conversation as resolved.
Show resolved Hide resolved
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
#ifndef PACKET_COMPOSED_SENSORSPACKET_HPP
#define PACKET_COMPOSED_SENSORSPACKET_HPP

#include <memory>
#include "rclcpp/rclcpp.hpp"
#include "std_msgs/msg/string.hpp"

class Composed : public rclcpp::Node {
private:

std::shared_ptr<rclcpp::Publisher<std_msgs::msg::String>> _publisher;
std::shared_ptr<rclcpp::TimerBase> _timer;
unsigned int _count;
void _loop();

public:
Composed();
};

#endif // PACKET_COMPOSED_SENSORPACKET_HPP
15 changes: 15 additions & 0 deletions packet/packet_composed/package.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
<?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>packet_composed</name>
<version>0.0.0</version>
<description>TODO: Package description</description>
<maintainer email="[email protected]">norikonakano</maintainer>
<license>MIT</license>
<buildtool_depend>ament_cmake</buildtool_depend>
<depend>rclcpp</depend>
<depend>packet_interfaces</depend>
<export>
<build_type>ament_cmake</build_type>
</export>
</package>
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
cmake_minimum_required(VERSION 3.8)
project(packet_current)

if(CMAKE_COMPILER_IS_GNUCXX OR CMAKE_CXX_COMPILER_ID MATCHES "Clang")
add_compile_options(-Wall -Wextra -Wpedantic)
endif()

# find dependencies
find_package(ament_cmake REQUIRED)
# uncomment the following section in order to fill in
# further dependencies manually.
# find_package(<dependency> REQUIRED)
find_package(rclcpp REQUIRED)
find_package(packet_interfaces REQUIRED)

add_executable(Current
src/current_main.cpp
src/current.cpp
)

ament_target_dependencies(Current
rclcpp
packet_interfaces
)

target_include_directories(Current
PUBLIC
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>
$<INSTALL_INTERFACE:include>
)
install(TARGETS
Current
DESTINATION lib/${PROJECT_NAME}
)

ament_package()
Loading
Loading