How to use import serial in Ros Foxy
Hello. I wanted to ask. Is it possible to use serial port for ros foxy for publishing data?
Thank you
ROS Resources: Documentation | Support | Discussion Forum | Index | Service Status | ros @ Robotics Stack Exchange |
Hello. I wanted to ask. Is it possible to use serial port for ros foxy for publishing data?
Thank you
You could try micro-ROS, but I am not sure if it fits your use case - could you describe it?
import RPi.GPIO as GPIO import time import serial
GPIO.setmode(GPIO.BCM)
redLED = 13 GPIO.setup(redLED, GPIO.OUT) GPIO.output(redLED,False)
ser = serial.Serial('/dev/ttyUSB0',115200,timeout=None)
while True: GPIO.output(redLED, False) line1 = ser.readline() line2 = ser.readline() line3 = ser.readline() line4 = ser.readline() ch1 = line1.strip().decode('utf-8') ch2 = line2.strip().decode('utf-8') ch3 = line3.strip().decode('utf-8') ch4 = line4.strip().decode('utf-8') print(ch1,ch2,ch3,ch4) GPIO.output(redLED, True) time.sleep(1) ser.close()
i wanted to publish the ser.readline data.
Then this demo https://micro.ros.org/blog/2019/06/03... or this tutorial https://ubuntu.com/blog/getting-start... suit you very well :) With Raspberry Pi and some LEDs
Asked: 2021-12-21 04:18:39 -0500
Seen: 305 times
Last updated: Dec 21 '21
float error while using a float - custom messages
rviz2 does not display an urdf file
/odom topic doesn't work on ROS2
[nav2] nav2_gazebo_spawner does not support specifying yaw
What went wrong with the installation?
Using Each Thread As Separate Publisher Node
How to build gtest tests in ros2?
Passing parameter for launch testing in ros2