Welcome to ROSMASTER M3 repository
4.Subscribe to the buzzer topic
Subscribe to the buzzer topic
Subscribe to the buzzer topic1. Experimental Purpose2. Hardware Connection3. Core code analysis4. Compile, download and burn firmware5. Experimental Results
1. Experimental Purpose
Learn about the STM32-microROS component, access the ROS2 environment, and subscribe to the topic of controlling the buzzer switch.
2. Hardware Connection
As shown in the figure below, the STM32 control board integrates an active buzzer.
Use a Type-C data cable to connect the USB port of the main control board and the USB Connect port of the STM32 control board.
Since ROS2 requires the Ubuntu environment, it is recommended to install Ubuntu22.04 and ROS2 environment on the main control board.

Note: There are many types of main control boards. Here we take the Jetson Orin series main control board as an example, with the default factory image burned.
3. Core code analysis
The virtual machine path corresponding to the program source code is:
xxxxxxxxxxBoard_Samples/Microros_Samples/Subscriber_beep
Create a subscriber beep, the message type is UInt16.
xxxxxxxxxxRCCHECK(rclc_subscription_init_default(&beep_subscriber,&node,ROSIDL_GET_MSG_TYPE_SUPPORT(std_msgs, msg, UInt16),"beep"));
Add a subscriber beep to the executor.
xxxxxxxxxxRCCHECK(rclc_executor_add_subscription(&executor,&beep_subscriber,&beep_msg,&beep_Callback,ON_NEW_DATA));