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