ApolloAuto/apollo

Custom Control Module

Closed this issue · 4 comments

System information

  • OS Platform and Distribution (e.g., Linux Ubuntu 18.04): Ubuntu 20
  • Apollo installed from (source or binary): source
  • Apollo version (3.5, 5.0, 5.5, 6.0): 6.0
  • Output of apollo.sh config if on master branch: [ OK ] Done building apollo. Enjoy!

Note that I am running Apollo exclusively in SimControl mode.
I have implemented a custom Control module (termed "controlbis") that function slightly different from the original. The only difference between "controlbis" and "control" is that "controlbis" produces command outputs (thottle,brake, steering) that are faulty meaning that they contain a high degree of noise intended to make the car crash.
Moreover, I changed parts of the Guardian and CANBUS modules which makes them listen to "controlbis" channel instead of the "control" channel in the following way:

control_cmd_reader_ = node_->CreateReader<ControlCommand>(FLAGS_control_command_topic)[this](const std::shared_ptr<ControlCommand>& cmd) {SomeCallBackFunction});

to

control_cmd_reader_ = node_->CreateReader<ControlCommand>("channel/controlbis")[this](const std::shared_ptr<ControlCommand>& cmd) {SomeCallBackFunction});

I rebuild the whole apollo stack without any errors.
When I am launching Dreamview and activate all the necessary modules to make the vehicle follow a planned trajectory I get the following:

  • control module is off, controlbis off --> vehicle does not move
  • control module is off, controlbis on --> vehicle does not move
  • control module is on, controlbis off or on --> vehicle runs normally

Even though control module is on and told explicitly the guardian and canbus and dreamview to not listen to the control channel the car still drives. Moreover if I switch control off an enable controlbis the car does not move. My question than becomes, what makes the car follow the trajectory in Dreamview? Following the documentation and searching inside apollo source code, only the guardian, canbus and dreamview modules read the control module channel.

Thank you for your help.

i haven't tried the simcontrol mode, but if you have your own control module, i don't think you need to change any other module, such as canbus.

just publish the control message to the same channel should do the work.

also, you may need to update the files under hmi_modes so that the dreamview is launching your own control module instead of the default one.

sim control is only used for simulation planning module.

why

In other words, the control module is an ideal model. By default, the car will drive according to the prescribed trajectory, so sim_control does not actually need the control module.

you can ref to the code in modules/dreamview/backend/sim_control/sim_control.h

how

Then the next question is how to simulate the control module.

I tried adding the dynamic model to sim_control. You need to add a vehicle kinematics model that accepts throttle brake and steering signals, and outputs the vehicle's speed and acceleration. Your own effect is related to the reality of your model. In fact, it is better to use the dynamic model of the existing simulator like carsim, carla, lgsvl.

Hope this helps you!

Thank you replies. This was helpful!

sim control is only used for simulation planning module.

why

In other words, the control module is an ideal model. By default, the car will drive according to the prescribed trajectory, so sim_control does not actually need the control module.

you can ref to the code in modules/dreamview/backend/sim_control/sim_control.h

how

Then the next question is how to simulate the control module.

I tried adding the dynamic model to sim_control. You need to add a vehicle kinematics model that accepts throttle brake and steering signals, and outputs the vehicle's speed and acceleration. Your own effect is related to the reality of your model. In fact, it is better to use the dynamic model of the existing simulator like carsim, carla, lgsvl.

Hope this helps you!

Seems to be resolved, we will close this issue. If the problem persists, pls feel free to reopen it or create a new one and refer to it.