How does it work

Starting with a central location, a destination at specific distance is randomly calculated with a trigonometry formula. Having an origin and destination, walking directions are requested to Google Maps API. At this point feet starts moving towards destination, pictures are taken with Google Street View API and at arrival a diary entry is created with generative Artificial Intelligence.

Parts used

    • Raspberry Pi 2 with USB WiFi dongle
    • DFRobot TFT screen 800x468
    • 2 SG90 Servo motors
    • 2 rubber foot
    • 3d printed parts

Circuit

There is not much from electronic in this project. Just the servo motors connected to GPIO2 and GPIO3 and external Power. The DFRobot screen is connected to the Raspberry Pi with a simple ribbon and it does not even required libraries or special software.

Software APIs

The Walk uses 3 APIs. 

    • 1. Google Maps API https://developers.google.com/maps for reverse geolocation (getting address from lat-lng), to get directions and also to plot maps and get snapshots. 
    • 2. Openweathermap API https://openweathermap.org/api to get the weather for given lat-long. This is used to create the journey entry.
    • 3. OpenAI API https://platform.openai.com/docs/api-reference to write journey entries

Random location at a distance

To get a random location at a distance first a bearing is obtained. A bearing could be defined as a direction or an angle, between the north-south line of earth or meridian and the line connecting the target and the reference point.

myBearing = randint(1, 360)

def get_point_at_distance(lat1, lon1, d, bearing, R=6371):
    lat1 = math.radians(lat1)
    lon1 = math.radians(lon1)
    a = math.radians(bearing)
    lat2 = math.asin(math.sin(lat1) * math.cos(d/R) + math.cos(lat1) * math.sin(d/R) * math.cos(a))
    lon2 = lon1 + math.atan2(math.sin(a) * math.sin(d/R) * math.cos(lat1), math.cos(d/R) - math.sin(lat1) * math.sin(lat2))
    return (math.degrees(lat2), math.degrees(lon2),)

Directions and steps

With a starting point, a random bearing and the new point at specific distance, a Google Maps API Direction call is executed. The answer is a Json that is parsed, distance is obtained and steps numbers calculated. The basic formula is one meter per step. So, if we have a direct 2000 meters line (6500 ft) we will have to wait around 2000 steps to get the picture.

To move the feet, mid and min angles are assigned to Gpio connected servos

while myDistance>0:
            rightFoot.min()
            leftFoot.min()
            sleep(0.5)
            rightFoot.mid()
            leftFoot.mid()
            sleep(0.5)
            myDistance=myDistance-1

 CSV Files

Coordinates.csv file is used for current location. Just one record with lat-lng.

TheWalkLog.csv is used to store every movement: timestemp, origin, destination, distance. map, snapshot and weather conditions.

Row example: 

2023-09-04 09:27:22.558367,-34.561641,-58.4819516,-34.564203,-58.48763710000001,592,'/home/roni/images/route-500835d3-b13b-4a17-b7d2-546fcdc605e9-5.jpg','/home/roni/images/snap-500835d3-b13b-4a17-b7d2-546fcdc605e9-5.jpg','clear sky'

TheWalkJournal.csv is used to store the diary.

The later 2 csv will be imported to a database and used in the future to plot The Walk complete journey. 

Screens

For lots of Python projects text output is just enough. In this case, more appealing screens are required, so CV2 library is used. The thing is that the screen size is 800x468 but Google Maps images are square. In the first versions of The Walk I just resized the images but then I found out a better option: using a full screen...

Read more »