ROS Resources: Documentation | Support | Discussion Forum | Index | Service Status | ros @ Robotics Stack Exchange
Ask Your Question
0

openai_ros start_training.launch does not work (q-learning example)

asked 2020-08-23 08:02:34 -0500

autonomousfan gravatar image

hi! I have tried to run the turtlebot2 q learning example from OpenAI and until now I managed to run the launchfile where gazebo starts:

roslaunch gym_construct main.launch

After typing:

roslaunch turtle2_openai_ros_example start_training.launch

the launchfile starts but then it shows the following error:

henry@henry:~/catkin_ws$ roslaunch turtle2_openai_ros_example start_training.launch 
... logging to /home/henry/.ros/log/504dc8b6-e53e-11ea-b60d-b8763ff5fae7/roslaunch-henry-10939.log
Checking log directory for disk usage. This may take a while.
Press Ctrl-C to interrupt
Done checking log file disk usage. Usage is <1GB.

started roslaunch server http://henry:39203/

SUMMARY
========

PARAMETERS
 * /rosdistro: melodic
 * /rosversion: 1.14.7
 * /turtlebot2/alpha: 0.1
 * /turtlebot2/angular_speed: 0.3
 * /turtlebot2/desired_pose/x: 5.0
 * /turtlebot2/desired_pose/y: 0.0
 * /turtlebot2/desired_pose/z: 0.0
 * /turtlebot2/end_episode_points: 200
 * /turtlebot2/epsilon: 0.9
 * /turtlebot2/epsilon_discount: 0.999
 * /turtlebot2/forwards_reward: 5
 * /turtlebot2/gamma: 0.7
 * /turtlebot2/init_linear_forward_speed: 0.0
 * /turtlebot2/init_linear_turn_speed: 0.0
 * /turtlebot2/linear_forward_speed: 0.5
 * /turtlebot2/linear_turn_speed: 0.05
 * /turtlebot2/max_laser_value: 6
 * /turtlebot2/min_laser_value: 0
 * /turtlebot2/min_range: 0.5
 * /turtlebot2/n_actions: 4
 * /turtlebot2/n_observations: 6
 * /turtlebot2/nepisodes: 500
 * /turtlebot2/new_ranges: 5
 * /turtlebot2/nsteps: 10000
 * /turtlebot2/number_splits: 10
 * /turtlebot2/pos_step: 0.016
 * /turtlebot2/running_step: 0.06
 * /turtlebot2/speed_step: 1.0
 * /turtlebot2/turn_reward: 1
 * /turtlebot2/wait_time: 0.1

NODES
  /
    turtlebot2_maze (turtle2_openai_ros_example/start_qlearning.py)

ROS_MASTER_URI=http://localhost:11311 process[turtlebot2_maze-1]: started with pid [10959] [ERROR] [1598186669.537051, 27.380000]: NOT Initialising Simulation Physics Parameters [WARN] [1598186669.544562, 27.387000]: Start Init ControllersConnection [WARN] [1598186669.546238, 27.387000]: END Init ControllersConnection
/home/henry/.local/lib/python2.7/site-packages/gym/logger.py:30: UserWarning: WARN: Box bound precision lowered by casting to float32
  warnings.warn(colorize('%s: %s'%('WARN', msg % args), 'yellow'))
Traceback (most recent call last):
  File "/home/henry/catkin_ws/src/openai_examples_projects/turtle2_openai_ros_example/scripts/start_qlearning.py", line 25, in <module>
    pkg_path = rospack.get_path('my_turtlebot2_maze')
  File "/usr/lib/python2.7/dist-packages/rospkg/rospack.py", line 207, in get_path
    raise ResourceNotFound(name, ros_paths=self._ros_paths)
rospkg.common.ResourceNotFound: my_turtlebot2_maze
ROS path [0]=/opt/ros/melodic/share/ros
ROS path [1]=/home/henry/catkin_ws/src
ROS path [2]=/opt/ros/melodic/share
[turtlebot2_maze-1] process has died [pid 10959, exit code 1, cmd /home/henry/catkin_ws/src/openai_examples_projects/turtle2_openai_ros_example/scripts/start_qlearning.py __name:=turtlebot2_maze __log:=/home/henry/.ros/log/504dc8b6-e53e-11ea-b60d-b8763ff5fae7/turtlebot2_maze-1.log]. log file: /home/henry/.ros/log/504dc8b6-e53e-11ea-b60d-b8763ff5fae7/turtlebot2_maze-1*.log
all processes on machine have died, roslaunch will exit
shutting down processing monitor...
... shutting down processing monitor complete
done 

I did not change anything in the start_qlearning.py file but it seems that it wants my_turtlebot2_maze as a package but there is only a my_turtblebot2_maze.py file. Can somebody help me please Thank you

edit retag flag offensive close merge delete

Comments

Hi, did you solve this? I am having the same problem. Any help would be appreciated. Thanks. [Update: Fixed it, see the answer by me]

prav2909 gravatar image prav2909  ( 2020-11-28 14:39:29 -0500 )edit

1 Answer

Sort by » oldest newest most voted
1

answered 2020-11-29 07:16:34 -0500

prav2909 gravatar image

Hi, I fixed it and got it running, you need to change line 30: "​pkg_path = rospack.get_path('turtle2_openai_ros_example')" of start_training.py to "pkg_path = rospack.get_path('my_turtlebot2_training')". Revert if this doesn't work.

edit flag offensive delete link more

Comments

Hi there, I'm having the same issue but don't know which file you are exactly referring to. Do you mean start_qlearning.py? And if so:

Do you mean line 25 of start_qlearning.py? Line 30 is blank. If you do mean liine 25 which is:

" pkg_path = rospack.get_path('my_turtlebot2_maze') " What did you change it to?

Thanks

wirobot gravatar image wirobot  ( 2022-04-24 18:35:59 -0500 )edit

For anyone else running into this issue, I fixed it by changing line 25 of start_qlearning.py to:

pkg_path = rospack.get_path('turtle2_openai_ros_example')

That is just the name of the "ros package" in openai_examples_projects.

I also had to copy the files from openai_ros robot_envs and task_envs to the scripts folder of turtle2_openai_ros_example.

I did that so that start_qlearning had the right files within the same folder to import from.

I also changed the import statement in start_qlearning.py to:

    from turtlebot2 import turtlebot2_maze

And I changed the import statement in my_turtlebot2_maze.py to

    import turtlebot2_env

You may need to change this to fit your own file structure.

Finally, make sure to change timestep_limit in the register function at the beginning of my_turtlebot2_maze.py to:

    max_episode_steps=timestep_limit_per_episode,

This is basically a change of params in gym that was made that they haven't updated in the

wirobot gravatar image wirobot  ( 2022-04-24 18:48:13 -0500 )edit

I will start a new thread to address this new error I'm running into at action 3 of running start_training.launch: UnboundLocalError: local variable 'linear_speed' referenced before assignment

wirobot gravatar image wirobot  ( 2022-04-24 18:52:48 -0500 )edit

Question Tools

2 followers

Stats

Asked: 2020-08-23 08:02:34 -0500

Seen: 334 times

Last updated: Nov 29 '20