Ask Your Question
-2

I want to send multiple requst and multiple response,but something wrong,how to debug it?[solved] [closed]

asked 2012-06-01 17:00:35 -0500

this post is marked as community wiki

This post is a wiki. Anyone with karma >75 is welcome to improve it.

this is client

#! /usr/bin/env python
import roslib; roslib.load_manifest('beginner_tutorials')

from beginner_tutorials.srv import *
import rospy
import sys
from beginner_tutorials.srv import xin2
import beginner_tutorials.msg

def callserver2(aa,bb):
  rospy.wait_for_service('girl')

  try:
    pse = rospy.ServiceProxy('girl',xin2)
    reqMsg = beginner_tutorials.msg.xin2(aa,bb)
    resp2 = pse(reqMsg)
    return resp2
  except rospy.ServiceException ,e:
    print "failed to send "

if __name__=='__main__':
  aa = "PSD has closed"
  bb = "routine is ok"
  res = callserver2(aa,bb)
  print res
  print res.out.cc
  print res.out.dd
  print "train number is :%s" %res.out.ee

this is server

#! /usr/bin/env python
import roslib;roslib.load_manifest('beginner_tutorials')
import sys
import rospy
from beginner_tutorials.srv import *
import beginner_tutorials.msg

def processReq2(req):
  print "req  :train\'speed is %s km/h, train\'local is %s"%(req.in_.aa,req.in_.bb)
  print req 
  try:
    respMsg = beginner_tutorials.msg.xin2_2(cc,dd,ee)
    return xin2Response(respMsg)
  except :
    print "ATO failed to send back "

def Server(cc,dd,ee):
  rospy.init_node('ATO')
  s= rospy.Service('girl',xin2, processReq2)
  print "readying "
  rospy.spin()

if __name__=='__main__':
  cc = "train door : closed"
  dd = "operation model : AM"
  ee = 801
  Server(cc,dd,ee)

xin2.srv

beginner_tutorials/xin2 in
---
beginner_tutorials/xin2_2 out

xin2.msg ## :

string aa
string bb

xin2_2.msg

string cc
string dd
int16 ee
edit retag flag offensive reopen merge delete

Closed for the following reason Question does not follow our guidelines for questions. Please see: http://wiki.ros.org/Support for more details. by tfoote
close date 2012-06-05 20:46:44

Comments

i have no idea about the typesetting,i just copy the code from my file

malong gravatar image malong  ( 2012-06-01 17:10:06 -0500 )edit

You say something went wrong. What did you expect? What happened instead?

joq gravatar image joq  ( 2012-06-01 18:05:26 -0500 )edit

1st: I copy the code from my file,why it is shambles? what is karma? 2nd : I have 2 requsts and 2 response ,how to realise it ? 3rd: i have run files in the terminal, but there are something wrong.all the code , msg and srv are above.

malong gravatar image malong  ( 2012-06-01 19:19:41 -0500 )edit

For literal code to display correctly, this forum requires you to add four spaces in front of each line. I fixed it for you once already. I am not going to do that again.

joq gravatar image joq  ( 2012-06-02 05:11:47 -0500 )edit
2

You still have not told us what you expect this code to do.

joq gravatar image joq  ( 2012-06-02 05:12:16 -0500 )edit

ok,i have solved this peoblem.thank you! in this file, msg is called in the srv; called xin2.msg in the req of xin2.srv, and called xin2_2.msg in the resp of xin2.srv.thus,i can realise two values in the req and two values in the resp.

malong gravatar image malong  ( 2012-06-03 15:51:08 -0500 )edit

1 Answer

Sort by » oldest newest most voted
0

answered 2012-06-05 20:46:15 -0500

this post is marked as community wiki

This post is a wiki. Anyone with karma >75 is welcome to improve it.

From @malong's comment:

ok,i have solved this peoblem.thank you! in this file, msg is called in the srv; called xin2.msg in the req of xin2.srv, and called xin2_2.msg in the resp of xin2.srv.thus,i can realise two values in the req and two values in the resp.

edit flag offensive delete link more

Question Tools

1 follower

Stats

Asked: 2012-06-01 17:00:35 -0500

Seen: 2,537 times

Last updated: Jun 05 '12