hadabot / hadabot_main

Content used in collaboration with various Hadabot blog posts to get guide you through learning ROS2.
https://blog.hadabot.com
GNU General Public License v3.0
37 stars 19 forks source link

ESP32 setup code fails: requesting non-existent key in hb.json and old class attribute #27

Open jschrier opened 2 years ago

jschrier commented 2 years ago

In step: Build Hadabot: Set up the ESP32 (using CLI tools) to interface with ROS 2

Code in hadabot_main/content/lessons/build_hadabot/m01_setup_esp32/firmware/ros2_interface/uhadabot/main.py fails to execute successfully on ESP32 (so far unattached to anything except a USB serial port)

Gleaning from the error messages below, it expects a as_ap key in the hb.json file (but none is created by setup_hadabot_config.py).

There also appears to be some problem related to creating an oled attribute in the class (this seems like it sets up some oled display hardware that is not present in the kit.). I also tried commenting this out, but then there are

Here's the serial output upon running this on a cleanly-flashed device:

ets J�uZ-�,d_drv:0x00,cs0_drv:0x00,hd_drv:0x00,wp_drv:0x00
mode:DIO, clock div:2
load:0x3fff0030,len:4
load:0x3fff0034,len:5636
load:0x40078000,len:12696
load:0x40080400,len:4292
entry 0x400806b0
Need to move webrepl_cfg.py to root folder
Need to move hb.json to root folder
Need to move main.py to root folder
Need to move ssd1306.py to root folder
All core files in uhadabot, so we will update the entire folder
Moving webrepl_cfg.py from uhadabot to root
Moving hb.json from uhadabot to root
Moving main.py from uhadabot to root
Moving ssd1306.py from uhadabot to root
ets Jul 29 2019 12:21:46

rst:0xc (SW_CPU_RESET),boot:0x13 (SPI_FAST_FLASH_BOOT)
configsip: 0, SPIWP:0xee
clk_drv:0x00,q_drv:0x00,d_drv:0x00,cs0_drv:0x00,hd_drv:0x00,wp_drv:0x00
mode:DIO, clock div:2
load:0x3fff0030,len:4
load:0x3fff0034,len:5636
load:0x40078000,len:12696
load:0x40080400,len:4292
entry 0x400806b0
Connecting to network Ranchito Dos Osos-2G...
Waiting for network to connect...
Waiting for network to connect...
Network connected. Config:  ('192.168.1.57', '255.255.255.0', '192.168.1.1', '192.168.1.1')
Installing to: /lib/
Warning: micropython.org SSL certificate is not validated
Installing micropython-logging 0.3 from https://micropython.org/pi/logging/logging-0.3.tar.gz
INFO:__main__:Welcome to Hadabot - www.hadabot.com
WebREPL daemon started on ws://192.168.1.57:8266
Started webrepl in normal mode
Network connected. Config:  ('192.168.1.57', '255.255.255.0', '192.168.1.1', '192.168.1.1')
INFO:boot:Welcome to Hadabot - www.hadabot.com
WebREPL daemon started on ws://192.168.1.57:8266
Started webrepl in normal mode
ERROR:__main__:Init exception hit as_ap
Traceback (most recent call last):
  File "main.py", line 452, in <module>
  File "main.py", line 449, in main
  File "main.py", line 346, in __init__
  File "main.py", line 388, in shutdown
AttributeError: 'Hadabot' object has no attribute 'oled'
MicroPython v1.15 on 2021-04-18; ESP32 module with ESP32
Type "help()" for more information.
>>> 
jschrier commented 1 year ago

A minimalistic code that only supports the left and right motors and LED blinking (needed for this first build tutorial) can be found in:

https://github.com/jschrier/hadabot_main/blob/minimal_initial_example/content/lessons/build_hadabot/m01_setup_esp32/firmware/ros2_helloworld/uhadabot/main.py

You'll also need to add a "as_ap": false entry to the network dictionary in the hb.json file.

jschrier commented 1 year ago

Related: It appears that the firmware code used in the lessons (https://github.com/hadabot/hadabot_main/tree/master/content/lessons/build_hadabot/m01_setup_esp32/firmware/ros2_interface/uhadabot) is out of sync with the other firmware code (https://github.com/hadabot/hadabot_main/tree/master/firmware/uhadabot), e.g. in the range sensor topic name