-
Notifications
You must be signed in to change notification settings - Fork 1.3k
MicroROS on Espressif #9955
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
MicroROS on Espressif #9955
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Where do these microros-ext
files come from? Can you submodule them instead?
I agree we should submodule somehow - |
I don't understand the build stuff you are referring to. A README.md in microros-ext would be helpful in explaining where it came from and how to update it. |
Sorry, let me say that in a less confusing way. Compiling the MicroROS component installs a bunch of python package managers, is slow, and has a lot of verbose build output. To avoid adding that to Circuitpython's CI tests, I made a pre-compiled version, which is what I've included. I've recieved feedback already that that might be less easy to maintain, so I could revert back to including the original component as a submodule if you feel this feature being more futureproofed would be worth a small performance hit to the CI. Which would you prefer? |
How about splitting the difference and making a separate repo for the precompiled files? That way it isn't in CP but it doesn't require building every time. |
I'd just like to comment that this looks awesome, having ROS on CircuitPython could open up lots of opportunities. I'm currently thinking of making a CircuitPython sensor -> ROS factory utility class - so you could just set up your sensor, pass it into the class and it starts publishing on an appropriate topic - so an accelerometer+gyro would start publishing IMU messages for example. |
Ok, this sounds good to me. I can maintain the repo and we can revisit if another solution becomes better. I'm out for 1 week starting tomorrow but I'll implement this and the shared-bindings as soon as I get back. |
I've just implemented the first bit of the shared-bindings layer so I'd love to hear more about what you meant by this. I'm currently basing the module API off of |
@hierophect I've actually implemented the adaptor using circuitpython on a raspberry pi. It should work on ROS1 and ROS2 - but I've only tested on ROS1. The code is here and a usage example is here It basically allows you to create any sensor that complies with the adafruit sensor conventions - simply create a normal sensor and then call That wraps the sensor in a class and allows you to publish the sensor data. I should probably get around to publishing this properly, not buried in a repo with a bunch of other stuff. |
Getting a hardfault on init, which probably means there's an issue with the microros allocator overrides I provided using the micropython allocator tools ( |
What is the reason for calling it |
That's what the ROS2 CPython version is called: https://github.com/ros2/rclpy |
I'd be ok with either. Originally I was naming the whole thing |
Got it. I missed the |
Fixed some lost changes that should have been in the last commit, I think I missed adding changes and reset them by accident. Hence the mismatched macros etc. I'm having no luck even calling |
I'd suggest getting a backtrace via a m_malloc will crash if the VM isn't active but if you are doing an |
Will |
Whoops, looks like this could actually be a wifi coordination issue:
This is actually the kind of problem I expected, just not for it to manifest as a hardfault. I'm glad it's not a problem the allocator. Edit: can confirm hardfault goes away when wifi.radio is initialized properly first. |
No, it puts the IDF logging out the default UART. |
Might be stuck on some ROS issues for a little bit:
|
If anyone's interested in trying this out, this test script includes the basic functionality of this PR:
The ROS agent can be run without a native ROS2 installation using Docker.
Mac:
You'll need to obtain the appropriate IP address with |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks clean!
It looks like you chose a couple of boards to enable this on because they were what you had on hand. Is that right? Ultimately, there could be many more, but we might just suggest that people do a rebuild themselves. I am not sure we want eventually dozens of boards with and without ROS.
ports/espressif/boards/espressif_esp32s3_devkitc_1_n8r2_ros/mpconfigboard.mk
Outdated
Show resolved
Hide resolved
Thanks for the review! I have lots of ESP32 boards but picked these two specifically because the DevkitC is a nice standard option for the ESP32S3 with lots of debugging options, and the Cardputer has some immediate utility in a ROS system as a robot controller. I figured I'd do one more follow-up PR for one of the Adafruit ESP32S3 feathers to tap into the feather ecosystem, and then recommend that people either compile new boards themselves or make a request. |
And yes micro-ros works on ESP32, ESP32-S2, ESP32-S3, ESP32-C3 and ESP32-C6, and so could be enabled on almost every Circuitpython espressif board, but takes up extra flash space. |
I've discovered that |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hi - one stray file, and some ESP_LOGW() to deal with.
ports/espressif/boards/espressif_esp32s3_devkitc_1_n8r2_ros/jtagcfg.cfg
Outdated
Show resolved
Hide resolved
Making a more complete note here that this PR has a known issue where Micro-ROS is unable to clean up the Node and Publisher objects without returning an internal error code. This doesn't currently inhibit the module in any known way, as it soft restarts and both creates and uses new objects of both types just fine, but I'm leaving in the associated catches and internal (ESP monitor) debug messages while investigate further. Since this occurs during soft-reboot, it's not practical to print this information to circuitpython itself using |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Alright! I'll merge. This will create some new boards for circuitpython.org, I think, and so it would be good to submit a PR for the new boards to https://github.com/adafruit/circuitpython-org, assuming that happens.
Hooray! Should I do that now, or wait until I have some Readme content up with examples on how to use it? |
The new boards won't show up on circuitpython.org until I do the next 10.0.0 alpha release. Here's an example of multiple builds for one board: https://circuitpython.org/downloads?q=playground |
Gotcha, I misunderstood. Sure, I can put that together. |
This PR adds MicroROS as a board-specific option to the Espressif port. The Robot Operating System (ROS and successor ROS2) is kind of a misnomer: it is not an operating system, but it is a very commonly used collection of middleware and type standards for different robot parts to talk to each other. MicroROS is a tiny implementation of the ROS API that lets embedded systems talk to ROS system on a linux machine, such as a big computer running perception, kinematics or machine learning tasks.
The goal of this project is to allow Espressif Circuitpython boards to recieve and transmit data over WIFI to a computer running ROS, to publish sensor data, take in motor commands, and other tasks. I'm hoping it'll be useful to experimenters who want to learn about ROS without having to dive too deep into embedded systems.
Implementation notes (edited 4/5/25):
rclcpy
, after the standard ROS2 python APIrclpy
(RCL: Ros Client Library)rclpy
where possible, excluding features that aren't supported by MicroROS.Will resolve #8139