"ERROR: Broken Pipe" on simple action server
Apologies if this is a newbie error but I can't find any previous posts on the subject.
I have a simple Action server that takes two arguments, a speed and duration, and outputs a message along the lines of "Drive in a square at 100 speed, 2 seconds per side".
It appears to work but I see a "Broken Pipe" message in the output, along with a TCP/IP connection failed warning:
[DEBUG] [1559657743.097583]: connecting to storm 33977
[DEBUG] [1559657743.173149]: The action server has received a new goal request
[DEBUG] [1559657743.184566]: A new goal /square_action_client-1-1559657743.170has been recieved by the single goal action server
[DEBUG] [1559657743.209280]: Accepting a new goal
[DEBUG] [1559657743.218293]: Accepting goal, id: /square_action_client-1-1559657743.170, stamp: 1559657743.17
[DEBUG] [1559657743.227325]: Drive in a square at 100 speed, 2 seconds per side
[DEBUG] [1559657743.235513]: Setting status to succeeded on goal, id: /square_action_client-1-1559657743.170, stamp: 1559657743.17
[DEBUG] [1559657743.310479]: connecting to storm 33977
[DEBUG] [1559657743.315485]: connecting to storm 33977
[WARN] [1559657744.034893]: Inbound TCP/IP connection failed: connection from sender terminated before handshake header received. 0 bytes were received. Please check sender for additional details.
[DEBUG] [1559657744.339137]: connecting to storm 33977
[DEBUG] [1559657748.262286]: Item stamp:
secs: 1559657743
nsecs: 170017957
id: "/square_action_client-1-1559657743.170" with destruction time of 1559657743.243 being removed from list. Now = 1559657748.259
This might be expected behaviour I guess (client has exited so nothing to read) but I wondered if maybe I needed to signal that I was exiting somehow ?
Source code below in case it helps.
Thanks for any help or advice,
David
Square_action_server.py:
#! /usr/bin/env python
import rospy
import time
import actionlib
from storm.msg import SquareAction, SquareGoal, SquareResult
def drive_square(goal):
start_time = time.time()
# extract the goal parameters
speed = goal.speed
secs_per_side = goal.secs_per_side.to_sec()
# perform the necessary actions
rospy.logdebug("Drive in a square at %d speed, %d seconds per side", speed, secs_per_side)
# send the result
result = SquareResult()
result.time_driven = rospy.Duration.from_sec(time.time() - start_time)
result.updates_sent = 0
server.set_succeeded(result)
rospy.init_node('ROS_SQUARE_DRIVE', log_level=rospy.DEBUG)
server = actionlib.SimpleActionServer('square_drive', SquareAction, drive_square, False)
server.start()
rospy.spin()
Square_action_client.py:
#! /usr/bin/env python
import rospy
import actionlib
from storm.msg import SquareAction, SquareGoal, SquareResult
rospy.init_node('square_action_client')
client = actionlib.SimpleActionClient('square_drive', SquareAction)
client.wait_for_server()
# Drive in a square at a specified speed, for a specified number of seconds per side
# 0 is full reverse, 180 is full lspeed forward, 90 is stopped
# e.g. drive forward at speed 100 for 2 seconds per side
goal = SquareGoal()
goal.secs_per_side = rospy.Duration.from_sec(2.0)
goal.speed = 100
client.send_goal(goal)
client.wait_for_result()
print('Time elapsed: %f'%(client.get_result().time_driven.to_sec()))