Pull request ESP32 port and new features

189 views
Skip to first unread message

Thomas Chou

unread,
Jun 1, 2023, 2:59:18 PM6/1/23
to LINOROBOT
Hi,

I ported ESP32 to linorobot2_hardware and submitted a pull request. It contains the following features,

1. ESP32 port. Tested with generic esp32 dev board and Waveshare General Driver Board for Robots as custom configuration 'gendrv'. Build and test on ROS2 Humble.
'pio run -e esp32' or 'pio run -e gendrv'

The ESP32 supports 64 bits hardware pulse counters which are used for encoders, so no interrupts are required . POSIX clock_gettime() is supported to overcome the overflow of millis() in 50 days. A hardware watchdog can be enabled. The ESP are widely used and cheaper than the teensy with richer features. Yes, it is stable.

The Waveshare General Driver Board for Robots based on ESP32 includes all the interfaces to drive a 2WD mobile robot. I am not with the Waveshare. It is a piece of useful hardware to build 2WD robot. Save time and more stable than hand wiring. So I made a custom configuration file. You can plug and play with minor motors and wheels setting.

2. Micro ROS WIFI transport on esp32
Set board_microros_transport = wifi in ini and USE_WIFI_TRANSPORT in configuration file.

3. Arduino OTA on esp32 wifi. It is much faster to develop, compile and upload on a desktop computer.

3. Syslog on esp32 wifi. Send logging messages to a remote syslog server.

4. Magnetometer support to imu/data orientation and publish imu/mag. The magnetometer calibration can be automatically computed with the robot_calibration package. HMC5883L, AK8963 (inside MPU9250), AK8975, AK09918, QMC5883L are supported.

5. I2Cdevlib and drivers are updated from the upstream. Compatibility might be improved.

6. Battery voltage measurement and publisher with on chip ADC or INA219.

7. Ultrasonic sensor HC-SR04 and range publisher.

I ported my previous works to Linorobot. Please find my fork at
Review and comments welcome.

Linorobot is an amazing project. Thanks.

Cheers,
Thomas Chou

Thomas Chou

unread,
Jun 2, 2023, 11:16:20 AM6/2/23
to LINOROBOT

After installed the build enviroment, before touching any code, try building a sample firmware to verify everything is setup properly.

cd firmware pio run -e teensy41 # Or if you are using esp32 pio run -e esp32

Then create a custom configuration for your robot. This will minimize the merge conflicts from future pulling the upstream. Follow the commit "add custom gendrv config for Waveshare General Driver for Robots board". Add an entry to platformio.ini and ../config/config.h. Take the lino_base_config.h as a template and add your custom configuration file to ../config/custom/ . Make changes to your custom configuration file.


Thomas Chou 在 2023年6月1日 星期四上午11:59:18 [UTC-7] 的信中寫道:

Thomas Chou

unread,
Jun 3, 2023, 11:30:07 PM6/3/23
to LINOROBOT
Why ESP32?

The wifi capability of esp32 is a lot of fun. I prefer using wifi during development. The compilation speed on the desktop computer is much faster than the robot computer. Then upload the firmware with OTA.  And the remote syslog helps debugging and monitoring. Especially, the wifi transport agent can keep running and accept requests from multiple clients. Back then you would have to kill the serial transport agent to upload firmware through the serial port. You can even run the robot without a robot computer on it. Life is colorful having the wifi capability of esp32.

Thomas

Thomas Chou 在 2023年6月2日 星期五上午8:16:20 [UTC-7] 的信中寫道:

Thomas Chou

unread,
Jun 9, 2023, 7:05:05 PM6/9/23
to LINOROBOT
Attached are the pictures of one of my robots built on esp32. There is NO robot computer on it. All the ROS2 packages are running on the desktop computer. The lidar data is pushed to a UDP  server. The following is the project ini, pins wiring and custom configuration,

upload_protocol = espota
upload_port = 192.168.1.101  ; IP of the esp32 on robot
board_microros_transport = wifi

//define your robot' specs here
#define MOTOR_MAX_RPM 150                   // motor's max RPM
#define MAX_RPM_RATIO 0.85                  // max RPM allowed for each MAX_RPM_ALLOWED = MOTOR_MAX_RPM * MAX_RPM_RATIO          
#define MOTOR_OPERATING_VOLTAGE 12          // motor's operating voltage (used to calculate max RPM)
#define MOTOR_POWER_MAX_VOLTAGE 12          // max voltage of the motor's power source (used to calculate max RPM)
#define MOTOR_POWER_MEASURED_VOLTAGE 12     // current voltage reading of the power connected to the motor (used for calibration)
#define COUNTS_PER_REV1 550                 // wheel1 encoder's no of ticks per rev
#define COUNTS_PER_REV2 550                 // wheel2 encoder's no of ticks per rev
#define WHEEL_DIAMETER 0.0560               // wheel's diameter in meters
#define LR_WHEELS_DISTANCE 0.224            // distance between left and right wheels
#define PWM_BITS 8                           // PWM Resolution of the microcontroller
#define PWM_FREQUENCY 20000                 // PWM Frequency

// ENCODER PINS
#define MOTOR1_ENCODER_A 36
#define MOTOR1_ENCODER_B 39

#define MOTOR2_ENCODER_A 35
#define MOTOR2_ENCODER_B 34

#define USE_BTS7960_MOTOR_DRIVER // A4950 Dual Motor Drive Module
  #define MOTOR1_PWM -1
  #define MOTOR1_IN_A 19
  #define MOTOR1_IN_B 18
  #define MOTOR2_PWM -1
  #define MOTOR2_IN_A 16
  #define MOTOR2_IN_B 17

#define LIDAR_RXD 14
// battery voltage ADC pin
#define BATTERY_PIN 33

#define USE_WIFI_TRANSPORT  // use micro ros wifi transport
#define USE_ARDUINO_OTA
#define USE_SYSLOG
#define USE_LIDAR_UDP
#define USE_SHORT_BRAKE // for shorter stopping distance
#define WDT_TIMEOUT 30 // Sec

The UDP lidar driver is here,

Cheers,
Thomas
Thomas Chou 在 2023年6月3日 星期六晚上8:30:07 [UTC-7] 的信中寫道:
IMG_20230607_171123.jpg
Screenshot from 2023-06-09 15-35-05.png
IMG_20230609_103402.jpg
Reply all
Reply to author
Forward
0 new messages