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

I write a service client code. But I always take same error. I send codes. Please help. Error processing request: 'geriSayRequest' object has no attribute 'sonuc'

asked 2023-06-28 10:41:18 -0500

updated 2023-06-28 16:45:19 -0500

Mike Scheutzow gravatar image

This is service code:

import rospy
from temizlik_robotu_pkg.srv import *
def servisCevapCB(istek):
    print(istek.sayi)
    istek.sonuc=1
    return istek

def servisSayma():
    rospy.init_node("servis_geri_say_nd")
    rospy.Service("geri_say", geriSay, servisCevapCB)
    rospy.spin()

servisSayma()

And this is client code:

import rospy
from temizlik_robotu_pkg.srv import *

def client():
    rospy.init_node("client_geri_say_nd")
    rospy.wait_for_service("geri_say")
    servis=rospy.ServiceProxy("geri_say", geriSay)

try:
    gelen_cevap=servis(5)

    print("sonuc: " +gelen_cevap.sonuc)
except rospy.ServiceException:
    print("servisde hata var")

client()

and this is .srv file:

int32 sayi
---

int32 sonuc
edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted
0

answered 2023-06-28 17:03:30 -0500

Mike Scheutzow gravatar image

updated 2023-06-28 17:04:11 -0500

Inside the service callback, you are passed a geriSayRequest object. The callback is expected to return a geriSayResponse object, so you must create one and fill in the field.

edit flag offensive delete link more

Question Tools

Stats

Asked: 2023-06-28 10:41:18 -0500

Seen: 40 times

Last updated: Jun 28 '23