Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add tutorial to run the pendulum_control demo #21

Closed
1 task
carlossvg opened this issue Jun 16, 2021 · 6 comments
Closed
1 task

Add tutorial to run the pendulum_control demo #21

carlossvg opened this issue Jun 16, 2021 · 6 comments
Assignees
Labels
documentation Improvements or additions to documentation

Comments

@carlossvg
Copy link
Contributor

carlossvg commented Jun 16, 2021

There is one real-time related demo in ros2/demos repository: pendulum_control

This demo was presented in:
Real-time Performance in ROS 2

A tutorial already exists in: https://docs.ros.org/en/galactic/Tutorials/Real-Time-Programming.html

As part of this issue we should revisit the existing tutorial, reproduce the results and see if it needs to be updated, deprecated or just complemented with a new tutorial.

Acceptance Criteria

  • A tutorial exists explaining how to run the pendulum_control demo
@carlossvg carlossvg added the documentation Improvements or additions to documentation label Jun 16, 2021
@carlossvg carlossvg added this to the ROScon2021 milestone Jun 16, 2021
@carlossvg carlossvg self-assigned this Jun 16, 2021
@carlossvg
Copy link
Contributor Author

carlossvg commented Jun 21, 2021

@LanderU This a draft for the tmux script:

Terminal 1:

# Runs the demo in CPU 1 using for 10 minutes using RT settings
taskset -c 1 /opt/ros/rolling/bin/pendulum_demo -m 400mb -d 400mb -t 90 -s rr -u 1ms -i 60000 -f output.txt

Terminal 2:

# Runs the pendulum logger
pendulum_logger

Terminal 3: NO! Remove this, see explanation below.

# Runs the pendulum teleop in a loop, we just send the same position (0)
while true; do
  pendulum_teleop 0
  sleep 3m
done

Terminal 4: htop

Terminal 5 or in background in another terminal?

# stress the system
taskset -c 0 stress -c 1 &
taskset -c 1 stress -c 1 &
taskset -c 2 stress -c 1 &
taskset -c 3 stress -c 1 &
taskset -c 0 stress -i 1 &
taskset -c 1 stress -i 1 &
taskset -c 2 stress -i 1 &
taskset -c 3 stress -i 1 &

I removed the teleoperation cause is not real-time safe, it prints to the stdout and impacts the measurements. I think the demo was not intended to use it. This not documented anywhere I think. https://github.com/ros2/demos/blob/master/pendulum_control/include/pendulum_control/pendulum_controller.hpp#L103

Selection_216

@carlossvg
Copy link
Contributor Author

@JanStaschulat

@carlossvg carlossvg removed this from the ROScon2021 milestone Mar 4, 2022
@carlossvg
Copy link
Contributor Author

carlossvg commented Mar 4, 2022

The instructions and results with the RPI4 are hosted here https://github.com/ros-realtime/ros2_realtime_benchmarks/tree/main/pendulum_demo_benchmarks/experiments/galactic

I'm trying to keep the instructions simple so I'm not including any stress, teleop, logging or CPU isolation.

The first latency sample it's always much higher. See https://github.com/ros-realtime/ros2_realtime_benchmarks/blob/main/pendulum_demo_benchmarks/experiments/galactic/rpi4_rt/pendulum_demo_results_plot_latency.svg. It's not clear why this happens cause there are no page faults. This might be caused by another issue during initialization. We should find out what is causing this and either fix the problem or discard the first sample when logging.

@carlossvg
Copy link
Contributor Author

carlossvg commented Mar 14, 2022

This is a list of issues I found when testing the pendulum demo:

  1. The first latency sample is very high. It looks like an initialization problem.
  2. The setpoint callback includes a printf => https://github.com/ros2/demos/blob/master/pendulum_control/include/pendulum_control/pendulum_controller.hpp#L108
  3. The latency is calculated using spin_some. This is probably not an issue for the pendulum_sensor and the pendulum_command callbacks because they will happen at the same time so spin_some will always execute both of them. This becomes a problem when a pendulum_setpoint arrives. If there is only one executable we will get an additional sample for the setpoint, which is not at the expected time. Therefore, we get a weird latency value for the setpoint callback. => https://github.com/ros2/demos/blob/f008dbbeefd7da30c4133ad67655554d9f7f8519/pendulum_control/include/pendulum_control/rtt_executor.hpp#L118
  4. The simulation doesn't work, we get weird values after some time. This is not that important for the demo.
  5. Data is shared between threads without any synchronization mechanism

Points 2 and 3 could be solved using callback groups.

@carlossvg
Copy link
Contributor Author

carlossvg commented Mar 15, 2022

Edit: Consider re-writing the demo with the following changes:

@carlossvg
Copy link
Contributor Author

No tutorial will be created for the pendulum_control. Only a brief document with some instructions to run the demo and create some plots here https://ros-realtime.github.io/Benchmarks/pendulum_demo_benchmark_instructions.html

A follow-up issue has been created to improve the current demo: #37

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
documentation Improvements or additions to documentation
Projects
Status: Done
Development

No branches or pull requests

1 participant