-
Notifications
You must be signed in to change notification settings - Fork 66
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
Fred/crowd sim plugin #218
Fred/crowd sim plugin #218
Conversation
update the latest
get up-to-date merge
… adding include and test folders in building_gazebo_plugins
… include and test folder. Please modify the model path when running test
As a high level comment I would remove all the testing files if we want to merge this. A strategy you could try is move all the testing files to a separate branch (i.e. called `crowd_sim_plugin_test). |
OK got it up and running! I was pondering if we can do something to make the actors look more natural when they reach a waypoint, basically what happens now is that they stop playing an animation at whatever point in time when they reach their destination (example below): I can see at least two ways to make it look better:
Do you think this would be possible? |
I think it's OK, it seems it's not so immediate to switch among different animations at runtime, we can leave this as a future feature. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just a quick review, I believe we can further reduce the size of this PR by moving as much logic as possible to the common library and reducing code duplication between the ignition and the gazebo plugins.
There might be some additional functions I missed but I pointed out the ones I could find from a quick glance.
Ideally we would reach something similar to the door plugin, which is super simple.
building_sim_plugins/building_gazebo_plugins/include/crowd_simulator.hpp
Outdated
Show resolved
Hide resolved
building_sim_plugins/building_gazebo_plugins/include/crowd_simulator.hpp
Outdated
Show resolved
Hide resolved
building_sim_plugins/building_gazebo_plugins/src/crowd_simulator.cpp
Outdated
Show resolved
Hide resolved
building_sim_plugins/building_gazebo_plugins/src/crowd_simulator.cpp
Outdated
Show resolved
Hide resolved
building_sim_plugins/building_gazebo_plugins/src/crowd_simulator.cpp
Outdated
Show resolved
Hide resolved
...g_sim_plugins/building_plugins_common/include/building_sim_common/crowd_simulator_common.hpp
Outdated
Show resolved
Hide resolved
...g_sim_plugins/building_plugins_common/include/building_sim_common/crowd_simulator_common.hpp
Outdated
Show resolved
Hide resolved
...g_sim_plugins/building_plugins_common/include/building_sim_common/crowd_simulator_common.hpp
Outdated
Show resolved
Hide resolved
...g_sim_plugins/building_plugins_common/include/building_sim_common/crowd_simulator_common.hpp
Outdated
Show resolved
Hide resolved
...g_sim_plugins/building_plugins_common/include/building_sim_common/crowd_simulator_common.hpp
Outdated
Show resolved
Hide resolved
...g_sim_plugins/building_plugins_common/include/building_sim_common/crowd_simulator_common.hpp
Outdated
Show resolved
Hide resolved
...g_sim_plugins/building_plugins_common/include/building_sim_common/crowd_simulator_common.hpp
Outdated
Show resolved
Hide resolved
building_sim_plugins/building_plugins_common/src/crowd_simulator_common.cpp
Outdated
Show resolved
Hide resolved
building_sim_plugins/building_ignition_plugins/include/crowd_simulator.hpp
Outdated
Show resolved
Hide resolved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The simulation is working like a charm! Thanks for all the hardwork! This is going to be awesome once we iron out all the changes.
Fred/crowd sim plugin refact
Refactor the original crowd simulation plugin structure. Changes are follow:
|
To test the refactored crowd_sim_plugin, a new test branch is created under The test files are tested under the latest rmf_core structure, with tinyRobot (under both gazebo and ignition). |
Thanks for the fixes! The main issue I find now is in the code style, generally we have the rmf guidelines for contributing code that we try to stick to (for example function names should be |
...g_sim_plugins/building_plugins_common/include/building_sim_common/crowd_simulator_common.hpp
Outdated
Show resolved
Hide resolved
if (!agentPtr) | ||
{ | ||
RCLCPP_ERROR(_crowdSimInterface->logger(), "Null agentPtr when update Object!"); | ||
assert(agentPtr); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is there a reason the assert
is in this check? Also do you intend to have the code continue executing even if the pointer is invalid? My suggestion would be to check for nullptr
and return
,
if (!agentPtr)
{
RCLCPP_ERROR(_crowdSimInterface->logger(), "Null agentPtr when update Object!");
return;
}
Or if this check is really for debugging purposes, maybe you can get away with only using a single assert
call instead of an if
case,
assert(agentPtr);
assert(modelPtr);
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for pointing out. Yep I remember I wrote this assert in the early stage to abort the plugin once an invalid pointer is found, which I think assert()
is doing the check, and if found false, assert will call abort()
. Just return from this function might just get a log and the rest code is continuing.
Is there any way to do it elegantly? maybe I should use exit()
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There is not that clear a solution I believe. It will ultimately depends on how you would like the plugin's behaviour to be, and how often would you expect these edge cases to show up. If it is something that is critical for the continual operation of the plugin, you might want to crash the plugin while providing error logs. Otherwise if this happens once in a while, as a result of dropping a sensor message for example, and you would like the plugin to continue, then an error log while calling return;
on the function would be good.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just a few more minor changes and we will be ready to merge, thanks for incorporating most of the comments in the previous review!
2 more things you can do, is to add proper licensing information into all the source files, we use Apache 2.0, you can find them all throughout rmf_core
, and might just need to change the year to 2020
.
Linting will also be needed. You can check out how it is done through this github action, https://github.com/osrf/rmf_core/blob/feature/style_action/.github/workflows/style.yaml
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for making the changes for all the new features! LGTM!
Great thanks for all the changes! |
Migrating the crowd simulation plugin into building_sim_plugins package.
Please include the import the menge lib to src directory when compiled the plugins, otherwise, the crowd simulation plugins will not be compiled.
The current using menge lib is as following.
To run the crowd simulation example.
For gazebo:
ros2 launch office.crowd_simulation.launch.xml
For Ign:
office.launch.xml
, you might need to add the model path for common models in https://github.com/FloodShao/traffic_editor/blob/fred/crowd_sim_plugin/building_sim_plugins/building_ignition_plugins/test/office.launch.xml#L7.ros2 launch office.launch.xml
There is an additional issue for ignition plugin:
Current test example for ignition plugin does not assign magni1 and magni2 as external agents, though they are imported in the world. The reason is when processing the crowd simulation initialization, the magni model (plugin) might not be imported in the world yet, which makes the crowd simulation plugin failed to be initialized. This situation isn't considered before because previous demo didn't import other plugin.