PokemonGo-Bot icon indicating copy to clipboard operation
PokemonGo-Bot copied to clipboard

with merge of pull request 4350: altitude logging crashes bot when follow path is set

Open ckrmml opened this issue 10 years ago • 13 comments

Expected Behavior

bot follows path and has right altitude

Actual Behavior

bot crashes

came up with https://github.com/PokemonGoF/PokemonGo-Bot/pull/4350 as solution to https://github.com/PokemonGoF/PokemonGo-Bot/issues/4275

Your FULL config.json (remove your username, password, gmapkey and any other private info)

{
  "auth_service": "ptc",
  "username": "xxxxx",
  "password": "xxxxxx",
  "location": "xxxxxxx",
  "gmapkey": "xxxxxxxxxx",
  "encrypt_location": "",
  "websocket_server": false,
  "heartbeat_threshold": 10,
  "tasks": [
    {
      "type": "HandleSoftBan"
    },
    {
      "type": "SleepSchedule",
      "config": {
        "enabled": false,
        "time": "22:54",
        "duration": "7:46",
        "time_random_offset": "00:24",
        "duration_random_offset": "00:43"
      }
    },
    {
      "type": "RandomPause",
      "config": {
        "enabled": false,
        "min_duration": "00:00:10",
        "max_duration": "02:00:00",
        "min_interval": "00:10:00",
        "max_interval": "02:00:00"
      }
    },
    {
      "type": "CompleteTutorial",
      "config": {
        "enabled": false,
        "// set a name": "",
        "nickname": ""
      }
    },
    {
      "type": "CollectLevelUpReward"
    },
    {
      "type": "IncubateEggs",
      "config": {
        "longer_eggs_first": true
      }
    },
    {
      "type": "UpdateLiveStats",
      "config": {
        "enabled": true,
        "min_interval": 120,
        "stats": [
          "username",
          "uptime",
          "stardust_earned",
          "xp_earned",
          "xp_per_hour",
          "stops_visited"
        ],
        "terminal_log": true,
        "terminal_title": true
      }
    },
    {
      "type": "UpdateLiveInventory",
      "config": {
        "enabled": true,
        "min_interval": 120,
        "show_all_multiple_lines": false,
        "items": [
          "space_info",
          "pokeballs",
          "greatballs",
          "ultraballs",
          "razzberries",
          "luckyegg"
        ]
      }
    },
    {
      "type": "TransferPokemon",
      "config": {
        "transfer_wait_min": 1,
        "transfer_wait_max": 4
      }
    },
    {
      "type": "NicknamePokemon",
      "config": {
        "enabled": false,
        "nickname_template": "{iv_pct}_{iv_ads}"
      }
    },
    {
      "type": "EvolvePokemon",
      "config": {
        "evolve_all": "all",
        "first_evolve_by": "cp",
        "evolve_above_cp": 200,
        "evolve_above_iv": 0.8,
        "logic": "or",
        "evolve_speed": 20,
        "use_lucky_egg": false
      }
    },
    {
      "type": "RecycleItems",
      "config": {
        "min_empty_space": 15,
        "max_balls_keep": 150,
        "max_potions_keep": 50,
        "max_berries_keep": 70,
        "max_revives_keep": 70,
        "item_filter": {
          "Pokeball": {
            "keep": 100
          },
          "Potion": {
            "keep": 10
          },
          "Super Potion": {
            "keep": 20
          },
          "Hyper Potion": {
            "keep": 30
          },
          "Revive": {
            "keep": 30
          },
          "Razz Berry": {
            "keep": 100
          }
        },
        "recycle_wait_min": 1,
        "recycle_wait_max": 4
      }
    },
    {
      "type": "CatchPokemon",
      "config": {
        "catch_visible_pokemon": true,
        "catch_lured_pokemon": true,
        "min_ultraball_to_keep": 5,
        "berry_threshold": 0.35,
        "vip_berry_threshold": 0.9,
        "catch_throw_parameters": {
          "excellent_rate": 0.1,
          "great_rate": 0.5,
          "nice_rate": 0.3,
          "normal_rate": 0.1,
          "spin_success_rate": 0.3,
          "hit_rate": 0.75
        },
        "catch_simulation": {
          "flee_count": 3,
          "flee_duration": 2,
          "catch_wait_min": 2,
          "catch_wait_max": 6,
          "berry_wait_min": 2,
          "berry_wait_max": 3,
          "changeball_wait_min": 2,
          "changeball_wait_max": 3
        }
      }
    },
    {
      "type": "SpinFort",
      "config": {
        "spin_wait_min": 2,
        "spin_wait_max": 3
      }
    },
    {
      "type": "FollowPath",
      "config": {
        "path_mode": "loop",
        "path_start_mode": "first",
        "path_file": "configs/pokestops.gpx"
      }
    }
  ],
  "map_object_cache_time": 5,
  "forts": {
    "avoid_circles": true,
    "max_circle_size": 50,
    "cache_recent_forts": true
  },
  "pokemon_bag": {
    "// if 'show_at_start' is true, it will log all the pokemons in the bag (not eggs) at bot start": {},
    "show_at_start": true,
    "// if 'show_count' is true, it will show the amount of each pokemon (minimum 1)": {},
    "show_count": true,
    "// 'pokemon_info' parameter define which info to show for each pokemon": {},
    "// the available options are": {},
    "// ['cp', 'iv_ads', 'iv_pct', 'ivcp', 'ncp', 'level', 'hp', 'moveset', 'dps']": {},
    "pokemon_info": [
      "cp",
      "iv_pct"
    ]
  },
  "walk_max": 4.16,
  "walk_min": 2.16,
  "alt_min": 500,
  "alt_max": 1000,
  "gps_default_altitude": 8,
  "replicate_gps_xy_noise": false,
  "replicate_gps_z_noise": false,
  "gps_xy_noise_range": 0.00025,
  "gps_z_noise_range": 12.5,
  "debug": false,
  "test": false,
  "health_record": false,
  "location_cache": true,
  "distance_unit": "km",
  "reconnecting_timeout": 15,
  "logging_color": true,
  "daily_catch_limit": 800,
  "catch": {
    "any": {
      "catch_above_cp": 0,
      "catch_above_iv": 0,
      "logic": "or"
    },
    "// Example of always catching Rattata:": {},
    "// Rattata": {
      "always_catch": true
    }
  },
  "release": {
    "any": {
      "keep_best_iv": 1
    },
    "// Example of always releasing Rattata:": {},
    "// Rattata": {
      "always_release": true
    },
    "// Example of keeping 3 stronger (based on CP) Pidgey:": {},
    "// Pidgey": {
      "keep_best_cp": 3
    },
    "// Example of keeping 2 best (based on IV) Zubat:": {},
    "// Zubat": {
      "keep_best_custom": "iv, cp, hp_max",
      "amount": 2
    },
    "// Also, it is working with any": {},
    "// Example of keeping the 2 strongest (based on CP) and 3 best (based on IV) Zubat:": {},
    "// Example of custom order of static criterion": {}
  },
  "vips": {
    "Any pokemon put here directly force to use Berry & Best Ball to capture, to secure the capture rate!": {},
    "any": {
      "catch_above_cp": 1200,
      "catch_above_iv": 0.9,
      "logic": "or"
    },
    "Lapras": {},
    "Moltres": {},
    "Zapdos": {},
    "Articuno": {},
    "// S-Tier pokemons (if pokemon can be evolved into tier, list the representative)": {},
    "Mewtwo": {},
    "Dragonite": {},
    "Snorlax": {},
    "// Mew evolves to Mewtwo": {},
    "Mew": {},
    "Arcanine": {},
    "Vaporeon": {},
    "Gyarados": {},
    "Exeggutor": {},
    "Muk": {},
    "Weezing": {},
    "Flareon": {}
  }
}

Output when issue occurred

2016-08-20 19:21:58,176 [SleepSchedule] [INFO] [next_sleep] Next sleep at 2016-08-20 22:57:11.176544
2016-08-20 19:21:58,179 [RandomPause] [INFO] [next_random_pause] Next random pause at 20:25:07, for a duration of 1:27:19
2016-08-20 19:21:59,739 [PokemonGoBot] [INFO] [bot_start] Starting bot...
2016-08-20 19:22:00,475 [CollectLevelUpReward] [INFO] [level_up_reward] Received level up reward: []
2016-08-20 19:22:00,841 [IncubateEggs] [INFO] [next_egg_incubates] Next egg (10.0 km) incubates in 1.11 km (Total eggs: 6, Incubating: 3)
2016-08-20 19:22:02,837 [UpdateLiveStats] [INFO] [log_stats] a2btpt | Uptime : 0:00:11 | Earned 0 Stardust | +0 XP | 0 XP/h | Visited 0 stops
2016-08-20 19:22:02,838 [UpdateLiveInventory] [INFO] [show_inventory] Items: 319/350 | Pokeballs: 72 | GreatBalls: 81 | UltraBalls: 0 | RazzBerries: 71 | LuckyEgg: 3
2016-08-20 19:22:04,760 [       cli] [INFO] 
2016-08-20 19:22:04,760 [       cli] [INFO] Ran for 0:00:12
2016-08-20 19:22:04,760 [       cli] [INFO] Total XP Earned: 0  Average: 0.00/h
2016-08-20 19:22:04,761 [       cli] [INFO] Travelled 0.00km
2016-08-20 19:22:04,761 [       cli] [INFO] Visited 0 stops
2016-08-20 19:22:04,761 [       cli] [INFO] Encountered 0 pokemon, 0 caught, 0 released, 0 evolved, 0 never seen before
2016-08-20 19:22:04,761 [       cli] [INFO] Threw 0 pokeballs
2016-08-20 19:22:04,762 [       cli] [INFO] Earned 0 Stardust
2016-08-20 19:22:04,763 [       cli] [INFO] 
2016-08-20 19:22:04,763 [       cli] [INFO] Highest CP Pokemon: 
2016-08-20 19:22:04,764 [       cli] [INFO] Most Perfect Pokemon: 
Traceback (most recent call last):
  File "pokecli.py", line 674, in <module>
    main()
  File "pokecli.py", line 118, in main
    bot.tick()
  File "/Volumes/Data/christiankrummel/projects/PokemonGo-Bot_wrapper_osx/PokemonGo-Bot/pokemongo_bot/__init__.py", line 541, in tick
    if worker.work() == WorkerResult.RUNNING:
  File "/Volumes/Data/christiankrummel/projects/PokemonGo-Bot_wrapper_osx/PokemonGo-Bot/pokemongo_bot/cell_workers/follow_path.py", line 143, in work
    'current_position': (lat, lng, alt),
UnboundLocalError: local variable 'alt' referenced before assignment

Steps to Reproduce

run bot with follow path in latest commit

Other Information

OS: OSX Branch: dev Git Commit: a1c9419521c9ed28e361aaecc87581addfce6ba8 Python Version: 2.7.12 Any other relevant files/configs (eg: path files): gpsies gpx track

ckrmml avatar Aug 20 '16 17:08 ckrmml

agreed, same happened to me, had to roll back to previous commit

bohus-rosko avatar Aug 20 '16 17:08 bohus-rosko

opened pr https://github.com/PokemonGoF/PokemonGo-Bot/pull/4395

ckrmml avatar Aug 20 '16 18:08 ckrmml

@Arcasss Which commit worked for you?

Vvkmnn avatar Aug 20 '16 18:08 Vvkmnn

@Vvkmnn https://github.com/PokemonGoF/PokemonGo-Bot/commit/72e111c1373ab2a6a74af33ce2bd1067e82bf414

there also is a typo in line 67 of follow_path.py

            raise RuntimeError('GPX file does not cotain a track')

should probably be contain.

hacked around a bit and got it to work. now shows correct altitude for current_position, but last_position seems to be some random gibberish between the values given in config

ckrmml avatar Aug 20 '16 18:08 ckrmml

Although altitude appears to be given in the gpx xsd, it is not used at all either, which would solve both these problems for the case of gpx.

Acuchillar avatar Aug 20 '16 19:08 Acuchillar

@Vvkmnn this one worked cc3b4c92b94b9e6b8f23f08eae93189a82d5cfd0

bohus-rosko avatar Aug 20 '16 19:08 bohus-rosko

quick fix would be placing

_, _, alt = self.bot.api.get_position()

right before emit. The current PR by ckrmml may incorporate reading altitude from GPX file.

kanemasa1987 avatar Aug 20 '16 23:08 kanemasa1987

Confirmed the quick fix works

Holzberg avatar Aug 21 '16 00:08 Holzberg

latest dev pull to commit 6f9ae7dc06c6518d2cc8db13ad3dc2dec167e22a fails with or without the quick fix.

Holzberg avatar Aug 21 '16 04:08 Holzberg

you mean this? #4395

kanemasa1987 avatar Aug 21 '16 05:08 kanemasa1987

I fixed it by adding a simple ,0 as the altitude for every location like this:

[
    {"location":"23.2312312,-123.123124,0"},
    {"location":"21.2312312,-125.123124,0"},
    {"location":"24.2312312,-121.123124,0"}
]

hobbes3 avatar Aug 21 '16 19:08 hobbes3

Yeah, all paths should indicate an altitude now. FollowPath should still assign a default altitude if none is present. I'll take a look and see if this is still an issue.

mjmadsen avatar Aug 22 '16 08:08 mjmadsen

#4452 Looks like it made the appropriate changes to fix this. Please reopen if the problem persists (with new error log).

mjmadsen avatar Aug 22 '16 08:08 mjmadsen