Robotics StackExchange | Archived questions

Issue for Moving base with leg tracker msgs

I am trying to run my script to send pose to my movebase from msgs. But it runs the code and waits without throwing any error. My tracker is leg running is running and providing me a Peopletracked 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()

Asked by malav bateriwala on 2018-11-22 16:15:46 UTC

Comments

Answers

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/28950/what-is-the-best-way-to-follow-a-moving-target/

Asked by Procópio on 2018-11-23 05:28:07 UTC

Comments

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.

Asked by Victor Lopez on 2018-11-23 05:37:54 UTC

Comments