We have defined the path using a script that is inspired from the Turtlebot3_client and Turtlebot3_server nodes in the Examples folder of the Turtlebot3 package.
Please understand that in this forum we usually do not review or analyze the custom code.
In some cases when TurtleBot3 is receiving multiple cmd_vel from different nodes, the robot may not run as intended.
For example, if you are running the turtlebot3_teleop node to control the robot remotely while transmitting a path, it may collide with each other.
I'd recommend to post at answers.ros.org with more details(such as your code and how steps you took to run the code) to get help from ROS developers and to find answers from similar questions.