Week 14: Building auto mode, configuring sensor, building simulation environment

     These two weeks, we purchased light intensity sensor online and tried to connect it with Pi, but we get trouble of configuration, and the respond of command line I2cdetect -y 1 showed that there's no connection between Pi and sensor. So we then used arduino uno to test whether sensor was broken, and the result was somehow disappointing, we can't get reasonable data from sensor which meant the sensor was highly likely broken.
       As a result, besides buying a new sensor, we also decided to using some random number generation method to build a simulation environment as an alternative way so that we can have some input data for our robot so that we can build and test robot's auto mode.
       Because in assignment 3 we successfully interrupted the bumper reaction process, we then implemented our auto mode based on that work. Our first job is build a auto mode prototype. So we just write a function to implement that feature and a GUI button to call that function. The Psudo-code is as follows.

def auto():
      currentvalue = random.randint(0,4000) #The light sensor will generate a number
      maxvalue=currentvalue
      maxindex=0 # store the value which indicates the direction has the brightest light
      for i in range (1,4):
             rotate pi/2 clockwise
             currentvalue=random.randint(0,4000)
             if currentvalue>maxvalue:
                    maxvalue=currentvalue
                    maxindex=i
      rotatenumber= 3-i #indicate how much will the robot rotate back in order to 
                                     #move towards the brightest direction.
      if rotatenumber>0
             for i in range (0,rotatenumber)
                   rotate pi/2 anticlockwise # we choose to make robot rotate back because
                                                             # it can make the robot heading exactly
                                                            #  towards the brightest direction it detected.
     moveforward()
     wait for 3 sec
     repeat this process until we interrupt it

       And after some debugging the robot behaved just as what we've expected and we also interrupted it because of our work in assignment 3. So building auto mode is successful. The only problem left is to get a right sensor and combine it with our robot.
What we will do:
      We are now not only waiting for the sensor but also improving the auto mode such as make robot rotate pi/4 each time of detection, can stop when it get close to the light source or flame,etc. However, considering there exists possibility that the sensor will still not work, if this happen we will focus on auto mode it self based on the simulation environment.
       We're confident that we'll make it work well.


   

Comments

Popular posts from this blog

Week 12: Building manual mode, figure out the problem and plan for the next couple of weeks.

Week 10:Learning iRobot