LineLeader example
 Raspberry Pi   Started by Eric Pascual   2016-12-05 18:02:48 -05:00   Comments: 7    Viewed: 261

  1. Eric Pascual
    Eric Pascual Member


    Where can I find examples of code using sensors defined in, such as LINELEADER for example ? I can't see how to set the sensor port (e.g. BAS1) for them.

    TIA for any pointer.

    Best regards


    Eric Pascual, 2016-12-05 18:02:48 -05:00
  2. Deepak Patil
    Deepak Patil Administrator Staff Member Richmond
    You don't have to specify Port for I2C sensors. You just need to instantiate the sensor class.

    I don't think there is an example program for LineLeader in the distribution yet,
    but refer to PiStorms/programs/50-SensorDemos/ to see how it's done.
    Deepak Patil, 2016-12-06 10:49:40 -05:00
  3. Eric Pascual
    Eric Pascual Member
    Thanks for replying,

    I've written a short test using the LINELEADER class :
    #!/usr/bin/env python
    import os, sys, inspect, time
    currentdir = os.path.dirname(os.path.abspath(inspect.getfile(inspect.currentframe())))
    parentdir = os.path.dirname(currentdir)
    from mindsensors import LINELEADER
    from PiStorms import PiStorms

    psm = PiStorms()
    ll = LINELEADER()


    psm.screen.askQuestion(['white calibration'], options=['OK'])
    psm.screen.askQuestion(['black calibration'], options=['OK'])
    psm.screen.askQuestion(['Start'], options=['OK'])
        while True:
            psm.screen.termPrintAt(5, "steering = %s" % ll.steering())
            if psm.isKeyPressed():
    except KeyboardInterrupt:


    Unfortunately nothing happens. The LEDs of the array don't lit up at all and the steering() method returns nothing. I've checked the sensor on an EV3 and it works, using its default I2C address (0x02).

    Any suggestion ?

    Eric Pascual, 2016-12-06 17:32:48 -05:00
  4. Deepak Patil
    Deepak Patil Administrator Staff Member Richmond
    I stand corrected, you need to activate the i2c on the port you are connecting the i2c sensor,
    as follows:

    psm = PiStorms()
    ll = LINELEADER()

    psm.BAS1.activateCustomSensorI2C() #Connect the I2C sensor on the port BAS1

    Deepak Patil, 2016-12-07 15:42:24 -05:00
  5. Eric Pascual
    Eric Pascual Member
    Yessss laughing  Thanks for the clue : it works like a charm now smile

    From what I understand from the source code, the LINELEADER class seems to support the first version of the LineLeader too, the one with the embedded PID. If I remember correctly, this V1 has been replaced later by the V2, without the embedded PID (and with cutoffs at the corners of the plate to be distinguished), to be compliant with the rules of a robotics competition (the FIRST LEGO League or something similar). Is my assumption about the LINELEADER code correct ?

    Many thanks again for your efficient support.

    Best regards

    Eric Pascual, 2016-12-07 17:17:37 -05:00
  6. Deepak Patil
    Deepak Patil Administrator Staff Member Richmond
    Actually LineLeader-v1, and LineLeader-v2 both have built in PID.
    LightSensorArray was created based on RoboCup request. It does not have built-in PID.
    Deepak Patil, 2016-12-08 19:22:21 -05:00
  7. Eric Pascual
    Eric Pascual Member
    OK, thanks for the precision. Things are clear now.
    Eric Pascual, 2016-12-12 16:26:14 -05:00
  8. (You must log in or sign up to post here)

Log in | Sign up
Tems & Conditions!