0
$\begingroup$

Rosanswers logo

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?


Originally posted by Zimba96 on ROS Answers with karma: 121 on 2020-10-12

Post score: 0

$\endgroup$

1 Answer 1

0
$\begingroup$

Rosanswers logo

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.


Originally posted by Rayman with karma: 128 on 2020-10-13

This answer was ACCEPTED on the original site

Post score: 1


Original comments

Comment by Zimba96 on 2020-10-13:
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?

Comment by Rayman on 2020-10-13:
Yes, correct!

$\endgroup$