Welcome to ROSMASTER R2 repository
4. Buzzer sounding
4. Buzzer sounding
4. Buzzer sounding4.1. Experimental Objectives4.2. Experiment Preparation4.3. Experimental operations and phenomena4.3.1. Checking ROS expansion boards4.3.2. Enter the Docker container.4.3.3. Run the program4.4. Program source code
4.1. Experimental Objectives
To control the buzzer switch on the expansion board with a beep time of 100 ms, 300 ms, 1 sec, etc.
4.2. Experiment Preparation
The red box in the picture shows the buzzer on the expansion board.

The buzzer on the expansion board is an active buzzer, so it is relatively simple to control, please check the following functions.
Rosmaster_Lib library functions needed to control the buzzer:
xxxxxxxxxxset_beep(on_time)Parameter explanation: on_time=0: off, on_time=1: ring all the time, on_time>=10: ring for xx milliseconds and then turn off automatically (on_time is a multiple of 10).
Return value: none.
4.3. Experimental operations and phenomena
4.3.1. Checking ROS expansion boards
The operation needs to enter into the docker to start, first need to make sure that the system has recognized the ROS expansion board, the terminal to run.
xxxxxxxxxxll /dev/myserial

The appearance of the above indicates that the system has recognized the ROS expansion board. The main point to note here is that ttyUSB1 is not absolute, it could be ttyUSB0 or other, as long as it is a ttyUSB device.
4.3.2. Enter the Docker container.
For more about Docker, please refer to [07. Docker] tutorial content, terminal enter the following command into the Docker to run the program.
xxxxxxxxxx./run_docker.sh
Then in the docker terminal, we go to Jupyter lab, and in the terminal we type.
xxxxxxxxxxjupyter lab --allow-root
Open it in a windows or ubuntu browser (must be on the same LAN, 192.168.2.88 is the IP address inside the docker container).
xxxxxxxxxxBrowser input.http://192.168.2.88:8889/labEnter the password: yahboom to access jupyter lab
Note that the URL here is modified according to the actual host terminal printout IP.

4.3.3. Run the program
In the jupyter lab interface, double-click into /root/yahboomcar_ros2_ws/Rosmaster/Sample, double-click to run 4.beep.ipynb, and step-by-step click on the

Run the program.
4.4. Program source code
Go to docker and refer to the code path: /root/yahboomcar_ros2_ws/Rosmaster/Sample/4.beep.ipynb.