示例#1
0
def my_callback(request):
    rospy.loginfo('Service has been called')
    obj = MoveBB8()
    obj.move_bb8(request.duration)
    rospy.loginfo('Finished')
    response = MyCustomServiceMessageResponse()
    response.success = True
    return response
示例#2
0
def my_callback(request):
    print "Request Data==> duration==>" + str(request.duration)
    my_response = MyCustomServiceMessageResponse()
    if request.duration > 5.0:
        my_response.success = True
    else:
        my_response.success = False
    return my_response
示例#3
0
 def service(self, *data):
     request = data[0]
     my_response = MyCustomServiceMessageResponse()
     if request.duration > 5.0:
         my_response.success = True
     else:
         my_response.success = False
     return my_response
示例#4
0
def my_callback(request):
    rospy.loginfo("The Service move_bb8_in_circle has been called")
    movebb8_object = MoveBB8()
    movebb8_object.move_bb8(request.duration)
    rospy.loginfo("Finished service move_bb8_in_circle")
    response = MyCustomServiceMessageResponse()
    response.success = True
    return response
示例#5
0
def my_callback(request):
    print "Request Data => radius= "+str(request.radius)+", repetitions = "+str(request.repetitions)
    my_response = MyCustomServiceMessageResponse()
    if request.radius > 5.0:
        my_response.success = True
    else:
        my_response.success = False
    
    return my_response #the service response class
def my_callback(request):
    print "Request Data Received"
    print "Radians = " + str(request.radians)
    print "Repeatitions = " + str(request.repeatitions)
    my_response = MyCustomServiceMessageResponse()
    if request.radians > 0.5:
        my_response.success = True
    else:
        my_response.success = False
    return my_response
示例#7
0
    def service(self, *data):
        request = data[0]

        self.pub_.publish(self.cmd_vel_move_)
        for _ in range(request.duration):
            self.rate_.sleep()

        self.pub_.publish(self.cmd_vel_stop_)

        my_response = MyCustomServiceMessageResponse()
        my_response.success = True
        return my_response
示例#8
0
def move_callback(request):
    #print ("move_callback has been called")
    print "Request Data==> radius=" + str(
        request.radius) + ", repetitions = " + str(request.repetitions)
    response = MyCustomServiceMessageResponse()
    if request.radius > 1 or request.radius == 0.0 or request.repetitions < 1 or request.repetitions > 10:
        response.success = False
        print("Bad arguements. Either radius or repetitions is out of range")
        return response
    for i in range(request.repetitions):
        moveBB8.move_square(request.radius)
    #print("move complete")
    response.success = True
    return response
def my_callback(request):
    print "Request Data==> duration=" + str(request.duration)
    i = 0
    while i < request.duration:  #request.duration is the Argument taken by the service message when called, as detailed in MyCustomServiceMessage
        move_circle.linear.x = 0.2
        move_circle.angular.z = 0.2
        my_pub.publish(move_circle)
        rate.sleep()
        i = i + 1
    else:
        move_circle.linear.x = 0
        move_circle.angular.z = 0
        my_pub.publish(move_circle)
    my_response = MyCustomServiceMessageResponse()
    my_response.success = True
    return my_response
示例#10
0
def my_callback(request):
    my_response = MyCustomServiceMessageResponse()
    time = my_response.duration
    rospy.loginfo("BB8 will start moving in circle")
    while time > 0:
        move_bb8.linear.x = 0.1
        move_bb8.angular.z = 0.5
        pub1.publish(move_bb8)
        time -= 1
        sleep(1)
    move_bb8.linear.x = 0.0
    move_bb8.angular.z = 0.0
    pub1.publish(move_bb8)
    rospy.loginfo("BB8 finished moving in circle")
    my_response.success = True
    return my_response  # the service Response class, in this case EmptyResponse
示例#11
0
def my_callback(request):
    global value
    print "Request Data==> duration=" + str(request.duration)

    value.linear.x = 0.5
    value.linear.z = 0.5
    value.angular.z = .5
    value.angular.x = .5
    pub.publish(value)
    rospy.sleep(request.duration)
    value.linear.x = 0
    value.linear.z = 0
    value.angular.z = 0
    value.angular.x = 0
    pub.publish(value)
    my_response = MyCustomServiceMessageResponse()
    my_response.success = True
    return my_response  # the service Response class, in this case EmptyResponse
def my_callback(request):
    rospy.loginfo("The Service move_bb8_in_circle_custom has been called")
    move_circle.linear.x = 0.2
    move_circle.angular.z = 0.2
    i = 0
    while i <= request.duration:
        my_pub.publish(move_circle)
        rate.sleep()
        i = i + 1

    move_circle.linear.x = 0
    move_circle.angular.z = 0
    my_pub.publish(move_circle)
    rospy.loginfo("Finished service move_bb8_in_circle_custom")

    response = MyCustomServiceMessageResponse()
    response.success = True
    return response  # the service Response class, in this case EmptyResponse
示例#13
0
def my_callback(request):

    print "Request Data==> duration=" + str(request.duration)
    my_response = MyCustomServiceMessageResponse()
    move = Twist()
    move.linear.x = 0.2
    move.angular.z = 0.2
    i = 0

    while i <= request.duration:
        pub.publish(move)
        rate.sleep()
        i = i + 1

    my_response.success = True
    move.angular.z = 0
    move.linear.x = 0
    pub.publish(move)

    return my_response
示例#14
0
def squareCallback(request):
    rospy.loginfo("Lets initialize the robot move...")
    ##initializing our response object
    response = MyCustomServiceMessageResponse()

    #create the robot movement object
    square = MoveBB8()
    errors = 0
    for i in range(request.repetitions):
        #movin with a side size
        try:
            square.movesinSquare(request.radius)
        except Exception as e:
            errors += 1
    if errors == 0:
        response.success = True
    else:
        response.success = False

    return response
def my_callback(request):
    rospy.loginfo("The Service move_bb8_in_circle_custom Has Been Called")

    move_circle.linear.x = 0.2
    move_circle.angular.z = 0.2

    i = 0
    while i <= request.duration:
        my_pub.publish(move_circle)
        rate.sleep()
        i += 1

    move_circle.linear.x = 0
    move_circle.angular.z = 0
    my_pub.publish(move_circle)
    rospy.loginfo("Finished Service move_bb8_in_circle_custom")

    response = MyCustomServiceMessageResponse()
    response.success = True

    return response
def my_callback(request):

    rospy.loginfo("Your request to move bb8 in a circle has been received.")

    # start moving robot in circle for request.duration in seconds
    move.linear.x = 0.5
    move.angular.z = 0.5
    pub.publish(move)
    rospy.sleep(request.duration)

    # stop moving robot once request.duration is completed
    move.linear.x = 0.0
    move.angular.z = 0.0
    pub.publish(move)

    rospy.loginfo("Your bb8 has executed circles for the requested duration.")

    # set response of message to True
    response = MyCustomServiceMessageResponse()
    response.success = True

    return response  # the service Response class, in this case MyCustomServiceMessage
示例#17
0
def my_callback(request):
    for side in range(4):
        move_straight(10.5)
        stop(5)
        turn(7)

    #while i <= request.duration:
    #    i+=1
    #    j = 0
    #    while j < 5:
    #        move.linear.x += 0.2
    #        move.angular.z += 0.0
    #        pub.publish(move)
    #        rate.sleep()

    response = MyCustomServiceMessageResponse()
    response.success = True
    move.linear.x = 0.0
    move.angular.z = 0.0
    pub.publish(move)
    rate.sleep()
    return response  # the service Response class, in this case EmptyResponse
示例#18
0
def my_callback(request):
    res = MyCustomServiceMessageResponse()
    res.success = True

    return res
#! /usr/bin/env python

import rospy
from std_srvs.srv import Empty, EmptyResponse
from my_custom_srv_msg_pkg.srv import MyCustomServiceMessage, MyCustomServiceMessageResponse
from bb8_move_circle_class import MoveBB8


def my_callback(request):

    rospy.loginfo("The Service move_bb8_in_circle has been called")

    movebb8_object = MoveBB8()
    movebb8_object.move_bb8(request.duration)
    rospy.loginfo("Finished service move_bb8_in_circle for requested duration")
    response = custom_request
    custom_request.success = True
    return response


rospy.init_node('service_move_bb8_in_circle_server')
my_service = rospy.Service('/move_bb8_in_circle', MyCustomServiceMessage,
                           my_callback)
custom_request = MyCustomServiceMessageResponse()
rospy.loginfo("Service /move_bb8_in_circle Ready")
rospy.spin()  # mantain the service open.