예제 #1
0
def main():
    rospy.init_node("call_move_square_custom_node")
    #waiting
    rospy.wait_for_service("/move_bb8_in_square_custom")

    try:
        rospy.loginfo("Executing client...")

        #open the service client
        moving_robot = rospy.ServiceProxy('/move_bb8_in_square_custom',
                                          MyCustomServiceMessage)

        #pack the request actions in the object
        actions = MyCustomServiceMessageRequest()
        actions.radius = 2.0
        actions.repetitions = 2

        #send the actions to the server
        result = moving_robot(actions)

        if result:
            rospy.loginfo("The mission is completed!")

        #pack the request actions in the object
        actions2 = MyCustomServiceMessageRequest()
        actions2.radius = 3.0
        actions2.repetitions = 1

        #send the actions to the server
        result2 = moving_robot(actions2)

        if result2:
            rospy.loginfo("The mission is completed!")

    except:
        rospy.loginfo("An error occured in client")
예제 #2
0
#! /usr/bin/env python

import rospy
from my_custom_srv_msg_pkg.srv import MyCustomServiceMessage, MyCustomServiceMessageRequest

rospy.init_node('start_bb8_square_move')
print("Waiting for /bb8service to start")
rospy.wait_for_service('/move_bb8_in_square_custom')

req = MyCustomServiceMessageRequest()
req.radius = 0.1
req.repetitions = 2
bb8_move_custom_square_service = rospy.ServiceProxy('/move_bb8_in_square_custom', MyCustomServiceMessage)
print("Requesting BB8 move in custom square")
result1 = bb8_move_custom_square_service(req)
req.radius = 0.3
req.repetitions = 1
result2 = bb8_move_custom_square_service(req)
if result1.success ==  False or result2.success == False:
  print("Move failed")
else:
  print("Successfully completed the move")