Robotics StackExchange | Archived questions

Error using roslaunch

I am making a package named "random", but i changed the name of this package to "third". It compiles but when I am trying to use roslaunch third brain.launch, the output is:

Traceback (most recent call last):   File "/opt/ros/hydro/bin/roslaunch", line 34, in <module>
    import roslaunch   File "/opt/ros/hydro/lib/python2.7/dist-packages/roslaunch/__init__.py", line 48, in <module>
    from . import core as roslaunch_core   File "/opt/ros/hydro/lib/python2.7/dist-packages/roslaunch/core.py", line 42, in <module>
    import xmlrpclib   File "/usr/lib/python2.7/xmlrpclib.py", line 145, in <module>
    import httplib   File "/usr/lib/python2.7/httplib.py", line 79, in <module>
    import mimetools   File "/usr/lib/python2.7/mimetools.py", line 6, in <module>
    import tempfile   File "/usr/lib/python2.7/tempfile.py", line 34, in <module>
    from random import Random as _Random ImportError: cannot import name Random Error in sys.excepthook: Traceback (most recent call last):   File "/usr/lib/python2.7/dist-packages/apport_python_hook.py", line 66, in apport_excepthook
    from apport.fileutils import likely_packaged, get_recent_crashes   File "/usr/lib/python2.7/dist-packages/apport/__init__.py", line 1, in <module>
    from apport.report import Report   File "/usr/lib/python2.7/dist-packages/apport/report.py", line 12, in <module>
    import subprocess, tempfile, os.path, urllib, re, pwd, grp, os   File "/usr/lib/python2.7/tempfile.py", line 34, in <module>
    from random import Random as _Random ImportError: cannot import name Random

Original exception was: Traceback (most recent call last):   File "/opt/ros/hydro/bin/roslaunch", line 34, in <module>
    import roslaunch   File "/opt/ros/hydro/lib/python2.7/dist-packages/roslaunch/__init__.py", line 48, in <module>
    from . import core as roslaunch_core   File "/opt/ros/hydro/lib/python2.7/dist-packages/roslaunch/core.py", line 42, in <module>
    import xmlrpclib   File "/usr/lib/python2.7/xmlrpclib.py", line 145, in <module>
    import httplib   File "/usr/lib/python2.7/httplib.py", line 79, in <module>
    import mimetools   File "/usr/lib/python2.7/mimetools.py", line 6, in <module>
    import tempfile   File "/usr/lib/python2.7/tempfile.py", line 34, in <module>
    from random import Random as _Random ImportError: cannot import name Random

The brain.launch file is:

<launch>
  <!--Launch the control of the motors for the turtlebot-->
  <include file="$(find turtlebot_bringup)/launch/minimal.launch"/>
  <node name="brain" pkg="third" type="brain"/>

  <!--Launch the 3d sensor of the kinect-->
  <include file="$(find turtlebot_bringup)/launch/3dsensor.launch"/>

  <arg name="map_file" value="/home/robot/Desktop/epsilon/maps/maps1/map1.yaml"/>
  <node name="map_server" pkg="map_server" type="map_server" args="$(arg map_file)"/>

  <arg name="initial_pose_x" default="0.0"/> 
  <arg name="initial_pose_y" default="0.0"/> 
  <arg name="initial_pose_a" default="0.0"/>
  <!--Launch the amcl or stack navigation of the turtlebot-->
  <include file="$(find turtlebot_navigation)/launch/includes/amcl.launch.xml">
    <arg name="initial_pose_x" value="$(arg initial_pose_x)"/>
    <arg name="initial_pose_y" value="$(arg initial_pose_y)"/>
    <arg name="initial_pose_a" value="$(arg initial_pose_a)"/>
  </include>

  <include file="$(find turtlebot_navigation)/launch/includes/move_base.launch.xml"/>

  <!--Run the node that allows us to know where is the turtlebot in the map-->
  <node name="robot_pose_publisher" pkg="robot_pose_publisher" type="robot_pose_publisher"/>
</launch>

And the brain.cpp file is:

#include "std_msgs/String.h"
#include "sound_play/sound_play.h"
#include "ros/ros.h"
#include <string>

class Listener {
  public:
    void cb(const std_msgs::String::ConstPtr& msg);
};

void Listener::cb(const std_msgs::String::ConstPtr& msg) {
  //TODO
}

int main(int argc, char **argv) {
  ros::init(argc, argv, "brain");
  ros::NodeHandle nh_;

  Listener listener;
  ros::Subscriber sub = nh_.subscribe("robot_listen", 1000, &Listener::cb, &listener);

  ros::spin();
  return 0;
}

So I don't know the reason of this error if I am not using the "random" word anymore in this pakage. (Was created with this name but afterwars, I have changed everything). What is the reason of this error at the launch time?

UPDATE 1:

CMakelist.txt file:

cmake_minimum_required(VERSION 2.8.3)
project(third)

## Find catkin macros and libraries
## if COMPONENTS list like find_package(catkin REQUIRED COMPONENTS xyz)
## is used, also find other catkin packages
find_package(catkin REQUIRED COMPONENTS
  genmsg
  actionlib
  actionlib_msgs
  message_generation
  pocketsphinx
  roscpp
  sound_play
  std_msgs
)
find_package(Boost REQUIRED COMPONENTS system)

# Generate actions in the 'action' folder
 add_action_files(
   DIRECTORY action
   FILES Talker.action
 )

## Generate added messages and services with any dependencies listed here
generate_messages(
  DEPENDENCIES
  actionlib_msgs std_msgs  # Or other packages containing msgs
)

###################################
## catkin specific configuration ##
###################################
## The catkin_package macro generates cmake config files for your package
## Declare things to be passed to dependent projects
## INCLUDE_DIRS: uncomment this if you package contains header files
## LIBRARIES: libraries you create in this project that dependent projects also need
## CATKIN_DEPENDS: catkin_packages dependent projects also need
## DEPENDS: system dependencies of this project that dependent projects also need
catkin_package(
#  INCLUDE_DIRS include
#  LIBRARIES robot_listen
   CATKIN_DEPENDS pocketsphinx roscpp sound_play std_msgs
#  DEPENDS system_lib
)

###########
## Build ##
###########

## Specify additional locations of header files
## Your package locations should be listed before other locations
# include_directories(include)
include_directories(include ${catkin_INCLUDE_DIRS} ${Boost_INCLUDE_DIRS})

## Declare a cpp executable
  add_executable(listener_server src/listener_server.cpp)
  add_executable(brain src/brain.cpp)
  add_executable(talker_server src/talker_server.cpp)

## Add cmake target dependencies of the executable/library
## as an example, message headers may need to be generated before nodes
  add_dependencies(listener_server ${PROJECT_NAME}_gen_cpp)
  add_dependencies(brain ${PROJECT_NAME}_gen_cpp)
  add_dependencies(talker_server ${PROJECT_NAME}_gen_cpp)

## Specify libraries to link a library or executable target against
  target_link_libraries(listener_server ${catkin_LIBRARIES})
  target_link_libraries(brain ${catkin_LIBRARIES})
  target_link_libraries(talker_server ${catkin_LIBRARIES})

Asked by pexison on 2015-07-31 06:18:48 UTC

Comments

Have you tried to do another clean build? I.e. removing the build and devel folder and issuing another catkin_make? Also, it is important that the project name in the CMakeLists.txt is changed as well.

Asked by mgruhler on 2015-07-31 06:47:21 UTC

This looks odd. Does roslaunch work with other packages?

Asked by dornhege on 2015-07-31 07:08:18 UTC

Yes, for the basic teleop tutorial of the Turtlebot it works!

Asked by pexison on 2015-07-31 07:59:23 UTC

You might have a problem with the random name. Try to remove that from everywhere and see if that fixes it.

Asked by dornhege on 2015-07-31 08:04:51 UTC

Answers