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

Actionlib: AttributeError: 'PoseStamped' object has no attribute 'use_start_pose'

asked 2020-10-12 14:35:26 -0500

Zimba96 gravatar image

updated 2022-07-24 11:06:19 -0500

lucasw gravatar image

I'm trying to use move base flex inside a SMACH state machine and want to call the get_path-action. The corresponding action-msg looks like this:

bool use_start_pose
geometry_msgs/PoseStamped start_pose
geometry_msgs/PoseStamped target_pose
float64 tolerance
string planner
uint8 concurrency_slot

---

# Predefined success codes:
uint8 SUCCESS         = 0
# 1..9 are reserved as plugin specific non-error results

# Possible error codes:
...

uint32 outcome
string message

nav_msgs/Path path

float64 cost

---

Since I have the target_pose stored in an array, I need to pass it to the get_path-actionServer via the goal_cb-Param of the smach_ros.SimpleActionState. Therefore, my code looks as follows:

sm.userdata.next_goal = [target_pose]
smach.StateMachine.add('GET_GLOBAL_PATH_IN_GOAL_CHECK_SM',
                                          smach_ros.SimpleActionState(
                                              '/move_base_flex/get_path',
                                              GetPathAction,
                                              result_cb = getPathCallback,
                                              goal_cb=set_goal_callback,
                                              input_keys=['next_goal', ...]),
                                          transitions={...})

with the goal_cb as:

def set_goal_callback(userdata, goal):
    if(userdata.next_goal[0]!=None):
        return userdata.next_goal[0]
    else:
        raise Exception("userdata.next_goal is empty.")

Doing so, I get the following error:

[ERROR] [1602531192.400746, 0.000000]: InvalidUserCodeError: Could not execute state 'GET_GLOBAL_PATH_IN_GOAL_CHECK_SM' of type '<smach_ros.simple_action_state.SimpleActionState object at 0x7fa458342c18>': Traceback (most recent call last):
  ...Traceback...
  File "/home/faps/catkin_ws/devel/lib/python3/dist-packages/mbf_msgs/msg/_GetPathActionGoal.py", line 165, in serialize
    buff.write(_get_struct_B3I().pack(_x.goal.use_start_pose, _x.goal.start_pose.header.seq, _x.goal.start_pose.header.stamp.secs, _x.goal.start_pose.header.stamp.nsecs))
AttributeError: 'PoseStamped' object has no attribute 'use_start_pose'

How do I have to modify my goal_cb to provide the Action with the required use_start_pose-bool and the start_pose-Pose? And furthermore, when I want to get the global path from my current position to the specified goal, do I even need to set the start_pose or does the get_path automatically plan from my current position when use_start_pose is false?

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted
1

answered 2020-10-13 02:53:06 -0500

Rayman gravatar image

There are 3 ways to get a goal into a SimpleActionClient:

  1. goal: Directly pass a goal
  2. goal_key: Pass a goal from a user_data key
  3. goal_cb: Execute a callback which builds the goal

I think in your case, method 1 would be the easiest. You could try something like this:

smach_ros.SimpleActionState(
      '/move_base_flex/get_path',
      GetPathAction,
      goal=GetPathGoal(...)

Edit: Your mistake is probably that you give a PoseStamped to the action, instead of a GetPathGoal.

edit flag offensive delete link more

Comments

Thanks for your Answer, I'll try that! For the correct understanding: the start-pose or use-start-pose-option is only relevant when you don't want to plan from your current position and therefore need to specify a start-pose, right?

Zimba96 gravatar image Zimba96  ( 2020-10-13 03:19:12 -0500 )edit

Yes, correct!

Rayman gravatar image Rayman  ( 2020-10-13 04:01:02 -0500 )edit

Question Tools

2 followers

Stats

Asked: 2020-10-12 14:35:26 -0500

Seen: 2,015 times

Last updated: Oct 13 '20