verlab / hero_common

This project contributes to an open source ROS-based framework for swarm robotics. We propose an low cost, high availability swarm system that could be printed and assembled multiple times without special knowledge or hardware skills.
https://verlab.github.io/hero_common/
58 stars 15 forks source link

WheelEncoder.h causing reset on ESP8266 #15

Closed willgraham345 closed 10 months ago

willgraham345 commented 1 year ago

My team and I have debugged the firmware on the 2.6 board down to the include statement on WheelEncoder.h. Here is the error we are getting if that helps:

ets Jan  8 2013,rst cause:2, boot mode:(3,6)

load 0x4010f000, len 3460, room 16 
tail 4
chksum 0xcc
load 0x3fff20b8, len 40, room 4 
tail 4
chksum 0xc9
csum 0xc9
v000476d0
~ld

we know that the ESP is getting enough power ~4.9V. We assume that the issue stems from within the file where these lines are included:


#include <Encoder.h>                    /* https://github.com/PaulStoffregen/Encoder */
#include <SimpleKalmanFilter.h>         /* https://github.com/denyssene/SimpleKalmanFilter */

We know that the bots aren't the issue because we are able to flash all of the sketches in the firmware/examples directory, as well as the demos that are included with the ESP including turning the bot into a wifi access point.

could this be an issue with the library location? Any help is extremely appreciated!

EDIT By going into the Encoder.h file supplied by Paul Stoffregen and adding ICACHE_RAM_ATTR to all static void ISR lines i.e

static void sr34(void) { update(interruptArgs[34]); }
----->
static void ICACHE_RAM_ATTR isr34(void) { update(interruptArgs[34]); }

the robot now has two red blinking LEDs when we turn it on and covering IR sensors for setup mode does not work.

EDIT 2.0 Changing the default mode for the robot in the firmware.ino to

config_mode = 1;

we are able to get the robot into config mode on startup.

rezeck commented 1 year ago

Hi @willgraham345,

Sorry for the late reply! After a while, I was able to replicate this error.

I was using version 2.5.0 of the esp8266 board, and this error did not come out. Screenshot from 2023-01-07 10-56-52 Screenshot from 2023-01-07 10-02-43

But when I upgrade it to version 3.1.0 and compile it again, when I check the serial output, I get the same error. Screenshot from 2023-01-07 09-59-52

In fact, the solution was just to update the Encoder library to the most current version (1.4.1 -> 1.4.3). It could have been some internal modification in the esp8266 board that changed the way to implement interrupts, making the Encoder lib need updating.

I tested it here, and everything should work fine since that last commit in the hero repository.

EDIT 1.0:

It looks like the newest version of the Encoder library (> 1.4.1) has decided to remove GPIO 10 from the list of interrupt pins. This will cause problems reading the left encoder since we use this pin.

The version of the Encoder library in the hero repository has re-enabled this pin. If you want to use future versions of the Encoder lib (> 1.4.3), remember to check if this GPIO is enabled as an interrupt.

Regarding the configuration mode, it could be some problems with the IR sensor readings. The idea we use as a switch is if all IR readings are greater than TOUCH_THRESHOLD, then the robot should go into configuration mode (blinking pink light). Otherwise, it enters the ROS communication mode. Red blink light (searching for an access point). When connecting to the access point, the light blinks blue and stops. At that moment, it is already possible to connect with the robot by executing the launch file, hero_bringup.launch.

/* firmware.ino */
/* Cover all the range sensor to enable web config mode */
  config_mode = rangeSensor.configModeCheck();
  /* Clean status led */
  ledStatus.reset();
  if (config_mode) {
    /* Create an AP that enables the user to setup some parameter of the robot. See config_via_wifi.h. */
    webConfig.init(ledStatus);
  }
  else {
    /* Setup ROS Communication */

Please let me know if you were able to fix these both issues. Best, Rezeck