Synchronization Between Robot and Simulink
1 次查看(过去 30 天)
显示 更早的评论
Good afternoon, everyone,
I am working on a path-tracking problem (deploying algorithm on Turtlebot3 (TB3) robot using ROS Noetic) using different controllers. Even though everything is fine in my model, I am facing synchronization time problem between TB3 and Simulink. In the attached image, the red circled signals ( from Motive subsystem: real time states of the robot from motion capturing system) are the real time states (x, y and theta) of the robot and green circled are the reference signal (from waypoints substem) in x and y respectively. When I do experiment, robot is moving faster than reference signal, in other words, TB3 is reaching the goal location before reference signals which is utterly undersirable and because of which it is not tracking the reference path precisely. Kindly guide be how can I synchronise time of both robot and reference signal.
3 个评论
Jagadeesh Konakalla
2023-6-6
Hi Shivam,
Can you try the Pacing option in the simulink ?
Let me know if this helps.
Thanks,
Jagadeesh K
回答(1 个)
Sanchari
2024-2-9
Hello Shivam,
Synchronization issues between a robot and reference signals in Simulink often arise due to discrepancies in the execution rates of the Simulink model and the robot's control loop. Here are some steps you can take to address synchronization issues:
- Control Loop Rate Matching: Ensure that the control loop rate in Simulink matches the control loop rate of the TB3. If the TB3 is executing its control loop faster than Simulink, the robot will reach its goal before Simulink updates the reference signals. You can adjust the sample time of the blocks in Simulink to match the TB3's control loop rate.
- ROS Time: Use ROS time, ros::Time::now(), instead of wall-clock time to ensure that all time-dependent operations are based on the ROS clock.
- ROS Rate: In your ROS nodes, use ros::Rate to control the rate of your control loop. This will help ensure that your robot's control commands are issued at a consistent rate.
- Simulink Pacing: As suggested before in the comments, use the Simulink Pacing to slow down the simulation to real-time/ desired execution rate. This can be found in Configuration Parameters under the Solver section. Enable "Pacing to slow down simulation" and set the desired pace.
- External Mode: If you're using Simulink's external mode for real-time execution on hardware, ensure that the communication interval is set appropriately to match the TB3's control loop rate.
- Buffering and Interpolation: If there's a delay in receiving the real-time states from the motion capturing system, consider buffering the data and using interpolation to estimate the states at the exact time steps needed by the control algorithm.
- ROS Synchronization Tools: Use ROS synchronization tools such as message_filters or tf2 to synchronize messages that are supposed to arrive at the same time but may be subject to network delays or processing time differences.
- Adjust Reference Trajectory Generation: If the reference trajectory is generated too slowly, consider precomputing the entire trajectory or larger segments of it, so the TB3 does not have to wait for new reference points.
- Hardware Timing: Investigate any hardware-induced latencies or timing issues that might affect the synchronization, such as delays in the motion capturing system or communication delays between the TB3 and the computer running Simulink.
- Diagnostics and Logging: Use ROS diagnostics and Simulink data logging to analyse the timing of various components in your system. Look for discrepancies in the timestamps of messages and execution rates.
Please refer to the following MathWorks Documentation for information on Simulation Pacing Options: https://www.mathworks.com/help/simulink/slref/simulationpacingoptions.html
The following links may be useful as well:
- ROS Toolbox support package for TurtleBot-based robots (File Exchange): https://www.mathworks.com/matlabcentral/fileexchange/55578-ros-toolbox-support-package-for-turtlebot-based-robots?s_tid=answers_rc2-2_p5_MLT
- Matching Simulink time with ROS time in co-simulation (ML Answer): https://www.mathworks.com/matlabcentral/answers/1604975-why-does-the-simulink-time-not-match-ros-time-in-co-simulation?s_tid=srchtitle
- Enable ROS Time Model Stepping for Deployed ROS Nodes (Documentation): https://www.mathworks.com/help/ros/ug/enable-ros-time-model-stepping-for-deployed-ros-nodes.html
- Simulate State Space model using live inputs coming from Gazebo environment (ML Answer): https://www.mathworks.com/matlabcentral/answers/827080-is-it-possible-to-simulate-state-space-model-using-live-inputs-coming-from-gazebo-environment?s_tid=srchtitle
- Synchronise Simulink node with PX4 SITL-ROS-Gazebo: https://www.mathworks.com/matlabcentral/answers/789749-synchronize-simulink-node-with-px4-sitl-ros-gazebo?s_tid=srchtitle
- Speeding up co-simulation between Gazebo and Simulink: https://www.mathworks.com/matlabcentral/answers/750999-on-speeding-up-co-simulation-between-gazebo-and-simulink?s_tid=srchtitle
Hope this helps!
0 个评论
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Publishers and Subscribers 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!