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
What went wrong with the installation?
Update subframe of collision object?
What is best practice for parameters which are empty lists in ros2
[ROS2] time.sleep() in a node [closed]
ValueError: Expected the full name of a message, got 'std_msgs/String'
How to build gtest tests in ros2?
Passing parameter for launch testing in ros2