Skip to content

Commit 7f1b182

Browse files
author
Javier Moreno
committed
Refs #3364.
1 parent d5dfb7c commit 7f1b182

1 file changed

Lines changed: 13 additions & 5 deletions

File tree

‎actuator/main.c‎

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,10 @@
44

55
#include <stdio.h>
66

7-
rclc_publisher_t* publisher;
7+
static rclc_publisher_t* publisher;
88

99

10-
void on_message(const void* msgin)
10+
void altitude_on_message(const void* msgin)
1111
{
1212
const std_msgs__msg__Float64* msg = (const std_msgs__msg__Float64*)msgin;
1313

@@ -32,18 +32,26 @@ void on_message(const void* msgin)
3232
}
3333
}
3434

35+
36+
void engine_on_message(const void* msgin)
37+
{
38+
const std_msgs__msg__Float64* msg = (const std_msgs__msg__Float64*)msgin;
39+
}
40+
3541
int main(int argc, char* argv[])
3642
{
3743
(void)argc;
3844
(void)argv;
3945
rclc_init(0, NULL);
4046
rclc_node_t* node = rclc_create_node("actuator", "");
41-
rclc_subscription_t* sub = rclc_create_subscription(node, RCLC_GET_MSG_TYPE_SUPPORT(std_msgs, msg, Float64), "position_sensor", on_message, 1, false);
42-
publisher = rclc_create_publisher(node, RCLC_GET_MSG_TYPE_SUPPORT(std_msgs, msg, String), "Warning", 1);
47+
rclc_subscription_t* altitude_sub = rclc_create_subscription(node, RCLC_GET_MSG_TYPE_SUPPORT(std_msgs, msg, Float64), "position_sensor", altitude_on_message, 1, false);
48+
rclc_subscription_t* engine_sub = rclc_create_subscription(node, RCLC_GET_MSG_TYPE_SUPPORT(std_msgs, msg, Float64), "engine_power", engine_on_message, 1, false);
49+
publisher = rclc_create_publisher(node, RCLC_GET_MSG_TYPE_SUPPORT(std_msgs, msg, String), "status_report", 1);
4350

4451
rclc_spin_node(node);
4552

46-
if (sub) rclc_destroy_subscription(sub);
53+
if (altitude_sub) rclc_destroy_subscription(altitude_sub);
54+
if (engine_sub) rclc_destroy_subscription(engine_sub);
4755
if (publisher) rclc_destroy_publisher(publisher);
4856
if (node) rclc_destroy_node(node);
4957

0 commit comments

Comments
 (0)