Ask Your Question
0

Issue for Moving base with leg tracker msgs

asked 2018-11-22 15:15:46 -0500

malav bateriwala gravatar image

updated 2018-11-22 18:23:48 -0500

I am trying to run my script to send pose to my move_base from msgs. But it runs the code and waits without throwing any error. My tracker is leg running is running and providing me a People_tracked msg of PeopleArray(Person[] people) Person (geometry_msgs/Pose pose uint32 id). Can't figure out the problem as there is no error.

 class move_base_goal:
   def __init__(self):
      self.goal_pose = PersonArray()

  self.new_person = Person()
  self.goal_pose.people.append(self.new_person)

  if not self.goal_pose.people:
         return move_base_goal()
  rospy.init_node('movebase_goal_py')
  rospy.Subscriber("people_tracked", PersonArray, self.callback )

  def callback(self,msg):
    self.goal_pose.people[0].pose.position.x = msg.people[0].pose.position.x
    self.goal_pose.people[0].pose.position.y = msg.people[0].pose.position.y


  def movebase_goal(msg):   

    move = actionlib.SimpleActionClient('move_base',MoveBaseAction)
    move.wait_for_server()


    goal = MoveBaseGoal()
    goal.target_pose.header.frame_id = "base_link"
    goal.target_pose.header.stamp = rospy.Time.now()
    goal.target_pose.pose.position.x = self.goal_pose.people[0].pose.x
    goal.target_pose.pose.position.y = self.goal_pose.people[0].pose.y
    goal.target_pose.pose.orientation.w = 1.0

    move.send_goal(goal)

if __name__ == '__main__':

    x = move_base_goal()
   rospy.spin()
edit retag flag offensive close merge delete

2 Answers

Sort by » oldest newest most voted
1

answered 2018-11-23 04:28:07 -0500

Procópio gravatar image

updated 2018-11-23 04:29:09 -0500

You are not calling your movebase_goal method anywhere, so you are not sending the goal to move_base.

Besides that, if you send a new goal each time you have a people_tracked callback, you will be constantly cancelling/sending new goals, which would result in a very erratic behaviour.

For more info on that, check this question: https://answers.ros.org/question/2895...

edit flag offensive delete link more
0

answered 2018-11-23 04:37:54 -0500

Victor Lopez gravatar image

There are several issues with your code, that if haven't failed yet, will fail when you execute it.

For instance the move_base_goal function requires the self argument, but you are not providing, and are providing an unused argument.

You have code within your class (call to init_node and Subscriber) that doesn't belong there, you should move it at least to your "main".

I suggest you go through the ROS tutorials again, you will find there tools to help you diagnose better what is happening.

edit flag offensive delete link more

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools

1 follower

Stats

Asked: 2018-11-22 15:15:46 -0500

Seen: 145 times

Last updated: Nov 23 '18