How to use/modify/implement new algorithm in planning module?
Hi,
I want to implement a new planner algorithm, I am still new to Apollo, right now, I just want to know how the framework work. I have several questions about using the planning module in Apollo.
-
When running the demo (demo.bad and demo_2.bag), the log data recorded that
routing not ready; skip the planning cycle.in planning.cc andRouting is not ready.in reference_line_provider.cc . I do turn on the planner and routing modules in the Module Controller, but the routing module keeps turning off. If it skips the planning cycle why the car still seems to have a planner line to follow in the DreamView visualization, can you explain what happens here? -
How to use RTK planner? I change the planning_config.proto but it still uses the EM planner.
Thank you.
You can implement a new planner (modules/planning/planner/planner.h) for your new algorithm.
That not really what I looking for. Right now I just want to play around/modify the existing Planners, but it seems they do not work and I don't know why.
Like I said, in the log file planning.INFO, the output is routing not ready; skip the planning cycle. the EMPlanner only goto the Init() function, the plan() function is never called.
And if the planning cycle is skipped, why the car still shows the planning line in the dreaming view.
Can you explain/tell me what wrong here?
Thank you.
"Like I said, in the log file planning.INFO, the output is routing not ready; skip the planning cycle. the EMPlanner only goto the Init() function, the plan() function is never called." --- Please make sure you published a routing for the planning. You can rosecho the routing topic to validate it is correct.
"And if the planning cycle is skipped, why the car still shows the planning line in the dreaming view." --- Since the planning results were recorded in the rosbag, you will observe the trajectory by just playing the bag. You can filter the /apollo/planning topic from the rosbag in order to test your own planning.
thank you for your reply.
--- Please make sure you published a routing for the planning. You can rosecho the routing topic to validate it is correct.
rostopic echo /apollo/routing_response
/use_sim_time is not set, will not subscribe to simulated time [/clock] topic
This what I get when echo the routing
Did you generate a routing? Only turning on the routing module will not generate one.
After you filtered the planning in the rosbag and started your own planning, you can click Default Routing in the Dreaview to generate a routing message.
Thank you for being patient with me. I really appreciate your support.
This is what I done so far:
#filter the planning module
rosbag filter ./docs/demo_guide/demo_2.0.bag ./docs/demo_guide/demonew.bag "topic== '/apollo/planning'"
#run the new bag
rosbag play -l ./docs/demo_guide/demonew.bag
But in the Dreamview, nothing shows, the Default Routing button is grey out, could not select.

After you filtered the planning in the rosbag and started your own planning, you can click Default Routing in the Dreamview to generate a routing message
How to start planning module?
Do you have any tutorial on start a 'helloworld' project where it shows how to start a project like making a car follow points?
Once again, thank for your support.
I think the filter should be "topic != '/apollo/planning'" (not == ). The topic will be kept if it the expression is true.
To start planning module, please (1) build the project you have modified (using bash apollo.sh build) (2) run the planning binary in a separate terminal (using bash scripts/planning.sh), or just turn on the planning from dreamview.
I follow all your suggestion, but still not works. Here is what I did, please tell me what I did wrong:
rosbag filter ./docs/demo_guide/demo_2.0.bag ./docs/demo_guide/new.bag "topic!= '/apollo/planning'"
rosbag play ./docs/demo_guide/new.bag
in new terminal:
bash scripts/planning.sh
In the Dreamview:

And the log file for planning.INFO
I0321 23:35:00.377490 7123 em_planner.cc:78] In EMPlanner::Init() I0321 23:35:00.377511 7123 em_planner.cc:83] Created task:DpPolyPathOptimizer I0321 23:35:00.377516 7123 em_planner.cc:83] Created task:PathDecider I0321 23:35:00.377523 7123 em_planner.cc:83] Created task:DpStSpeedOptimizer I0321 23:35:00.377526 7123 em_planner.cc:83] Created task:SpeedDecider I0321 23:35:00.377557 7123 em_planner.cc:83] Created task:QpSplineStSpeedOptimizer I0321 23:35:00.377671 7123 planning.cc:144] Planning started E0321 23:35:00.427840 7219 reference_line_provider.cc:184] Routing is not ready. E0321 23:35:00.478001 7219 reference_line_provider.cc:184] Routing is not ready. E0321 23:35:00.478160 7123 planning.cc:209] localization not ready; skip the planning cycle. E0321 23:35:00.528249 7219 reference_line_provider.cc:184] Routing is not ready. E0321 23:35:00.578413 7219 reference_line_provider.cc:184] Routing is not ready. E0321 23:35:00.578434 7123 planning.cc:209] localization not ready; skip the planning cycle. .....
Another question, how to switch to another planner. I search around and see someone mention to make a change in the planning.proto to switch planner. I did but it seems do not work.
Before
optional PlannerType planner_type = 1 [default = EM];
After
optional PlannerType planner_type = 1 [default = RTK];
I also try to change " planner_type = 0" but it give a build error
modules/planning/proto/planning_config.proto:36:39: Field numbers must be positive integers.
I also did try to change RTK = 5, and planner_type = 5, but it not work either.
Thank you for your support and being patient with me.
Which routing did you choose? I tested "Route: sunnyvale loop" and it works.
I figure it out, has to choose the "Route: sunnyvale loop reverse", only that I can see the route (red line). Can you answer my question of how to switch to another planner, right now the code only call the EM planner.
Another question: How do I test my own planning algorithm? I want to make the car follow path generated by my planner, but it seems that even if I turn off the planner module, it still just follow what is recorded in the bag.
--- to change to another planner, please (1) add your planner name in planning_config.proto (line 31 - 35); (2) define the config of your own planner in planning_config.proto (after line 29); (3) change "planner_type : EM" to the one you have in planning_config.pb.txt.
--- Because the car in the rosbag has position info pre-recorded, it cannot follow your planning trajectory. If you want to make the car follow a generated path, you need to turn on the "SimControl" button (tasks->others) in the dreamview. Under the sim-control mode, the dreamview will receive the planning trajectory and help to move the car for you to mimic the driving process.
thank. I got all i need now.
choose the "Route: sunnyvale loop reverse"
How to choose the "Route: sunnyvale loop reverse"?
Hi @lianglia-apollo I read you know how to add or switch to a new planner. I am using Apollo 6.0 now. And I tried to change the planner from ROAD_PUBLIC to LATTICE defined in the planning_config.pb.txt as you and this post https://github.com/ApolloAuto/apollo/issues/13650 suggested:

However the planner did not work. I mean the planning module is disabled on dreamview when I turn it on, as you can check here: https://www.youtube.com/watch?v=bApS6gzyo7s&list=PL_d_YiRmUA3nnTRmF8QJKyPoEQhrdvpP2&index=3&t=253s
Then after this I also attempt to change the code below from file planning_config.proto:

I changed from 1 (Public_Road planner type) to 3 (Lattice planner) and compiled the workspace again with success. However the planning module keeps being disabled.
What am I doing wrong? Is it possible to swich Apollo 6.0 planners? I wish to do a test one by one of them (NAVI, ROAD_PUBLIC, LATTICE, OPEN_SPACE) to include in my master thesis: https://github.com/ApolloAuto/apollo/issues/13763
Could you please provide a step-by-step to how to change the planners? Which files I need to modify the code and which lines?
Thanks a lot for some reply!
Hi @lianglia-apollo could you kindly say me how to define the LATTICE planner config (just an example). It seems that this is the code missing for me enable/ change for the Lattice Planner.
I have done a lot of attempts to change the planner. Please take a look: https://github.com/ApolloAuto/apollo/issues/13828