14
14
#include < rclc/rclc.h>
15
15
#include < rclc/executor.h>
16
16
17
- #include < std_msgs /msg/int32 .h>
17
+ #include < sensor_msgs /msg/joint_state .h>
18
18
19
19
/* *************************************************************************************
20
20
* GLOBAL VARIABLES
21
21
**************************************************************************************/
22
22
23
- rcl_publisher_t publisher ;
24
- std_msgs__msg__Int32 msg ;
23
+ rcl_publisher_t joint_state_publisher ;
24
+ sensor_msgs__msg__JointState joint_state_msg ;
25
25
rclc_executor_t executor;
26
26
rclc_support_t support;
27
27
rcl_allocator_t allocator;
@@ -60,13 +60,13 @@ void setup()
60
60
61
61
/* Create JointState publisher. */
62
62
RCCHECK (rclc_publisher_init_default (
63
- &publisher ,
63
+ &joint_state_publisher ,
64
64
&node,
65
- ROSIDL_GET_MSG_TYPE_SUPPORT (std_msgs , msg, Int32 ),
65
+ ROSIDL_GET_MSG_TYPE_SUPPORT (sensor_msgs , msg, JointState ),
66
66
" braccio_plusplus_node_joint_state_publisher" ));
67
67
68
68
/* Create Timer. */
69
- const unsigned int timer_timeout = 1000 ;
69
+ const unsigned int timer_timeout = 100 ;
70
70
RCCHECK (rclc_timer_init_default (
71
71
&timer,
72
72
&support,
@@ -76,8 +76,6 @@ void setup()
76
76
/* Create executor. */
77
77
RCCHECK (rclc_executor_init (&executor, &support.context , 1 , &allocator));
78
78
RCCHECK (rclc_executor_add_timer (&executor, &timer));
79
-
80
- msg.data = 0 ;
81
79
}
82
80
83
81
void loop ()
@@ -104,7 +102,6 @@ void timer_callback(rcl_timer_t * timer, int64_t last_call_time)
104
102
RCLC_UNUSED (last_call_time);
105
103
if (timer != NULL )
106
104
{
107
- RCSOFTCHECK (rcl_publish (&publisher, &msg, NULL ));
108
- msg.data ++;
105
+ RCSOFTCHECK (rcl_publish (&joint_state_publisher, &joint_state_msg, NULL ));
109
106
}
110
107
}
0 commit comments