AtsushiSaito / buttons_ros

ROS package for web interface button
0 stars 0 forks source link

About using the button to set the target point for the ros robot #1

Open ju-mingyue opened 3 years ago

ju-mingyue commented 3 years ago

@AtsushiSaito Hello, I am glad to see your file, it is of great help to me. At present, I have some problems in the process of experimenting. I hope you can help me.

  1. I use the mobile app to set a button and publish a topic named /mobile_base/events/button0. I use the following program to subscribe to the topic and publish the target point to move_base. `

    !/usr/bin/env python

      # -*- coding: utf-8 -*-
    
      import roslib
      import rospy
      import actionlib
      from std_msgs.msg import Bool
      from geometry_msgs.msg import Pose, PoseWithCovarianceStamped, Point, Quaternion, Twist  
      from move_base_msgs.msg import MoveBaseAction, MoveBaseGoal
    
      class kobuki_button():
    
          def __init__(self):
              rospy.init_node("kobuki_button")      
    
              #monitor kobuki's button events
              rospy.Subscriber("/mobile_base/events/button0",Bool,self.ButtonEventCallback1)
    
              self.move_base = actionlib.SimpleActionClient("move_base", MoveBaseAction)
              self.goal = MoveBaseGoal()    
              self.goal.target_pose.header.frame_id = 'map'  
              self.goal.target_pose.header.stamp = rospy.Time.now()
              #self.data=False
          def ButtonEventCallback1(self,data):
              #print(data)
              self.target = Pose(Point(-5.543, -4.779, 0.000), Quaternion(0.000, 0.000, 0.645, 0.764)) 
              if data==True:
              self.goal.target_pose.pose = self.target
              self.move_base.send_goal(self.goal)
              rospy.loginfo("Going to: " + str(target))
    
      if __name__ == '__main__':
          try:
          kobuki_button()
    
          rospy.spin()
          except rospy.ROSInterruptException:
          rospy.loginfo("exception")`
  2. Currently the program compiles without errors, but the target point cannot be sent, and the robot cannot receive the target point's information. I don't know how to do it. Hope to get your help.

  3. I hope you can give me some guidance, especially for the use of ros mobile phone software control, and the use of rosbrige, I am a novice.I will be very grateful for your help.

AtsushiSaito commented 3 years ago

@ju-mingyue Maybe I can help.

First, you need to find the problem. Please check the following

  1. Check that "/mobile_base/events/button0" is subscribed correctly in the python code.
  2. Create a simple program to set a destination and check if the robot works.

Please verify these contents and let us know the results.

To understand rosbridge, you may want to read the following reference.