chore(les1): Clean up work, add node template

This commit is contained in:
2025-09-11 09:38:42 +02:00
parent 976f684c04
commit a8f0eb737e
4 changed files with 79 additions and 104 deletions

View File

@@ -1,22 +1,4 @@
// Wessel T <contact@wessel.gg> (https://wessel.gg/)
//
// "Build your own tower.
// A kingdom freed from malice.
// Create a world of bounty, peace and beauty."
// ⠀⣠⣶⣶⣤⣁
// ⢰⣷⡟⠻⣏⠻⣧⣀⠐⠈⠀⡈⠠⠀⠂⠀⢁⠈⠀⠄⠀⠁⣠⣴⣤⡈
// ⠀⣿⢿⡀⠘⢦⡈⢻⣦⠐⠀⠀⠄⠀⠁⠈⠀⡀⠠⠀⣠⡿⣿⣯⣽⡇
// ⠀⢻⣿⠛⢦⣄⣹⠦⣌⣳⡀⠀⣠⠈⠀⢾⠀⠀⢀⣼⢯⠞⢡⣿⣿⠁
// ⠄⠘⣿⣷⣤⡀⠙⣆⠈⠻⣿⡄⠘⣇⠀⣾⠀⣴⠿⢲⣋⣤⣿⡿⠃⠀
// ⠀⡀⠹⣿⣦⡉⠛⠚⣆⠀⠈⠻⣆⢻⢠⣇⡾⠃⢠⣟⣠⣾⡞⠃⠀
// ⠂⡀⠄⠹⣿⣏⠛⠒⠾⠷⣄⠀⠙⣞⣿⠋⣀⣴⣋⣽⡿⠋
// ⠂⠠⠀⠀⣨⣿⢿⣶⣒⠲⢮⣿⣶⣼⣧⣾⣭⣿⠟⠉
// ⠐⠀⠁⣰⣿⠓⠒⣛⣻⠟⠛⣩⣿⣯⠙⡯⣿⡆
// ⠐⠀⠄⠸⣿⡟⢉⡽⢛⣿⡿⠉⠀⢸⣧⡷⣾⡇
// ⠀⢂⠀⠄⠹⢿⣿⣴⣯⠏⠀⠀⠀⣼⢸⣽⣷⠇
// ⠠⠀⠂⢀⠀⢀⠈⠉⠀⠀⠀⠂⡀⠹⠿⠛⠁⠀⠀
/* les1.cpp
/* les1/clock.cpp
* Assignment done in the first lesson explaining
* the basics of ROS2
*
@@ -26,15 +8,13 @@
* [07-09-2025] Wessel T:
* - Rename {les1.cpp -> les1/clock.cpp}
* - Update node names to be in line with other files
* [11-09-2025] Wessel T: Remove unused imports
*/
#include <cstdlib>
#include "rclcpp/rclcpp.hpp"
#include <rclcpp/clock.hpp>
#include <rclcpp/time.hpp>
class NodeLes1Clock : public rclcpp::Node
{
class NodeLes1Clock : public rclcpp::Node {
public:
NodeLes1Clock()
: Node("node_les1_clock")

View File

@@ -1,22 +1,4 @@
// Wessel T <contact@wessel.gg> (https://wessel.gg/)
//
// "Build your own tower.
// A kingdom freed from malice.
// Create a world of bounty, peace and beauty."
// ⠀⣠⣶⣶⣤⣁
// ⢰⣷⡟⠻⣏⠻⣧⣀⠐⠈⠀⡈⠠⠀⠂⠀⢁⠈⠀⠄⠀⠁⣠⣴⣤⡈
// ⠀⣿⢿⡀⠘⢦⡈⢻⣦⠐⠀⠀⠄⠀⠁⠈⠀⡀⠠⠀⣠⡿⣿⣯⣽⡇
// ⠀⢻⣿⠛⢦⣄⣹⠦⣌⣳⡀⠀⣠⠈⠀⢾⠀⠀⢀⣼⢯⠞⢡⣿⣿⠁
// ⠄⠘⣿⣷⣤⡀⠙⣆⠈⠻⣿⡄⠘⣇⠀⣾⠀⣴⠿⢲⣋⣤⣿⡿⠃⠀
// ⠀⡀⠹⣿⣦⡉⠛⠚⣆⠀⠈⠻⣆⢻⢠⣇⡾⠃⢠⣟⣠⣾⡞⠃⠀
// ⠂⡀⠄⠹⣿⣏⠛⠒⠾⠷⣄⠀⠙⣞⣿⠋⣀⣴⣋⣽⡿⠋
// ⠂⠠⠀⠀⣨⣿⢿⣶⣒⠲⢮⣿⣶⣼⣧⣾⣭⣿⠟⠉
// ⠐⠀⠁⣰⣿⠓⠒⣛⣻⠟⠛⣩⣿⣯⠙⡯⣿⡆
// ⠐⠀⠄⠸⣿⡟⢉⡽⢛⣿⡿⠉⠀⢸⣧⡷⣾⡇
// ⠀⢂⠀⠄⠹⢿⣿⣴⣯⠏⠀⠀⠀⣼⢸⣽⣷⠇
// ⠠⠀⠂⢀⠀⢀⠈⠉⠀⠀⠀⠂⡀⠹⠿⠛⠁⠀⠀
/* les1.cpp
/* les1/publisher.cpp
* Assignment done in the first lesson explaining
* the basics of ROS2
*
@@ -24,19 +6,17 @@
* Changelog:
* [04-09-2025] Wessel T:
* - Implement template
* [11-09-2025] Wessel T: Remove unused imports
*/
#include <cstdlib>
#include "rclcpp/rclcpp.hpp"
#include <rclcpp/clock.hpp>
#include <rclcpp/time.hpp>
#include "geometry_msgs/msg/point.hpp" // Point for x, y, z coordinates
#include "les_interface/msg/hardware_status.hpp" // Custom HW status message
class NodeLes1Publisher : public rclcpp::Node {
public:
NodeLes1Publisher()
: Node("node_les1_publisher")
@@ -67,7 +47,8 @@ void timer_location_function() {
publisher_location_->publish(coordinate);
RCLCPP_INFO(this->get_logger(),
"Published x=%.2f, y=%.2f, z=%.2f", coordinate.x, coordinate.y, coordinate.z);
"Published x=%.2f, y=%.2f, z=%.2f", coordinate.x, coordinate.y, coordinate.z
);
}
void timer_hw_status_function() {
@@ -82,7 +63,8 @@ void timer_hw_status_function() {
"Published HW status: version=%ld, temp=%.2f, motors_ready=%s, msg=%s",
hw_msg.version, hw_msg.temperature,
hw_msg.are_motors_ready ? "true" : "false",
hw_msg.debug_message.c_str());
hw_msg.debug_message.c_str()
);
}
private:

View File

@@ -1,22 +1,4 @@
// Wessel T <contact@wessel.gg> (https://wessel.gg/)
//
// "Build your own tower.
// A kingdom freed from malice.
// Create a world of bounty, peace and beauty."
// ⠀⣠⣶⣶⣤⣁
// ⢰⣷⡟⠻⣏⠻⣧⣀⠐⠈⠀⡈⠠⠀⠂⠀⢁⠈⠀⠄⠀⠁⣠⣴⣤⡈
// ⠀⣿⢿⡀⠘⢦⡈⢻⣦⠐⠀⠀⠄⠀⠁⠈⠀⡀⠠⠀⣠⡿⣿⣯⣽⡇
// ⠀⢻⣿⠛⢦⣄⣹⠦⣌⣳⡀⠀⣠⠈⠀⢾⠀⠀⢀⣼⢯⠞⢡⣿⣿⠁
// ⠄⠘⣿⣷⣤⡀⠙⣆⠈⠻⣿⡄⠘⣇⠀⣾⠀⣴⠿⢲⣋⣤⣿⡿⠃⠀
// ⠀⡀⠹⣿⣦⡉⠛⠚⣆⠀⠈⠻⣆⢻⢠⣇⡾⠃⢠⣟⣠⣾⡞⠃⠀
// ⠂⡀⠄⠹⣿⣏⠛⠒⠾⠷⣄⠀⠙⣞⣿⠋⣀⣴⣋⣽⡿⠋
// ⠂⠠⠀⠀⣨⣿⢿⣶⣒⠲⢮⣿⣶⣼⣧⣾⣭⣿⠟⠉
// ⠐⠀⠁⣰⣿⠓⠒⣛⣻⠟⠛⣩⣿⣯⠙⡯⣿⡆
// ⠐⠀⠄⠸⣿⡟⢉⡽⢛⣿⡿⠉⠀⢸⣧⡷⣾⡇
// ⠀⢂⠀⠄⠹⢿⣿⣴⣯⠏⠀⠀⠀⣼⢸⣽⣷⠇
// ⠠⠀⠂⢀⠀⢀⠈⠉⠀⠀⠀⠂⡀⠹⠿⠛⠁⠀⠀
/* les1.cpp
/* les1/subscriber.cpp
* Assignment done in the first lesson explaining
* the basics of ROS2
*

View File

@@ -0,0 +1,31 @@
/* node_template.cpp
* Basic node template for ROS2
*
* Reviewed by: <x>
* Changelog:
* [04-09-2025] Wessel T: Implement template
*/
#include <cstdlib>
#include "rclcpp/rclcpp.hpp"
class NodeTemplate : public rclcpp::Node {
public:
NodeTemplate()
: Node("node_template")
{
}
private:
};
int main(int argc,char *argv[]) {
rclcpp::init(argc,argv);
auto node = std::make_shared<NodeTemplate>();
rclcpp::spin(node);
rclcpp::shutdown();
return 0;
}