-
Notifications
You must be signed in to change notification settings - Fork 117
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
Want to rewrite the micro_ros_subscriber for example_interfaces/msg/String. #1791
Comments
Is this a school assignment? You will need to solve it yourself. Google "c++ string compare" |
Hi,hippo5329 Thank you for reply. My concern is not just about the syntax. In |
digitalWrite(LED_PIN, (msg->data == "0") ? LOW : HIGH); The c++ string compare operator is "==" . |
Welcome to ROS2/mciro-ROS. There are a lot more puzzles. Enjoy. :) As I suggested. It will save a lot of you if you install Ubuntu 22.04 PC, platformio/vscode, esp32 and follow my wiki. Workflow 1 and 2, should get you ready to explore the ROS world. A bare esp32 module is enough. You don't need to build a robot immediately. |
Although it is possible to run ROS2 on Windows, it is more difficult for a beginner. You should get a spare laptop/desktop to install Ubuntu 22.04 and ROS2 humble. |
An old PC with 8GB memory will be fine. I used 10 years old PC myself. If you want to purchase new PC, be sure to have 32GB memory to build moveit2. |
Hey, hippo5329 |
I would not suggest Arduino IDE. It is very limited on Pi. And it is awkward to build static micro-ros library on Arduino IDE. I would suggest install platformio/vscode on your windows pc. It should work. I switched to Linux more than 30 years ago, and do not use windows since then. You should really setup an Ubuntu PC to learn and use ROS. |
Due has very limited memory. It uses very low memory meta. I would not recommend Due. |
I fired up a win11 vm and realized micro ros platformio won't work. You can install platformio cli on pi to build the micro-ros firmware. platfromio.ini
src/subcriber_twist.ino
|
Do you mean downloading PlatformIO on Ubuntu running on a Raspberry Pi, instead of on Windows? |
Yes. Please follow my wiki to install platformio cli to pi. You may skip the linorobot2 and linorobot2_hardware installation. I have created a repo for the example. You may clone and tryout. git clone https://github.com/hippo5329/micro-ros_subscriber_twist.git |
You may check the commit to understand the conversion. |
However, it will save some efforts in the future if you install the two lino projects. |
Due has very limited memory. You should get some esp32. It has 5 times the RAM and 8 times the Flash ROM of Due. The CPU speed is much faster on esp32, too. The WifI support of esp32 is another plus. |
When I executed 'pio run -t upload', the following error occurred. Command 'pio' not found, but can be installed with: The actions I took were: |
Please complete the software installation in my wiki. Do not skip any steps. The steps to install platformio as in my wiki. sudo apt remove brltty -y curl -fsSL -o get-platformio.py https://raw.githubusercontent.com/platformio/platformio-core-installer/master/get-platformio.py echo "PATH="$PATH:$HOME/.platformio/penv/bin"" >> ~/.bashrc curl -fsSL https://raw.githubusercontent.com/platformio/platformio-core/develop/platformio/assets/system/99-platformio-udev.rules | sudo tee /etc/udev/rules.d/99-platformio-udev.rules |
You may be confused in the beginning. But in the future, you will need to understand what and why every steps in my wiki. |
Updated. Please check README. |
My previous replies on string msg are wrong. String is complex datatype and needs special memory allocation. Please check this, digitalWrite(LED_PIN, strcmp(msg->data.data, "0") ? HIGH : LOW); There are more examples in micro_ros_demos. You may clone my repo and try out. https://github.com/hippo5329/micro-ROS-demos-platformio I got a Due and gave it 20 mins try-out with both int32_publisher and string_publisher. I am not able to get it connect to mico-ROS after upload. I give up because I am not interested in Due. I have tested string_publisher and string_subscriber on two esp32_wifi. They work well. I have heard: "Hello from micro-ROS #5" |
To install platformio,I followed all the steps, but the following error occurred.
"After running
Additional note: I am considering purchasing an ESP32. |
Did you create the sd image with rpi-imager? Which OS version did you choose? You should use ubuntu 22.04 lts 64 bits desktop or server (better). Do not use core version. You may use ubuntu lts 24.04 and ROS2 jazzy. It will get better support in the future. |
Please check your platformio installation with ls ~/.platformio/penv/bin If you can find pio file here, then it is problem in the PATH. Try echo $PATH You should find the above path included. |
I checked again on a rpi3b ubuntu 22.04 lts server 64 bits. There is no issue in pio installation. https://github.com/hippo5329/micro-ROS-demos-platformio#install-platformio |
I forced pushed update. Due should work with most example packages now. Please remove old dir and clone again. Some won't work due to Due limitation. |
The arduino sam port has not been updated for 4 years. Issues remains unresolved. Arduino Due should be avoided. |
I'm sorry for the late reply.
I chose Ubuntu Desktop 22.04 LTS(64bit). So, I used ROS2 humble.
The results of the execution are as follows. I have omitted the description regarding user information.
What should I do? Should I start over from the beginning with the PlatformIO procedures? Also, I got ESP32. It says ESP-WROOM-32, but is it compatible with your wiki? |
Also, I have one more question. |
The PATH setup was wrong. Please edit your .bashrc, remove all lines containing "~/.platformio/penv/bin" . Then add this line to the end,
Then open a new terminal, and check with, "which pio". It should be like "/home/ubuntu/.platformio/penv/bin/pio" , here ubuntu is your user name. The pio command should be available now. The ESP-WROOM-32 works well. If you follow my wiki, no need to worry about micro ros setup. It is included in the linorobot2 installation. The micro-ros agent will be built and installed. You can follow the steps up to check topics with a WROOM esp32 module and wfi transport. This is a setup to help you learn micro-ros. You do not need to use the firmware in the future. Wifi transport is very helpful to run the various micro-ros demos. https://github.com/hippo5329/linorobot2_hardware/wiki#install-linorobot2 |
For your information, https://github.com/hippo5329/linorobot2_hardware/wiki#build-micro-ros-agent-alone---optional You do not need this. The linorobot2 installation will build micro-ROS agent. |
After executing this, the results of executing steps
Is PlatformIO functioning correctly with this? Should I start over from the beginning? |
It is because you installed platformio with apt, which is /usr/bin/pio. While we install platformio with python penv. You may try "sudo apt remove platformio". Or you may start over with a fresh ubuntu 22.04. You will need to execute those commands I listed in my wiki. No need to follow the links to upstream sites. I should remove those link to external sites, such as platformio. It causes confusion. |
I have removed those confusing external links. You may start here on a fresh ubuntu 22.04 rpi4, https://github.com/hippo5329/linorobot2_hardware/wiki#install-the-software |
After executing
Is this successful? |
How should I write 'cd firmware' when moving from the home directory as described in 'esp32 with micro-ROS serial transport on /dev/ttyUSB0'? |
Good. The esp32 built and uploaded successfully. You may proceed to test micro ROS connection. cd linorobot2_hardware/firmware |
After executing step 1, the following message was displayed
Is this successful? Also, I believe the program written in One more question please. |
It is successful.
You should proceed to check to topics. Google the massages types. Make sure you understand the commands and messages. Then proceed to wifi transport. Connect via wifi transport and check topic again. You should learn wifi tansport because serial transport will occupy the serial port, and you cannot use Serial.print() or printf(). You should use wifi transport so that you can use "pio device monitor ..." command to see the serial output. After checked topics and wifi transport, you may leave the linorobot2_hardware. And proceed to other examples.
A .ino file can be edited with any text editor. In file manager, select file, right mouse click, "open with" Text Editor.
|
OR you may install vscode on rpi4. Or install vscode on windows, and use remote development extension ssh into pi. |
I checked topics. They're correct.
This did not work, and the following error was found.
It seems like it doesn't recognize setup() and loop().
I would like to hear your thoughts. |
Good.
It is correct. It is not related to linorobot2_hardware. It should be outside linorobot2_hardware.
It does not matter the file extension is .ino or .cpp .
Please remove the old clone directory and clone again.
|
Please follow the new wiki. I added more arduino examples. The old micro-ros_subscriber_twist is removed. https://github.com/hippo5329/micro_ros_arduino_examples_platformio/wiki |
When editing the .ino file using the Arduino IDE, a new folder is created in the location where the file was, and the edited file is saved in that folder. Is this okay? I believe this is the reason why setup() and loop() were not recognized. |
As a test, I changed the LED_PIN in micro-ros_publisher to 4 and uploaded the program, but the attached LED did not light up. Why is this? The positive side of the LED is connected to "D4" and the negative side to "GND". The resistor is 1kΩ. I realized while writing that the resistor might be too large. Also, should the pin numbers specified in the program be the same as the pin numbers written on the ESP32 itself? I researched this but couldn't find a clear answer. |
So the arduino ide should not be used to edit this project. Arduino will interfere with our build process. Please install gedit and use gedit to edit your project. Remove the old directory and clone again. You may remove arduino ide to avoid the interference. |
I have changed the LED_PIN in my port.
I used LED_BUILTIN, which is 2 in most esp32 modules, including wroom. Wroom has two LEDs on board. The red led is power. The blue led is 2. You should see blue led lights up. If the micro-ros client times out, the led will blink quickly. Press the "EN" button near the usb header to reset. Then it should be able to connect to micro-ros agent. |
A Blink LED example in platformio. |
I think our conversations has gone far away from the scope of this repository. Please open a new issue in my repo, |
I have created a new issue. Thank you. |
Hi,
I want to rewrite the micro_ros_subscriber for example_interfaces/msg/String.
However, when I tried to modify it myself, I encountered an error and couldn't proceed any further. I would like to know how to resolve this issue.
The operating environment
・ArduinoIDE2.1.1
・Arduino Due
program
<
Error message
Thank you.
The text was updated successfully, but these errors were encountered: