User Tools

Site Tools


turtlebot:adventures:sensing101_hints

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revisionPrevious revision
Next revision
Previous revision
turtlebot:adventures:sensing101_hints [2015/10/06 18:02] pvelaturtlebot:adventures:sensing101_hints [2024/08/20 21:38] (current) – external edit 127.0.0.1
Line 29: Line 29:
 ==== Gyro-Based Square Drawing ==== ==== Gyro-Based Square Drawing ====
  
-This one combines the above two and uses a finite state machine to alternate between them.  The finite state machine should have four states it seems.  One state is for forward driving and uses the ''gostraight'' feedback control algorithm above.  Another is for pure turning and uses the ''turninplace'' feedback control algorithm.  What about the other two?+This one combines the above two and uses a finite state machine to alternate between them.  The finite state machine should have four states it seems.  One state is for forward driving and uses the ''gostraight'' feedback control algorithm above modified to [[Turtlebot:Adventures:Sensing101_ForwardError|regulate the forward velocity]].  Another is for pure turning and uses the ''turninplace'' feedback control algorithm.  What about the other two?
  
 Well, I think they should be to transition from forward driving state to the turning (and vice-versa).  that means the system would really be state 1, prepare for straight driving and identify goal; state 2, perform straight driving to a specified goal; state 3, prepare for turning by identifying goal; state 4, perform turning to a specified orientation.  When state 4 terminates, then it goes back to state 1.  A combination of a while loop with a finite state machine (operating at a certain rate) and a series of odometry subscribers with different callbacks should be employed. Well, I think they should be to transition from forward driving state to the turning (and vice-versa).  that means the system would really be state 1, prepare for straight driving and identify goal; state 2, perform straight driving to a specified goal; state 3, prepare for turning by identifying goal; state 4, perform turning to a specified orientation.  When state 4 terminates, then it goes back to state 1.  A combination of a while loop with a finite state machine (operating at a certain rate) and a series of odometry subscribers with different callbacks should be employed.
Line 38: Line 38:
  
 If you do the above, the Turtlebot may drive in a square forever unless you keep track of the amount of times you've driven forward and turned.  If you do so, then you can figure out an additional terminating condition that could be triggered to end the square maneuver.  This would be extra, but good to figure out. If you do the above, the Turtlebot may drive in a square forever unless you keep track of the amount of times you've driven forward and turned.  If you do so, then you can figure out an additional terminating condition that could be triggered to end the square maneuver.  This would be extra, but good to figure out.
 +
 +When you want to grab the current state (pose) of the Turtlebot but don't want to have to create a subscriber, then it is possible to simply request the information using ''wait_for_message'':
 +<code>
 +  msg = rospy.wait_for_message("my_topic", MyType)
 +</code>
 +The ''msg'' variable (or whatever you call it) will have the data associated to the topic.  Mind you it may wait a bit for the latest data to be made available (depending on the message and its publication frequency).  
 +
 +Also, when you want to stop subscribing to something, there is a function called ''unregister'' that will do the trick.  You need to have the subscriber object available to you though.  The way to do that is to save the subscriber when you start it.  As an example, for ''kobuki_button'' code one would do:
 +<code>
 +  subButtons = rospy.Subscriber("/mobile_base/events/button",ButtonEvent,self.ButtonEventCallback)
 +
 +  ... some code here ...
      
 +  subButtons.unregister()
 +</code>
 +Once the topic has been unregistered, the callback will no longer be called.  More generaly the subscriber will have been killed.  To start appears to require re-instantiating a new subscriber and overwriting the subButtons object with the newly created one.
 +
 --------- ---------
 ;#; ;#;
 [[turtlebot:adventures:Sensing101 | Sensing 101]] [[turtlebot:adventures:Sensing101 | Sensing 101]]
 ;#; ;#;
turtlebot/adventures/sensing101_hints.1444168971.txt.gz · Last modified: 2024/08/20 21:38 (external edit)