Apollo: Cyber RT timer

Created on 27 Sep 2020  路  7Comments  路  Source: ApolloAuto/apollo

Hi, I have 2 questions.
1) What is meant by reality mode? Is it the mode when Apollo is installed on a real car? And what changes between reality mode and not?
2) What is the difference between work_wheel and assistant_wheel in the TimingWheel class?

Cyber

All 7 comments

Here are some ideas for reference.

  1. What is meant by reality mode? Is it the mode when Apollo is installed on a real car? And what changes between reality mode and not?

"reality mode" is true by default. If it is set to false, the cyber will not even create nodes and the timer will not work too. That means you can't send msg, but the component can handle proc by itself, so I think it is used for unit test or some test cases when set false.

  1. What is the difference between work_wheel and assistant_wheel in the TimingWheel class?

If you are familiar with the time wheel, then this is a multi-level time wheel structure, which is similar to the concept of seconds and minutes. After 60 seconds, the minute will advance 1.

assistant_wheel (64)  <-  work_wheel (512) 

work_wheel is 1024ms period(almost 1s), and assistant_wheel is 64*1024ms period(almost 1min)

@daohu527 thanks. Why in timer.cc there Is AddTask call function twice in with the same task?

Can be understood like this.

  1. After the task is done, put it in the next period bucket.
    https://github.com/ApolloAuto/apollo/blob/55fe6dab85b48220f9f9cc2a0266fb21fc16f64f/cyber/timer/timer.cc#L122-L124

  2. Add the source task into time wheel, and then repeat the above process
    https://github.com/ApolloAuto/apollo/blob/55fe6dab85b48220f9f9cc2a0266fb21fc16f64f/cyber/timer/timer.cc#L135-L137

1.So, here put the task in the time wheel to be processed.

  1. After the task is done, put it in the next period bucket.
    https://github.com/ApolloAuto/apollo/blob/55fe6dab85b48220f9f9cc2a0266fb21fc16f64f/cyber/timer/timer.cc#L122-L124
  1. I don't understand why here the same task is again put in the same time wheel?
    > 2. Add the source task into time wheel, and then repeat the above process
    > https://github.com/ApolloAuto/apollo/blob/55fe6dab85b48220f9f9cc2a0266fb21fc16f64f/cyber/timer/timer.cc#L135-L137

The first code just add callback, not actually add task, so when do we start the task ?

The second code is used to add the above task into time wheel, we say the first root or parent task, then the callback will run, and cycle add task in callback, the whole process like this.

add first task -> time wheel
      | 
callback-> add itself into next bucket

In this function, we take the task in the current work wheel, but what does the Async function do?
What happens in the lines from 56 to 62?

https://github.com/ApolloAuto/apollo/blob/55fe6dab85b48220f9f9cc2a0266fb21fc16f64f/cyber/timer/timing_wheel.cc#L46-L67

It use for execute task callback, callback is a function point, then we run the callback through the function point.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

freeclouds picture freeclouds  路  3Comments

chilihua picture chilihua  路  3Comments

chasingw picture chasingw  路  3Comments

lyletbjohnson picture lyletbjohnson  路  3Comments

jamchen1025 picture jamchen1025  路  3Comments