Python-learning-SMACH-QA

  • Question

    /usr/bin/python3.4 /home/evan/PycharmProjects/smach_projects/GettingStarted.py
Traceback (most recent call last):
  File "/home/evan/PycharmProjects/smach_projects/GettingStarted.py", line 2, in
    import roslib;roslib.load_manifest('smach_projects')
  File "/opt/ros/indigo/lib/python2.7/dist-packages/roslib/__init__.py", line 50, in
    from roslib.launcher import load_manifest
  File "/opt/ros/indigo/lib/python2.7/dist-packages/roslib/launcher.py", line 42, in
    import rospkg
ImportError: No module named 'rospkg'

Process finished with exit code 1


  • Answer

Because we didnot install python3.4 package in the ros folder(/opt/ros/indigo/lib) , we just installed rospkg for python 2.7.6 so can not find the rospkg for python 3.4. We can manually install rospkg for python 3.4 but notice that only one rospkg can be installed that means we can not install rospkg for both python 2.7 and python 3.4.


  • Question
    • Answer:-smach_viewer的Graph view不能显示状态图

  • Question
    [ERROR] [WallTime: 1496741655.591969] Error raised during SMACH container construction:
    Traceback (most recent call last):

      File "/home/evan/workspace/roboware/my_catkin_ws/src/smach_package/src/cleanContainer.py", line 123, in main
        smach.StateMachine.add('find_area', State_find_area(),

      File "/home/evan/workspace/roboware/my_catkin_ws/src/smach_package/src/cleanContainer.py", line 63, in __init__
        result_cb = self.cb_result)

      File "/home/evan/workspace/roboware/my_catkin_ws/src/smach_package/src/cleanContainer.py", line 37, in __init__
        smach_ros.SimpleActionState.__init__(self,action_name,action_spec,goal,goal_key,goal_slots,goal_cb,goal_cb_args
    , result_key,result_slots,result_cb,result_cb_args,result_cb_kwargs,input_keys,output_keys,outcomes, exec_timeout,p
    reempt_timeout,server_wait_timeout)

      File "/opt/ros/indigo/lib/python2.7/dist-packages/smach_ros/simple_action_state.py", line 173, in __init__
        if not all([s in action_spec().action_result.result.__slots__ for s in result_slots]):

    TypeError: 'instancemethod' object is not iterable

    Traceback (most recent call last):
      File "/home/evan/workspace/roboware/my_catkin_ws/src/smach_package/src/cleanContainer.py", line 135, in
        main()
      File "/home/evan/workspace/roboware/my_catkin_ws/src/smach_package/src/cleanContainer.py", line 123, in main
        smach.StateMachine.add('find_area', State_find_area(),
      File "/home/evan/workspace/roboware/my_catkin_ws/src/smach_package/src/cleanContainer.py", line 63, in __init__
        result_cb = self.cb_result)
      File "/home/evan/workspace/roboware/my_catkin_ws/src/smach_package/src/cleanContainer.py", line 37, in __init__
        smach_ros.SimpleActionState.__init__(self,action_name,action_spec,goal,goal_key,goal_slots,goal_cb,goal_cb_args
    , result_key,result_slots,result_cb,result_cb_args,result_cb_kwargs,input_keys,output_keys,outcomes, exec_timeout,p
    reempt_timeout,server_wait_timeout)
      File "/opt/ros/indigo/lib/python2.7/dist-packages/smach_ros/simple_action_state.py", line 173, in __init__
        if not all([s in action_spec().action_result.result.__slots__ for s in result_slots]):
    TypeError: 'instancemethod' object is not iterable
    • Answer
           def   __init__ ( self # Action info
                   action_name  =  'default_action' ,
                   action_spec  = defaultAction,
                   # Default goal 
                   goal  =  None ,
                   goal_key  =  None ,
                   goal_slots  = [],
                   goal_cb  =  None ,
                   goal_cb_args  = [],
                   goal_cb_kwargs  = {},
                   # Result modes
                   result_key  =  None ,
                   result_slots  = [],
                   result_cb  =  None ,
                   result_cb_args  = [],
                   result_cb_kwargs  = {},
                   # Keys
                   input_keys  = [],
                   output_keys  = [],
                   outcomes  = [],
                   # Timeouts
                   exec_timeout  =  None ,
                   preempt_timeout  = rospy.Duration( 60.0 ),
                   server_wait_timeout  = rospy.Duration( 60.0 )):
              smach_ros.SimpleActionState. __init__ ( self ,action_name,action_spec,goal,goal_key,goal_slots,goal_cb,goal_cb_args,goal_cb_kwargs(forget adding this param to cause the wrong param order), result_key,result_slots,result_cb,result_cb_args,result_cb_kwargs,input_keys,output_keys,outcomes, exec_timeout,preempt_timeout,server_wait_timeout)

  • Question
    [ERROR] [WallTime: 1496742757.805075] InvalidTransitionError: State machine failed consistency check:
            State 'find_area' references unregistered outcomes: ['preempted', 'aborted']

            Available states: ['finish', 'BAR', 'find_area']
    [ERROR] [WallTime: 1496742757.805399] Container consistency check failed.

    • Answer
      smach.StateMachine.add( 'find_area' , State_find_area(), 
                                      transitions ={ 'succeeded' : 'finish'
                                                   'fail' : 'find_area' ,
                                                  'aborted':'aborted',
                                                  'preempted':'aborted' },#forget adding these two lines,so the state machine can not form complete outcome diagram.
                                      remapping ={ 'find_wall_area' : 'area' })

  • Question
    [ERROR] [WallTime: 1496743305.298023] InvalidUserCodeError: Reading from SMACH userdata key 'find_wall_area' but the only keys that were declare
    d as input to this state were: (). This key needs to be declaread as input to this state.
    [ERROR] [WallTime: 1496743305.298158] State 'find_area' failed to execute.

    • Answer
      smach.StateMachine.add( 'find_area' , State_find_area(), 
                                      transitions ={ 'succeeded' : 'plan_path'
                                                   'fail' : 'find_area' ,
                                                   'aborted' : 'aborted' ,
                                                   'preempted' : 'aborted' },
                                      remapping ={ 'find_wall_area' : 'area' ,#This line for input_key named 'find_wall_area'
                                                   'find_wall_area' : 'area' })#This line for output_key named 'find_wall_area'
  • Question
    When adding a new action file area.action , there is an error happened when building.
     Generating .msg files for action smach_package/area /home/evan/workspace/roboware/my_catkin_ws/src/smach_package/action/area.action
    Traceback (most recent call last):
      File "/opt/ros/indigo/share/actionlib_msgs/cmake/../../../lib/actionlib_msgs/genaction.py", line 136, in 
        if __name__ == '__main__': main()
      File "/opt/ros/indigo/share/actionlib_msgs/cmake/../../../lib/actionlib_msgs/genaction.py", line 97, in main
        raise ActionSpecException("%s: wrong number of pieces, %d"%(filename,len(pieces)))
    __main__.ActionSpecException: /home/evan/workspace/roboware/my_catkin_ws/src/smach_package/action/area.action: wrong number of pieces, 1
    Generating for action area
    CMake Error at /opt/ros/indigo/share/catkin/cmake/safe_execute_process.cmake:11 (message):
    • Answer
      #goal definition
      geometry_msgs::PointStamped  origin

      #result definition
      geometry_msgs::PolygonStamped area

      #feedback definition
      geometry_msgs::PolygonStamped area
      replace the double comma to reverse slash and add two seperators
      #goal definition
      geometry_msgs/PointStamped  origin
      ---
      #result definition
      geometry_msgs/PolygonStamped area
      ---
      #feedback definition
      geometry_msgs/PolygonStamped area
    • if there is another error occurring
      CMake Error at /home/evan/workspace/roboware/my_catkin_ws/build/smach_package/cmake/smach_package-genmsg.cmake:3 (message):
        Could not find messages which
        '/home/evan/workspace/roboware/my_catkin_ws/devel/share/smach_package/msg/areaAction.msg'
        depends on.  Did you forget to specify generate_messages(DEPENDENCIES ...)?

        Cannot locate message [PointStamped]: unknown package [geometry_msgs] on
        search path [{{'smach_package':
        ['/home/evan/workspace/roboware/my_catkin_ws/devel/share/smach_package/msg'],
        'actionlib_msgs': ['/opt/ros/indigo/share/actionlib_msgs/cmake/../msg'],
        'std_msgs': ['/opt/ros/indigo/share/std_msgs/cmake/../msg']}}]
      • Answer
        ## Generate added messages and services with any dependencies listed here
        generate_messages(DEPENDENCIES
          actionlib_msgs
          geometry_msgs   ## Add this line for support the geometry_msgs/polygonStamped message
          std_msgs
        )
        find_package (catkin REQUIRED COMPONENTS
          actionlib_msgs
          message_generation
          rospy
          std_msgs
          geometry_msgs  ## Add this line when using geometry_msgs to generate messages
        )
  • Question
    e_action_server.py", line 289, in executeLoop
        self.execute_callback(goal)
      File "/home/evan/catkin_ws/src/sim_platform/src/path_planner.py",
     line 99, in execute_cb
        self._sas.set_succeeded(result)
      File "/opt/ros/indigo/lib/python2.7/dist-packages/actionlib/simpl
    e_action_server.py", line 162, in set_succeeded
        self.current_goal.set_succeeded(result, text)
      File "/opt/ros/indigo/lib/python2.7/dist-packages/actionlib/serve
    r_goal_handle.py", line 195, in set_succeeded
        self.action_server.publish_result(self.status_tracker.status, r
    esult)
      File "/opt/ros/indigo/lib/python2.7/dist-packages/actionlib/actio
    n_server.py", line 182, in publish_result
        self.result_pub.publish(ar)
      File "/opt/ros/indigo/lib/python2.7/dist-packages/rospy/topics.py
    ", line 856, in publish
        raise ROSSerializationException(str(e))
    ROSSerializationException: : 'required argume
    nt is not a float' when writing 'x: 0
    y:
      - 0.208178028592
      - -0.0186330676772
      - 0
    z: 0.0'
    • Answer
      for  index,waypoint in  enumerate ( self .path):  ## forget add index ,enumerate will firstly set index .Otherwise waypoint[0] will be set as index.

你可能感兴趣的:(Python)