micro-ROS / micro_ros_arduino

micro-ROS library for Arduino
Apache License 2.0
453 stars 117 forks source link

Tutorial not working on teensy 4.1 #572

Closed carmiac closed 3 years ago

carmiac commented 3 years ago

The teensy tutorial is not working. Everything builds and loads properly, but when I start the ros2 serial agent, it appears to connect to the teensy and then crash out with no error messages. When this happens the teensy jumps into the error_loop and will just blink away forever.

I'm running Arduino 1.8.13, Teensyduino 1.53 and using a Teensy 4.1 board. I've used both the v2.0.2-foxy micro_ros_arduino release as well as v1.0.0 with the same results. I've also tried it with Arduino 1.8.15 and Teensyduino 1.55 and get the same results.

Here's the output from the micro ros agent terminal:

milner@canterbury:~/arduino-1.8.13/hardware/teensy/avr$ ros2 run micro_ros_agent micro_ros_agent serial --dev /dev/ttyACM0
[1637094118.227826] info     | TermiosAgentLinux.cpp | init                     | Serial port not found. | device: /dev/ttyACM0, error 2, waiting for connection...
[1637094119.231427] info     | TermiosAgentLinux.cpp | init                     | Serial port not found. | device: /dev/ttyACM0, error 2, waiting for connection...
[1637094120.234235] info     | TermiosAgentLinux.cpp | init                     | Serial port not found. | device: /dev/ttyACM0, error 2, waiting for connection...
[1637094121.237957] info     | TermiosAgentLinux.cpp | init                     | Serial port not found. | device: /dev/ttyACM0, error 2, waiting for connection...
[1637094122.239907] info     | TermiosAgentLinux.cpp | init                     | Serial port not found. | device: /dev/ttyACM0, error 2, waiting for connection...
[1637094123.242296] info     | TermiosAgentLinux.cpp | init                     | Serial port not found. | device: /dev/ttyACM0, error 2, waiting for connection...
[1637094124.245006] info     | TermiosAgentLinux.cpp | init                     | Serial port not found. | device: /dev/ttyACM0, error 2, waiting for connection...
[1637094125.247322] info     | TermiosAgentLinux.cpp | init                     | Serial port not found. | device: /dev/ttyACM0, error 2, waiting for connection...
[1637094126.250484] info     | TermiosAgentLinux.cpp | init                     | Serial port not found. | device: /dev/ttyACM0, error 2, waiting for connection...
[1637094127.251737] info     | TermiosAgentLinux.cpp | init                     | Serial port not found. | device: /dev/ttyACM0, error 2, waiting for connection...
[1637094128.253653] info     | TermiosAgentLinux.cpp | init                     | Serial port not found. | device: /dev/ttyACM0, error 2, waiting for connection...
[1637094129.255863] info     | TermiosAgentLinux.cpp | init                     | Serial port not found. | device: /dev/ttyACM0, error 2, waiting for connection...
[1637094130.085380] info     | TermiosAgentLinux.cpp | init                     | running...             | fd: 3
[1637094130.085572] info     | Root.cpp           | set_verbose_level        | logger setup           | verbose_level: 4
[1637094131.908440] info     | Root.cpp           | create_client            | create                 | client_key: 0x49E910CB, session_id: 0x81
[1637094131.908500] info     | SessionManager.hpp | establish_session        | session established    | client_key: 0x49E910CB, address: 0
milner@canterbury:~/arduino-1.8.13/hardware/teensy/avr$
pablogs9 commented 3 years ago

Could you try to use the latest commit of the micro_ros_arduino repo & use the agent with:

docker run -it --rm --net=host -v /dev/shm:/dev/shm --privileged -v /dev:/dev microros/micro-ros-agent:galactic serial --dev /dev/serial/by-id/usb-Teensyduino_USB_Serial_8180040-if00 -v6

I have just tested Teensy 3.2 with the repo in d67c9dbe71644f004704914f2ce2e8dce5b0b94f (foxy) building with arduino-cli v0.1.8 and seems to work, I'm going to do some more tests.

pablogs9 commented 3 years ago

Could you paste your log of the agent with the flag -v6?

Acuadros95 commented 3 years ago

I just tried on a fresh foxy ROS install and all examples are working fine. This could be related to your ROS installation, did you modify it in any way? What is your output for apt list --installed | grep fast?

Could you run the agent with the debug flag? like this: ros2 run micro_ros_agent micro_ros_agent serial --dev /dev/ttyACM0 -v6

Anyway, you can try to run the dockerized agent, which should work out of the box.

carmiac commented 3 years ago

I just tried re-checking out and building all of micro_ros and now its working. Not sure if HEAD was broken for a few days or what, but it looks good now. Thanks!

avibrown commented 2 years ago

Hi, I followed this guide for getting MicroROS up and running on a Pi Pico, and succeeded at first. I was able to echo the pico_publisher topic... but only once. It ran for a while, then I CTRL+C'd out of the agent, and the echoing stopped as expected... Only now when I try and run the dockerized agent again I get the same Serial port not found. error that @carmiac reported.

Running Foxy on RPi4, Ubuntu 20.04 Server.

WARNING: apt does not have a stable CLI interface. Use with caution in scripts.

libfastjson4/focal,now 0.99.8-2 arm64 [installed,automatic]
ros-foxy-fastcdr/focal,now 1.0.13-1focal.20210901.042734 arm64 [installed,automatic]
ros-foxy-fastrtps-cmake-module/focal,now 1.0.4-1focal.20210901.175217 arm64 [installed,automatic]
ros-foxy-fastrtps/focal,now 2.1.1-1focal.20220209.133847 arm64 [installed,automatic]
ros-foxy-rmw-fastrtps-cpp/focal,now 1.3.0-1focal.20220209.140958 arm64 [installed,automatic]
ros-foxy-rmw-fastrtps-shared-cpp/focal,now 1.3.0-1focal.20220209.140231 arm64 [installed,automatic]
ros-foxy-rosidl-typesupport-fastrtps-c/focal,now 1.0.4-1focal.20220209.135407 arm64 [installed,automatic]
ros-foxy-rosidl-typesupport-fastrtps-cpp/focal,now 1.0.4-1focal.20220209.135238 arm64 [installed,automatic]

Would really appreciate some help on this! Thanks in advance.

Edit:

I also decided to rebuild MicroROS, and it looks like it managed to "unhang" whatever issue was preventing the agent from connecting. That said: The Pico does not seem to like it when the agent is "Interrupt" terminated! It often won't reconnect ("Serial port not found.") until I reconnect the USB a few times over. The easy solution is "OK, just don't terminate the agent then..." But it would be nice to figure out a way for auto-reconnect to work. Or maybe I'm just missing something.

pablogs9 commented 2 years ago

@avielbr micro-ROS does not reconnect automatically by default. Check this example for reference: https://github.com/micro-ROS/micro_ros_arduino/blob/humble/examples/micro-ros_reconnection_example/micro-ros_reconnection_example.ino