Skip to content

Commit f910a0a

Browse files
committed
Publish a (empty JointState) message.
1 parent e4a5bc6 commit f910a0a

File tree

1 file changed

+7
-10
lines changed

1 file changed

+7
-10
lines changed

Diff for: examples/ROS2_Braccio_Driver/ROS2_Braccio_Driver.ino

+7-10
Original file line numberDiff line numberDiff line change
@@ -14,14 +14,14 @@
1414
#include <rclc/rclc.h>
1515
#include <rclc/executor.h>
1616

17-
#include <std_msgs/msg/int32.h>
17+
#include <sensor_msgs/msg/joint_state.h>
1818

1919
/**************************************************************************************
2020
* GLOBAL VARIABLES
2121
**************************************************************************************/
2222

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;
2525
rclc_executor_t executor;
2626
rclc_support_t support;
2727
rcl_allocator_t allocator;
@@ -60,13 +60,13 @@ void setup()
6060

6161
/* Create JointState publisher. */
6262
RCCHECK(rclc_publisher_init_default(
63-
&publisher,
63+
&joint_state_publisher,
6464
&node,
65-
ROSIDL_GET_MSG_TYPE_SUPPORT(std_msgs, msg, Int32),
65+
ROSIDL_GET_MSG_TYPE_SUPPORT(sensor_msgs, msg, JointState),
6666
"braccio_plusplus_node_joint_state_publisher"));
6767

6868
/* Create Timer. */
69-
const unsigned int timer_timeout = 1000;
69+
const unsigned int timer_timeout = 100;
7070
RCCHECK(rclc_timer_init_default(
7171
&timer,
7272
&support,
@@ -76,8 +76,6 @@ void setup()
7676
/* Create executor. */
7777
RCCHECK(rclc_executor_init(&executor, &support.context, 1, &allocator));
7878
RCCHECK(rclc_executor_add_timer(&executor, &timer));
79-
80-
msg.data = 0;
8179
}
8280

8381
void loop()
@@ -104,7 +102,6 @@ void timer_callback(rcl_timer_t * timer, int64_t last_call_time)
104102
RCLC_UNUSED(last_call_time);
105103
if (timer != NULL)
106104
{
107-
RCSOFTCHECK(rcl_publish(&publisher, &msg, NULL));
108-
msg.data++;
105+
RCSOFTCHECK(rcl_publish(&joint_state_publisher, &joint_state_msg, NULL));
109106
}
110107
}

0 commit comments

Comments
 (0)