0
$\begingroup$

Rosanswers logo

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)

Originally posted by maxsteel777 on ROS Answers with karma: 16 on 2017-04-21

Post score: 0


Original comments

Comment by ahendrix on 2017-04-21:
Which service are you trying to call? What happens when you try to call it? Do you get a python stack trace?

Comment by maxsteel777 on 2017-04-21:
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)

Comment by ahendrix on 2017-04-22:
Please edit your question with the full program that you're trying to run, and the full exception that you get.

$\endgroup$

1 Answer 1

0
$\begingroup$

Rosanswers logo

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


Originally posted by maxsteel777 with karma: 16 on 2017-04-22

This answer was ACCEPTED on the original site

Post score: 0

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.