Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

new PolylineWalker(StepWalker) #990

Closed
wants to merge 43 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
43 commits
Select commit Hold shift + click to select a range
e1bb9b7
removed walk() method
th3w4y Jul 24, 2016
f19e601
Merge pull request #1 from th3w4y/polyline
th3w4y Jul 24, 2016
3f4e65f
Merge remote-tracking branch 'upstream/dev' into dev
th3w4y Jul 24, 2016
9d565bb
modified test
th3w4y Jul 24, 2016
31d0dd6
modified test
th3w4y Jul 24, 2016
682aeae
use a more significant example
th3w4y Jul 24, 2016
e27fa7c
fixed percentage_walked calculation
th3w4y Jul 24, 2016
6f2e74f
Merge branch 'dev' into polyline
th3w4y Jul 24, 2016
510c0d8
running test with 100m/s in order to speed the polyline generating time
th3w4y Jul 24, 2016
8eb7f89
added 2 module requirements
th3w4y Jul 24, 2016
1e67264
a stepper that is using the PolylineWalker
th3w4y Jul 24, 2016
4c81f7e
a stepper that is using the PolylineWalker
th3w4y Jul 24, 2016
b27de0c
Merge pull request #2 from th3w4y/polyline
th3w4y Jul 24, 2016
075c9f4
Merge pull request #3 from th3w4y/dev
th3w4y Jul 24, 2016
5e9e7ae
Merge remote-tracking branch 'upstream/dev' into polyline
th3w4y Jul 24, 2016
fde0bf4
resolved conflict
th3w4y Jul 24, 2016
7f79c3f
Merge remote-tracking branch 'upstream/dev' into dev
th3w4y Jul 24, 2016
db93a93
Merge branch 'dev' into polyline
th3w4y Jul 24, 2016
b16e65b
Merge pull request #4 from th3w4y/polyline
th3w4y Jul 24, 2016
afcae3d
improved stepper that walks using Google Directions API
th3w4y Jul 24, 2016
24bb7fb
improved logging
th3w4y Jul 25, 2016
1f53ed4
Merge remote-tracking branch 'upstream/dev' into dev
th3w4y Jul 25, 2016
3bb2f56
merge upstream/dev
th3w4y Jul 25, 2016
f6efe4e
Merge branch 'dev' of https://github.com/PokemonGoF/PokemonGo-Bot int…
th3w4y Jul 25, 2016
3521aa3
Merge pull request #6 from PokemonGoF/dev
th3w4y Jul 25, 2016
25ebe8c
Merge pull request #8 from PokemonGoF/dev
th3w4y Jul 25, 2016
3c4bb9d
Merge pull request #9 from th3w4y/dev
th3w4y Jul 25, 2016
bb303be
add origin/destination point to the PolylineWalker().points
th3w4y Jul 25, 2016
6b503c7
renamed polyline_stepper.py to polyline_stepper.py.bak
th3w4y Jul 25, 2016
f597e02
above
th3w4y Jul 25, 2016
f899961
renamed polyline_stepper.py to polyline_stepper.py.bak
th3w4y Jul 25, 2016
aeea53a
Merge branch 'polyline' of https://github.com/th3w4y/PokemonGo-Bot in…
th3w4y Jul 25, 2016
c353fb7
bug fixes, and rewrite for the new navigator, walker, stepper concept
th3w4y Jul 25, 2016
063dc19
fixed PolylineWalker(StepWalker) __init__()
th3w4y Jul 25, 2016
c95efce
round lat, lng to 5 digits to not be too precise
th3w4y Jul 26, 2016
94ace2c
merge upstream/refactor-workers
th3w4y Jul 26, 2016
46b0d6d
reverted rounding of lat/lng iside the polyline generator since dest
th3w4y Jul 26, 2016
55f09db
Merge branch 'refactor-workers' of https://github.com/PokemonGoF/Poke…
th3w4y Jul 26, 2016
990502d
Merge branch 'PokemonGoF-refactor-workers' into refactor-workers
th3w4y Jul 26, 2016
746a475
remove old polyline_stepper
th3w4y Jul 26, 2016
8365244
fixed import statement in pokemongo_bot/cell_workers/evolve_all_worke…
th3w4y Jul 26, 2016
9954930
disable pylint check for module disturil.core in setup.py
th3w4y Jul 26, 2016
a788476
return destination unrounded, and intermediary points rounded to 5 de…
th3w4y Jul 27, 2016
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion .pylintrc
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
[MESSAGES CONTROL]
disable=line-too-long,
missing-docstring
missing-docstring

[TYPECHECK]
ignored-modules=distutils,distutils.core
Copy link
Contributor Author

@th3w4y th3w4y Jul 26, 2016

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

pylint running on travis inside virtualenv has issues with the setup.py file not being able to import distils.core pylint-dev/pylint#73

2 changes: 1 addition & 1 deletion pokemongo_bot/cell_workers/evolve_all_worker.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

from pokemongo_bot import logger
from pokemongo_bot.human_behaviour import sleep
from item_list import Item
from pokemongo_bot.item_list import Item


class EvolveAllWorker(object):
Expand Down
43 changes: 0 additions & 43 deletions pokemongo_bot/polyline_stepper.py

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1 +1,3 @@
from polyline_generator import Polyline
from polyline_walker import PolylineWalker

Original file line number Diff line number Diff line change
@@ -1,25 +1,24 @@
import time
from itertools import chain
from math import ceil

import haversine
import polyline
import requests


class PolylineWalker(object):
class Polyline(object):

def __init__(self, origin, destination, speed):
self.DISTANCE_API_URL='https://maps.googleapis.com/maps/api/directions/json?mode=walking'
self.origin = origin
self.destination = destination
self.URL = '{}&origin={}&destination={}'.format(self.DISTANCE_API_URL,
'{},{}'.format(*self.origin),
'{},{}'.format(*self.destination))
self.polyline_points = [x['polyline']['points'] for x in
requests.get(self.DISTANCE_API_URL+'&origin='+
self.origin+'&destination='+
self.destination
).json()['routes'][0]['legs'][0]['steps']]
requests.get(self.URL).json()['routes'][0]['legs'][0]['steps']]
self.speed = float(speed)
self.points = self.get_points(self.polyline_points)
self.points = [self.origin] + self.get_points(self.polyline_points) + [self.destination]
self.lat, self.long = self.points[0][0], self.points[0][1]
self.polyline = self.combine_polylines(self.points)
self._timestamp = time.time()
Expand Down Expand Up @@ -85,9 +84,15 @@ def get_pos(self):
return self.calculate_coord(percentage_walked, *steps_dict[walked_end_step])

def calculate_coord(self, percentage, o, d):
lat = o[0]+ (d[0] -o[0]) * percentage
lon = o[1]+ (d[1] -o[1]) * percentage
return [(lat, lon)]
# If this is the destination then returning as such
if self.points[-1] == d:
return [d]
else:
# intermediary points returned with 5 decimals precision only
# this ensures ~3-50cm ofset from the geometrical point calculated
lat = o[0]+ (d[0] -o[0]) * percentage
lon = o[1]+ (d[1] -o[1]) * percentage
return [(round(lat, 5), round(lon, 5))]

def get_total_distance(self):
return ceil(sum([haversine.haversine(*x)*1000 for x in self.walk_steps()]))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,10 @@

import haversine
import polyline

from polyline_walker import PolylineWalker

a = PolylineWalker('Poststrasse+20,Zug,CH', 'Guggiweg+7,Zug,CH', 100)
from math import ceil
from polyline_generator import Polyline
a = Polyline((47.1706378, 8.5167405), (47.1700271, 8.518072999999998), 100)
print(a.points)
print('Walking polyline: ', a.polyline)
print('Encoded level: ','B'*len(a.points))
print('Initialted with speed: ', a.speed, 'm/s')
Expand Down
25 changes: 25 additions & 0 deletions pokemongo_bot/walkers/polyline_walker.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
# -*- coding: utf-8 -*-
from polyline_generator import Polyline
from math import ceil
from ..human_behaviour import sleep
from ..cell_workers.utils import i2f
from pokemongo_bot.step_walker import StepWalker
from pokemongo_bot import logger

class PolylineWalker(StepWalker):

def __init__(self, bot, speed, initLat, initLng, destLat, destLng):
super(PolylineWalker, self).__init__(bot, speed, initLat, initLng, destLat, destLng)
self.polyline_walker = Polyline((i2f(self.api._position_lat), i2f(self.api._position_lng)),
(self.destLat, self.destLng), self.speed)
logger.log('[#] {}'.format(self.polyline_walker.URL))

def step(self):
self.polyline_walker.unpause()
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This seems fishy.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why doesn't this just call walk_steps on the polyline walker? Why pause and unpause?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

And how does it behave if position changed in between steps?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nvm. I understand better now. I read the code a little bit deeper. :)

sleep(1)
self.polyline_walker.pause()
cLat, cLng = self.polyline_walker.get_pos()[0]
self.api.set_position(round(cLat, 5), round(cLng, 5), 0)
self.bot.heartbeat()
if self.destLat == cLat and self.destLng == cLng:
return True
2 changes: 2 additions & 0 deletions requirements.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
-e git+https://github.com/tejado/pgoapi.git#egg=pgoapi
geopy==1.11.0
distribute==0.7.3
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

trying to get travis build working, distribute==0.0 (req protobuffer) not available on travis

protobuf==3.0.0b4
requests==2.10.0
s2sphere==0.2.4
Expand All @@ -11,3 +12,4 @@ enum34==1.1.6
pyyaml==3.11
haversine==0.4.5
polyline==1.3.1
pysmbus==0.1.post3
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

someone on lcd.py forgot to include the pysmus module in requirements.txt

1 change: 0 additions & 1 deletion web
Submodule web deleted from 83463c