ROBOTIS-GIT / turtlebot3_machine_learning

Apache License 2.0
121 stars 82 forks source link

keras submodule of tensorflow2.X for ros2 foxy #59

Closed tidota closed 3 years ago

tidota commented 3 years ago

Hi ROBOTIS,

This PR contains changes to solve errors when running turtlebot3_dqn on ROS2 Foxy.

Ubuntu Focal, on which ROS2 Foxy is supported, uses Tensorflow2.0 or above. When running dqn_agent on ROS2 Foxy, I experienced the following error: AttributeError: module 'keras.utils.generic_utils' has no attribute 'populate_dict_with_module_objects' Apparently, the Keras package has a compatibility problem as reported here: https://github.com/keras-team/keras/issues/14632 In their discussion, it was suggested to use the Keras submodule of Tensorflow2.X instead of the separate Keras package. This PR applied this suggested approach.

Because the submodule is available since Tensorflow2.0, it also checks the major version of Tensorflow and uses the separate Keras package when running with Tensorflow1.X. This version check was also applied to the line of model.compile( ... because the argument lr for RMSprop is deprecated and learning_rate is prefered to be used.

Additionally, dqn_gazebo.py was changed. It finds the path to goal_box model from the installed directories of turtlebot3_gazebo.

For summary, this PR contains:

I understand the Foxy version of turtlebot3_dqn is not officially supported yet. If these changes are not appropriate, please close this PR.

Thank you

ROBOTIS-Will commented 3 years ago

@tidota Thank you for your contribution!