ROS Resources: Documentation | Support | Discussion Forum | Index | Service Status | ros @ Robotics Stack Exchange
Ask Your Question
0

All publishers give this warning when a subscriber subscribes

asked 2020-10-23 02:22:17 -0600

feoranis26 gravatar image

All publishers give this warning when a subscriber subscribes to them using wait_for_message:

[WARN] [1603436136.720705]: Inbound TCP/IP connection failed: connection from sender terminated before handshake header received. 0 bytes were received. Please check sender for additional details.

The publisher:

#!/usr/bin/python3
import rospy, time, math
import RPi.GPIO as GPIO
from geometry_msgs.msg import Twist
import sys, subprocess
"""subprocess.Popen([sys.executable, 'sudo mjpg_streamer -i "/usr/local/lib/input_uvc.so" -o "/usr/local/lib/output_http.so -w /usr/local/www"'])"""


GPIO.setmode(GPIO.BCM)

GPIO.setup(27, GPIO.OUT)
lf = GPIO.PWM(27, 50)
GPIO.setup(23, GPIO.OUT)
rf = GPIO.PWM(23, 50)
lf.start(0)
rf.start(0)

GPIO.setup(17, GPIO.OUT)
lb = GPIO.PWM(17, 50)
GPIO.setup(22, GPIO.OUT)
rb = GPIO.PWM(22, 50)
lb.start(0)
rb.start(0)

wheel_pwm = rospy.Publisher("wheel_pwm", Twist, queue_size=1)

def receiveMessage(msg):
    l = min((msg.linear.x + (-msg.angular.z)) * 50, 99)
    r = min((msg.linear.x - (-msg.angular.z)) * 50, 99)
    wheelpwm = Twist()
    wheelpwm.linear.x = l; wheelpwm.linear.y = r; wheelpwm.linear.z = 0
    wheel_pwm.publish(wheelpwm)
    if l >= 0:
        lf.ChangeDutyCycle(l)
        lb.ChangeDutyCycle(0)
    else:
        lb.ChangeDutyCycle(l * -1)
        lf.ChangeDutyCycle(0)

    if r >= 0:
        rf.ChangeDutyCycle(r)
        rb.ChangeDutyCycle(0)
    else:
        rb.ChangeDutyCycle(r * -1)
        rf.ChangeDutyCycle(0)



rospy.init_node('fourwd')
rospy.Subscriber('key_vel', Twist, receiveMessage)
rospy.spin()
GPIO.cleanup()

This is the subscriber:

#!/usr/bin/python3
import RPi.GPIO as GPIO
from geometry_msgs.msg import Twist
import rospy
from std_msgs.msg import Int16
from threading import Thread, Event

GPIO.setmode(GPIO.BCM)

GPIO.setup(24, GPIO.IN)
GPIO.setup(25, GPIO.IN)



pub = rospy.Publisher("wheels", Twist, queue_size=1)


rospy.init_node('pub_encoders')

event = Event()


def Tick(lr_):
    while True:
        lpwm = lr_[4]
        rpwm = lr_[5]
        if not lr_[2] and GPIO.input(24):
            lr[0]+=lpwm
            lr_[2] = True
        elif not GPIO.input(24):
            lr_[2] = False
        if not lr_[3] and GPIO.input(25):
            lr[1]+=rpwm
            lr_[3] = True
        elif not GPIO.input(25):
            lr_[3] = False
        rospy.sleep(0.01)
def Publisher(lr_):
    while True:
        _t = Twist()
        _t.linear.x = lr[0]
        _t.linear.y = lr[1]
        pub.publish(_t)
        rospy.sleep(0.1)

lr = [0,0, False, False, 1, 1]


reader = Thread(target=Tick, args=(lr,))
reader.start()

publisher = Thread(target=Publisher, args=(lr,))
publisher.start()


while True:
    try:
        twst = rospy.wait_for_message("wheel_pwm", Twist)
        if twst.linear.x > 0:
            lr[4] = 1
        elif twst.linear.x < 0:
            lr[4] = -1
        if twst.linear.y > 0:
            lr[5] = 1
        elif twst.linear.y < 0:
            lr[5] = -1
    except rospy.exceptions.ROSException:
        pass
edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted
0

answered 2020-10-24 00:42:46 -0600

miura gravatar image
rospy.Subscriber('key_vel', Twist, receiveMessage)

'key_vel' is about to be received, but what is actually being sent is "wheels".

rospy.Subscriber('wheels', Twist, receiveMessage)

I think that would solve the problem.

edit flag offensive delete link more

Comments

Those two are entirely different stuff, one is the vx,vy,vth message and the other is raw pwm duty cycle output from the program to be used in the pub_encoders program, and those examples aren't the only ones that i'm getting this error from. There isn't a subscriber subscribed to "wheels" in those programs, am I missing something?

feoranis26 gravatar image feoranis26  ( 2020-10-24 03:38:41 -0600 )edit

If it doesn't subscribe to key_vel, it looks like wheel_pwm won't be published.

miura gravatar image miura  ( 2020-10-25 05:20:23 -0600 )edit

It is subscribed to key_vel, and it does publish wheel_pwm, this warning doesn't prevent the publisher/subscribers from working, I just get this warning when data is being sent, everything else works as intended

feoranis26 gravatar image feoranis26  ( 2020-10-25 07:16:27 -0600 )edit

Question Tools

2 followers

Stats

Asked: 2020-10-23 02:01:06 -0600

Seen: 185 times

Last updated: Oct 24 '20