Ask Your Question
0

How to call a service of a seperate package from a node frm another package?

asked 2017-04-21 12:54:42 -0500

maxsteel777 gravatar image

updated 2017-04-22 17:10:06 -0500

ahendrix gravatar image

I'm using the rosarduino bridge package on a custom robot and i'm developing a node access the package when required. but im havin trouble callin the services in arduinobridge usin rospy.serviceproxy(' ', )

shld it be called usin another function in da client node.. i did add da dependacies in da node.

This is da code I used to call the service

#!/usr/bin/env python

import sys
import rospy
from ros_arduino_python import *
from ros_arduino_msgs.srv import *

def digital_write_client(pin, value):
  # rospy.wait_for_sevice('digital_write')
   try:
        digital_write = rospy.ServiceProxy('digital_write', DigitalWrite)
        digital_write(pin,value)
        print"call success"
   except rospy.ServiceException, e:
        print "Service call failed: %s"%e   

if __name__ == "__main__":
   digital_write_client(8,1)
edit retag flag offensive close merge delete

Comments

1

Which service are you trying to call? What happens when you try to call it? Do you get a python stack trace?

ahendrix gravatar image ahendrix  ( 2017-04-21 18:55:08 -0500 )edit

i'm tryin to call DigitalWrite.srv using the below code, but i keep gettin da exception i have implemented. I'm new to ROS so having trouble

rospy.wait_for_sevice('digital_write')

try: digital_write = rospy.ServiceProxy('digital_write', DigitalWrite) digital_write(pin,value)

maxsteel777 gravatar image maxsteel777  ( 2017-04-21 23:04:39 -0500 )edit

Please edit your question with the full program that you're trying to run, and the full exception that you get.

ahendrix gravatar image ahendrix  ( 2017-04-22 00:11:29 -0500 )edit

1 Answer

Sort by ยป oldest newest most voted
0

answered 2017-04-22 07:56:59 -0500

maxsteel777 gravatar image

updated 2017-04-22 07:58:50 -0500

I found da error in the code. I had been usin the wrong service name (rospy.ServiceProxy('digital_write', DigitalWrite). I changed it to 'arduino/digital_write' and its workin fine. Thank you

edit flag offensive delete link more

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools

1 follower

Stats

Asked: 2017-04-21 12:54:42 -0500

Seen: 532 times

Last updated: Apr 22 '17