File tree Expand file tree Collapse file tree 1 file changed +18
-0
lines changed
Expand file tree Collapse file tree 1 file changed +18
-0
lines changed Original file line number Diff line number Diff line change @@ -751,6 +751,24 @@ def read_position(self):
751751 return "right"
752752 return "unknown"
753753
754+ def read_position_str (self ):
755+ """
756+ returns a string of five letters indicating what the line sensor is seeing.
757+ 'b' indicates that specific sensor has detected a black line.
758+ 'w' indicates that specific sensor has not detected a black line.
759+
760+ :returns: String indicating what the line follower just read.
761+ :rtype: str
762+
763+ Here's an example of what could get returned:
764+ * ``'bbbbb'`` - when the line follower reads black on all sensors.
765+ * ``'wwbww'`` - when the line follower is perfectly centered.
766+ * ``'bbbww'`` - when the line follower reaches an intersection.
767+ """
768+ five_vals = self .read ()
769+ out_str = "" .join (["b" if sensor_val == 1 else "w" for sensor_val in five_vals ])
770+ return out_str
771+
754772
755773#######################################################################
756774#
You can’t perform that action at this time.
0 commit comments