You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: src/rover_samples/rv_sample_package/include/sample_node.h
+21-26Lines changed: 21 additions & 26 deletions
Original file line number
Diff line number
Diff line change
@@ -7,52 +7,47 @@
7
7
#include<rover_utils/include/roverCommon.h>// roverCommon.h will get you set up with basic ros2 includes as well as our utility libraries. Some parts of the repo
8
8
#include"sample_node_defines.h"
9
9
// Other ros2 includes seperated by a line
10
-
#include"sensor_msgs/msg/joy.hpp"
10
+
#include<sensor_msgs/msg/joy.hpp>
11
+
#include<geometry_msgs/msg/twist_stamped.hpp>
11
12
// cpp specific or other also seperated by a line
12
13
#include<atomic>
13
14
14
15
15
16
// Defines go after includes, but before class definitions
16
17
// If you need a lot of defines, create a seperate defines file (see sample_node_defines.h for more info)
17
-
#defineCONSTANT_ONE45
18
+
#defineTIMER_HZ5
18
19
#defineMACRO(x) 45*x
20
+
#defineTIMER_PERIOD_MS (1.0/TIMER_HZ)
19
21
20
22
21
23
// Class definition
22
24
classSampleNode : publicrclcpp::Node {
23
25
public:
24
26
SampleNode(); // Constructor is usually defined in .cpp. Its okay if you want to define it here instead.
Copy file name to clipboardExpand all lines: src/rover_samples/rv_sample_package/src/sample_node.cpp
+53-8Lines changed: 53 additions & 8 deletions
Original file line number
Diff line number
Diff line change
@@ -2,16 +2,19 @@
2
2
#include"sample_node.h"
3
3
4
4
// Constructor
5
-
SampleNode::SampleNode() : Node("sample_node") { // We create a class using rclcpp::Node as a base class. You can still use another base class if you need, albeit sometimes with difficulties in passing args..
5
+
SampleNode::SampleNode() : Node("sample_node")
6
+
{ // We create a class using rclcpp::Node as a base class. You can still use another base class if you need, albeit sometimes with difficulties in passing args..
7
+
6
8
// Quality of service example
7
9
auto qos = rclcpp::QoS(rclcpp::KeepLast(1)).transient_local();
std::cout << "Node is running (std cout)" << std::endl; // Standard C++ is always available
59
+
RCLCPP_INFO(this->get_logger(), "Node is running (ros2 info)"); // ROS2 (rclcpp) also has functions/macros that can replace some of the standard c++ workflow.
60
+
RCLCPP_WARN(this->get_logger(), "Node is running (ros2 warn)"); // ROS2 (rclcpp) also has functions that can replace some of the standard c++ workflow.
61
+
RCLCPP_ERROR(this->get_logger(), "Node is running (ros2 error)"); // ROS2 (rclcpp) also has functions that can replace some of the standard c++ workflow.
0 commit comments