Skip to content

Commit

Permalink
config: add node name and topic prefix
Browse files Browse the repository at this point in the history
Signed-off-by: Thomas Chou <thomas@wytron.com.tw>
  • Loading branch information
hippo5329 committed Feb 21, 2024
1 parent 238d890 commit cbe3a80
Showing 1 changed file with 10 additions and 4 deletions.
14 changes: 10 additions & 4 deletions firmware/src/firmware.ino
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,12 @@ static inline void set_microros_net_transports(IPAddress agent_ip, uint16_t agen
#ifndef BAUDRATE
#define BAUDRATE 115200
#endif
#ifndef NODE_NAME
#define NODE_NAME "linorobot_base_node"
#endif
#ifndef TOPIC_PREFIX
#define TOPIC_PREFIX
#endif

#define RCCHECK(fn) { rcl_ret_t temp_rc = fn; if((temp_rc != RCL_RET_OK)){rclErrorLoop();}}
#define RCSOFTCHECK(fn) { rcl_ret_t temp_rc = fn; if((temp_rc != RCL_RET_OK)){}}
Expand Down Expand Up @@ -208,27 +214,27 @@ bool createEntities()
//create init_options
RCCHECK(rclc_support_init(&support, 0, NULL, &allocator));
// create node
RCCHECK(rclc_node_init_default(&node, "linorobot_base_node", "", &support));
RCCHECK(rclc_node_init_default(&node, NODE_NAME, "", &support));
// create odometry publisher
RCCHECK(rclc_publisher_init_default(
&odom_publisher,
&node,
ROSIDL_GET_MSG_TYPE_SUPPORT(nav_msgs, msg, Odometry),
"odom/unfiltered"
TOPIC_PREFIX "odom/unfiltered"
));
// create IMU publisher
RCCHECK(rclc_publisher_init_default(
&imu_publisher,
&node,
ROSIDL_GET_MSG_TYPE_SUPPORT(sensor_msgs, msg, Imu),
"imu/data"
TOPIC_PREFIX "imu/data"
));
// create twist command subscriber
RCCHECK(rclc_subscription_init_default(
&twist_subscriber,
&node,
ROSIDL_GET_MSG_TYPE_SUPPORT(geometry_msgs, msg, Twist),
"cmd_vel"
TOPIC_PREFIX "cmd_vel"
));
// create timer for actuating the motors at 50 Hz (1000/20)
const unsigned int control_timeout = 20;
Expand Down

0 comments on commit cbe3a80

Please sign in to comment.