Making an IoT robot…

Philippe Coval <purl.org/rzr> #FOSDEM 2020

FOSDEM_logo.svg

Who are we ?

  • Philippe Coval: @RzrFreeFr
    • SW Engineer for OSS (Intel, Samsung)
      • Available for cooperation
  • Alin Jerpelea: @devjerpelea
    • SW Architect for Sony
      • Maintainer of Sony Open Devices
  • OSS Advocates
  • Contributors to NuttX community

Disclaimer

  • This talk is not about:
    • State of the art in Robotics
    • Hard real time on critical systems
  • It's about experimenting:
    • Prototyping a "Web of Twins"
    • Validated chain from actuator to UI/UX

Do NOT reproduce in a critical context

Robots

  • DiY from scratch:
    • Design mechanical (with FreeCAD)
    • Produce (CNC laser cutter)
    • Assemble with motors modules
  • Faster: Buy a kit (pref. OSHW / OpenDesign)
  • How to connect and control ?

Servo Motors

pwm-sg90.png

sg90.jpg

  • Angle is controlled by a PWM signal
  • SG90: 9g Micro Servo
    • Angle: [-90°, +90°]
    • I/O: Power: 4.8V, GND, PWM

Robotic arm's controller

Software Architecture

  • JS Application is a Web server:
    • to expose Motors angles using HTTP/REST
    • to generate control signals (PWM)
  • JavaScript Runtime: IoT.js
  • "Unix like" RTOS: NuttX

Sourcing hardware

  • Requirements:
    • IO: 4+ PWM signals (Hardware)
    • Connectivity (Ethernet)
    • Memory: ~200K For JS runtime and app
  • Nucleo F767ZI board from ST
    • STM32F7 is a good candidate
      • Cortex-M7 (Compat. M4 / STM32F4)
      • RAM: 320 KB, Flash: 2 MB
    • IO: Nucleo-144 Pins
    • Support: cube, mbed, STM32duino, RIOT

NuttX

  • Released by Gregory Nutt in 2007
  • Community and code grew (2.6M LoC)
    • Base of derived projects:
      • TizenRT, PX4, Sony Spresense
  • Incubation at Apache F. in 2019
  • NuttX conference in May 2020 (Tokyo)
    • Registration is open

NuttX's features

  • A real-time operating system (RTOS)
  • Committed to comply standards
    • POSIX, ANSI C
    • File based IO (/dev)
    • BSD sockets/ uIP
  • Modular (kconfig)
  • Scalable (8/32 bits MCU)
    • Support 9 archs / ~400+ boards

NuttX contribution

  • Only CPU STM32F7 was supported
  • Added patches for new Nucleo-F767ZI board
  • Mapping inspired by STM32F103:
    • GPIO, ADC, PWM, ROMFS…
  • Released in nuttx-7.31

IoT.js contribution

  • Added native module for stm32f7nucleo
    • inspired by ref board SMT32F4 discovery
  • webthing-iotjs module to expose resources
    • REST API (uses iotjs-express module)
    • Mozilla IoT schema (in JSON)

WebThings REST API

$ curl http://192.168.0.42:8888
{ (...) "properties":{"arm":{
   "type":"number",
   "minimum":-90,"maximum":90,
   "description":"Rotary actuator on /dev/pwm2" (...)
   "links":[{"rel":"property","href":"/properties/arm" (...)

$ curl http://192.168.0.42:8888/properties
{"torso":0,"shoulder":0,"arm":0,"hand":0}

$ curl -H "Content-Type: application/json" \
  -X PUT --data '{"arm": 42}' \
  http://192.168.0.42:8888/properties
{"arm":42}

Web of Twins Robot

📺 📺 📺

Web of Twins demo

. .

Resources

fosdem.svg

Video playback

More

Playlist

📺 📺 📺 📺

Created by Philippe Coval