openai_ros turtlebot2 example, setup, documentation, UnboundLocalError: 'linear_speed', noetic, melodic, kinetic, ubuntu 20.04, ubuntu 16.04
Hello all,
For anyone trying to run the turtlebot2 example today, I am providing links to threads below that will help you because it is so hard to find out how to make this ROS package work with ROS Noetic + Ubuntu 20.04.
THE CURRENT WIKI ROS PAGE DOES NOT WORK WITH ROS NOETIC AND UBUNTU 20.04
I am running the turtlebot2 example from openai_ros on ROS Development Studio from the Construct with ROS Kinetic, because the examples don't seem to be updated for ROS Noetic (I don't think they are currently supported).
I am currently running into an error when the turtlebot is trying to do action 3.
From the code: Line 125, VSCode gives me an error message
"bad operand type for unary -: _Unspecified pylint(invalid-unary-operand-type)"
linear_speed = -self.linear_turn_speed
And the error message points to
Line 131
self.move_base(linear_speed, angular_speed, epsilon=0.05, update_rate=10)
This is not the full terminal output but most of it:
[WARN] [1650843499.233519, 1801.370000]: Next action is:3
Traceback (most recent call last):
File "/home/user/catkin_ws/src/openai_examples_projects/turtle2_openai_ros_example/scripts/start_qlearning.py", line 74, in <module>
observation, reward, done, info = env.step(action)
File "/usr/local/lib/python2.7/dist-packages/gym/core.py", line 103, in step
return self._step(action)
File "/usr/local/lib/python2.7/dist-packages/gym/wrappers/monitoring.py", line 33, in _step
observation, reward, done, info = self.env.step(action)
File "/usr/local/lib/python2.7/dist-packages/gym/core.py", line 103, in step
return self._step(action)
File "/usr/local/lib/python2.7/dist-packages/gym/wrappers/time_limit.py", line 36, in _step
observation, reward, done, info = self.env.step(action)
File "/home/simulations/public_sim_ws/src/all/openai_ros/openai_ros/src/openai_ros/robot_gazebo_env.py", line 48, in step
self._set_action(action)
File "/home/user/catkin_ws/src/openai_examples_projects/turtle2_openai_ros_example/scripts/turtlebot2/turtlebot2_maze.py", line 162, in _set_action
self.move_base(linear_speed,
UnboundLocalError: local variable 'linear_speed' referenced before assignment
Will update this thread with a fix if I am able to find one.
Thanks.
Some extra context:
I receive these warning messages when I run
roslaunch gym_construct main.launch
Warnings:
[Wrn] [Publisher.cc:141] Queue limit reached for topic /gazebo/default/pose/local/info, deleting message. This warning is printed only once.
[Wrn] [msgs.cc:1808] Conversion of sensor type[depth] not suppported.
[Wrn] [msgs.cc:1808] Conversion of sensor type[imu] not suppported.
[Wrn] [msgs.cc:1808] Conversion of sensor type[gpu_ray] not suppported.
[Wrn] [msgs.cc:1808] Conversion of sensor type[depth] not suppported.
[Wrn] [msgs.cc:1808] Conversion of sensor type[imu] not suppported.
[Wrn] [msgs.cc:1808] Conversion of sensor type[gpu_ray] not suppported.
THREADS FOR HOW I SET UP TO THIS POINT:
Started out with this to setup the packages and dependencies:link text
Debugging steps with ros_pkg resource not found errorlink text
Similar problem and thread to current issuelink text
ISSUE SOLVED
This is a weird one, but I think there may be a misnaming of files in the package "openai_ros_examples_projects".
There is no linear_speed and angular speed set in the turtlebot2_maze.py that I had copied over from the openai_ros package. It is however, set in my_turtlebot2_maze.py which comes with the turtle2_openai_ros_example in the openai_examples_projects package.
So I added:
And special note, I changed
To: