Synchronization Between Robot and Simulink

10 ビュー (過去 30 日間)
Shivam Bajpai
Shivam Bajpai 2023 年 6 月 2 日
回答済み: Sanchari 2024 年 2 月 9 日
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
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
Shivam Bajpai
Shivam Bajpai 2023 年 6 月 14 日
Hello, Sir,
Sorry for the late reply. I tried the above solution but, still reference signal is slower than the real robot. I don't know how it can be possible even I am giving low linear and angular velocities to robot which are 0.22m/s and 2.84 rad/sec. I tried real-time synchronization as well but it also didn't work.
Thank you,
Shivam

サインインしてコメントする。

回答 (1 件)

Sanchari
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:
  1. 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.
  2. 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.
  3. 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.
  4. 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.
  5. 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.
  6. 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.
  7. 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.
  8. 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.
  9. 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.
  10. 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:
  1. 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
  2. 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
  3. 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
  4. 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
  5. 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
  6. 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!

カテゴリ

Help Center および File ExchangeNetwork Connection and Exploration についてさらに検索

製品


リリース

R2023a

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by