示例#1
0
    def __init__(self,
                 rotation=0,
                 low_light=False,
                 calibration={},
                 smoothing=0,
                 register_services=True,
                 environmental_publishing=True,
                 environmental_publishing_rate=12,
                 imu_publishing=False,
                 imu_publishing_mode="get_orientation_degrees_rpy",
                 imu_publishing_config="1|1|1",
                 imu_publishing_rate=1,
                 stick_publishing=True,
                 stick_sampling=0.2):
        """Constructor method"""

        # Init sensor
        self.sense = SenseHat()
        self.sense.clear(0, 0, 0)
        self.sense.set_rotation(rotation)
        self.sense.low_light = low_light
        self.measures = {
            'humidity': self.sense.get_humidity,
            'temperature_from_humidity':
            self.sense.get_temperature_from_humidity,
            'temperature_from_pressure':
            self.sense.get_temperature_from_pressure,
            'pressure': self.sense.get_pressure,
            'compass': self.sense.get_compass,
        }
        self.imu_modes = {
            'get_orientation_radians_rpy': self.sense.get_orientation_radians,
            'get_orientation_degrees_rpy': self.sense.get_orientation_degrees,
            'get_compass_raw_xyz': self.sense.get_compass_raw,
            'get_gyroscope_rpy': self.sense.get_gyroscope,
            'get_gyroscope_raw_xyz': self.sense.get_gyroscope_raw,
            'get_accelerometer_rpy': self.sense.get_accelerometer,
            'get_accelerometer_raw_xyz': self.sense.get_accelerometer_raw,
        }

        # Init parameters
        self.stick_publishing = stick_publishing
        self.environmental_publishing = environmental_publishing
        self.imu_publishing = imu_publishing
        self.imu_publishing_mode = imu_publishing_mode
        self.stick_sampling = stick_sampling
        self.environmental_publishing_rate = environmental_publishing_rate
        self.imu_publishing_rate = imu_publishing_rate
        self.calibration = calibration
        self.register_services = register_services
        self.smoothing = smoothing
        self.history = {}
        for measure in self.measures:
            self.history[measure] = collections.deque(
                [], maxlen=smoothing
                if smoothing > 0 else None) if smoothing >= 0 else None

        # Init Lock to serialize access to the LED Matrix
        self.display_lock = Lock()

        # Register publishers
        if self.stick_publishing:
            self.stick_pub = rospy.Publisher("Stick", Stick, queue_size=10)
        if self.environmental_publishing:
            self.environmental_pub = rospy.Publisher("Environmental",
                                                     Environmental,
                                                     queue_size=10)
        if self.imu_publishing:
            self.sense.set_imu_config(
                *[i == "1" for i in imu_publishing_config.split("|")])
            self.imu_pub = rospy.Publisher("IMU", IMU, queue_size=10)

        # Register services
        if self.register_services:
            self.getEnvironmentalService = rospy.Service(
                "GetEnvironmental", GetEnvironmental, self.getEnvironmental)
            self.getHumidityService = rospy.Service("GetHumidity", GetHumidity,
                                                    self.getHumidity)
            self.getTemperatureService = rospy.Service("GetTemperature",
                                                       GetTemperature,
                                                       self.getTemperature)
            self.getPressureService = rospy.Service("GetPressure", GetPressure,
                                                    self.getPressure)
            self.getIMUService = rospy.Service("GetIMU", GetIMU, self.getIMU)
            self.getCompassService = rospy.Service("GetCompass", GetCompass,
                                                   self.getCompass)
            self.emulateStick = rospy.Service("EmulateStick", EmulateStick,
                                              self.emulateStick)
            self.clearService = rospy.Service("Clear", Clear, self.clear)
            self.setPixelsService = rospy.Service("SetPixels", SetPixels,
                                                  self.setPixels)
            self.switchLowLightService = rospy.Service("SwitchLowLight",
                                                       SwitchLowLight,
                                                       self.switchLowLight)
            self.showLetterService = rospy.Service("ShowLetter", ShowLetter,
                                                   self.showLetter)
            self.showMessageService = rospy.Service("ShowMessage", ShowMessage,
                                                    self.showMessage)

        rospy.loginfo("sensehat_ros initialized")
示例#2
0
def strategy_server():
    #rospy.init_node(NAME)
    s = rospy.Service('arm_state', arm_state,
                      Arm_state)  ##server arm point data
示例#3
0
 def __init__(self):
     self.direction = "x"
     rospy.Subscriber("/argo/key_cmd", String, self.save_cmd)
     self.s = rospy.Service("get_direction", GetDirection, self.get_cmd)
     print "Direction Server Ready"
     rospy.spin()
示例#4
0
    def __init__(self):
        self.sim_mode = rospy.get_param('simulation_mode', False)
        self.publish_joint_angles = rospy.get_param(
            'publish_joint_angles', True)  # if self.sim_mode else False
        self.publish_temperatures = rospy.get_param('publish_temperatures',
                                                    True)

        self.axis_for_right = float(rospy.get_param(
            '~axis_for_right',
            0))  # if right calibrates first, this should be 0, else 1
        self.wheel_track = float(rospy.get_param(
            '~wheel_track', 0.285))  # m, distance between wheel centres
        self.tyre_circumference = float(
            rospy.get_param('~tyre_circumference', 0.341)
        )  # used to translate velocity commands in m/s into motor rpm

        self.connect_on_startup = rospy.get_param('~connect_on_startup', False)
        #self.calibrate_on_startup = rospy.get_param('~calibrate_on_startup', False)
        #self.engage_on_startup    = rospy.get_param('~engage_on_startup', False)

        self.has_preroll = rospy.get_param('~use_preroll', True)

        self.publish_current = rospy.get_param('~publish_current', True)
        self.publish_raw_odom = rospy.get_param('~publish_raw_odom', True)

        self.publish_odom = rospy.get_param('~publish_odom', True)
        self.publish_tf = rospy.get_param('~publish_odom_tf', False)
        self.odom_topic = rospy.get_param('~odom_topic', "odom")
        self.odom_frame = rospy.get_param('~odom_frame', "odom")
        self.base_frame = rospy.get_param('~base_frame', "base_link")
        self.odom_calc_hz = rospy.get_param('~odom_calc_hz', 10)

        rospy.on_shutdown(self.terminate)

        rospy.Service('connect_driver', std_srvs.srv.Trigger,
                      self.connect_driver)
        rospy.Service('disconnect_driver', std_srvs.srv.Trigger,
                      self.disconnect_driver)

        rospy.Service('calibrate_motors', std_srvs.srv.Trigger,
                      self.calibrate_motor)
        rospy.Service('calibrate_motors_reverse', std_srvs.srv.Trigger,
                      self.calibrate_motor_reverse)
        rospy.Service('engage_motors', std_srvs.srv.Trigger, self.engage_motor)
        rospy.Service('release_motors', std_srvs.srv.Trigger,
                      self.release_motor)

        self.status_pub = rospy.Publisher('status',
                                          std_msgs.msg.String,
                                          latch=True)
        self.status_pub.publish("disconnected")

        self.command_queue = Queue.Queue(maxsize=5)
        self.vel_subscribe = rospy.Subscriber("/cmd_vel",
                                              Twist,
                                              self.cmd_vel_callback,
                                              queue_size=2)

        if self.publish_temperatures:
            self.temperature_publisher_left = rospy.Publisher(
                'left/temperature', Float64, queue_size=2)
            self.temperature_publisher_right = rospy.Publisher(
                'right/temperature', Float64, queue_size=2)

        if self.publish_current:
            self.current_loop_count = 0
            self.left_current_accumulator = 0.0
            self.right_current_accumulator = 0.0
            self.current_publisher_left = rospy.Publisher('left/current',
                                                          Float64,
                                                          queue_size=2)
            self.current_publisher_right = rospy.Publisher('right/current',
                                                           Float64,
                                                           queue_size=2)
            rospy.logdebug("ODrive will publish motor currents.")

        self.last_cmd_vel_time = rospy.Time.now()

        if self.publish_raw_odom:
            self.raw_odom_publisher_encoder_left = rospy.Publisher(
                'left/raw_odom/encoder', Int32,
                queue_size=2) if self.publish_raw_odom else None
            self.raw_odom_publisher_encoder_right = rospy.Publisher(
                'right/raw_odom/encoder', Int32,
                queue_size=2) if self.publish_raw_odom else None
            self.raw_odom_publisher_vel_left = rospy.Publisher(
                'left/raw_odom/velocity', Int32,
                queue_size=2) if self.publish_raw_odom else None
            self.raw_odom_publisher_vel_right = rospy.Publisher(
                'right/raw_odom/velocity', Int32,
                queue_size=2) if self.publish_raw_odom else None

        if self.publish_odom:
            rospy.Service('reset_odometry', std_srvs.srv.Trigger,
                          self.reset_odometry)
            self.old_pos_l = 0
            self.old_pos_r = 0

            self.odom_publisher = rospy.Publisher(self.odom_topic,
                                                  Odometry,
                                                  tcp_nodelay=True,
                                                  queue_size=2)
            # setup message
            self.odom_msg = Odometry()
            #print(dir(self.odom_msg))
            self.odom_msg.header.frame_id = self.odom_frame
            self.odom_msg.child_frame_id = self.base_frame
            self.odom_msg.pose.pose.position.x = 0.0
            self.odom_msg.pose.pose.position.y = 0.0
            self.odom_msg.pose.pose.position.z = 0.0  # always on the ground, we hope
            self.odom_msg.pose.pose.orientation.x = 0.0  # always vertical
            self.odom_msg.pose.pose.orientation.y = 0.0  # always vertical
            self.odom_msg.pose.pose.orientation.z = 0.0
            self.odom_msg.pose.pose.orientation.w = 1.0
            self.odom_msg.twist.twist.linear.x = 0.0
            self.odom_msg.twist.twist.linear.y = 0.0  # no sideways
            self.odom_msg.twist.twist.linear.z = 0.0  # or upwards... only forward
            self.odom_msg.twist.twist.angular.x = 0.0  # or roll
            self.odom_msg.twist.twist.angular.y = 0.0  # or pitch... only yaw
            self.odom_msg.twist.twist.angular.z = 0.0

            # store current location to be updated.
            self.x = 0.0
            self.y = 0.0
            self.theta = 0.0

            # setup transform
            self.tf_publisher = tf2_ros.TransformBroadcaster()
            self.tf_msg = TransformStamped()
            self.tf_msg.header.frame_id = self.odom_frame
            self.tf_msg.child_frame_id = self.base_frame
            self.tf_msg.transform.translation.x = 0.0
            self.tf_msg.transform.translation.y = 0.0
            self.tf_msg.transform.translation.z = 0.0
            self.tf_msg.transform.rotation.x = 0.0
            self.tf_msg.transform.rotation.y = 0.0
            self.tf_msg.transform.rotation.w = 0.0
            self.tf_msg.transform.rotation.z = 1.0

        if self.publish_joint_angles:
            self.joint_state_publisher = rospy.Publisher(
                '/odrive/joint_states', JointState, queue_size=2)

            jsm = JointState()
            self.joint_state_msg = jsm
            #jsm.name.resize(2)
            #jsm.position.resize(2)
            jsm.name = ['joint_left_wheel', 'joint_right_wheel']
            jsm.position = [0.0, 0.0]
        )
        resp.result = StartObjectTrackingResponse.FAILURE
    print("done")
    return resp


def stop_tracking(req):
    global tracked_object_id
    global timer

    resp = StopObjectTrackingResponse()
    if not tracked_object_id == "":
        tracked_object_id = ""
        timer.shutdown()
        rospy.loginfo("stopTracking: stopped")
        resp.result = StopObjectTrackingResponse.SUCCESS
    else:
        rospy.logerr("stopTracking: currently not tracking an object")
        resp.result = StopObjectTrackingResponse.FAILURE
    return resp


if __name__ == "__main__":
    rospy.sleep(2)
    s1 = rospy.Service("/squirrel_start_object_tracking", StartObjectTracking,
                       start_tracking)
    s2 = rospy.Service("/squirrel_stop_object_tracking", StopObjectTracking,
                       stop_tracking)
    rospy.loginfo("Ready to get service calls...")
    rospy.spin()
示例#6
0
    sendADDRESS = args[1]
    sendPORT    = args[2]
    recvADDRESS = args[3]
    recvPORT    = args[4] 
  else:
    sendPORT = 9180
    recvPORT = 9182
    sendADDRESS = "127.0.1.1"
    recvADDRESS = "127.0.1.1"

  print("sendADD:", sendADDRESS, ", sendPORT:", sendPORT)
  print("recvADD:", recvADDRESS, ", recvPORT:", recvPORT)
  udp = udpcomm.Udpcomm(sendADDRESS, sendPORT, recvADDRESS, recvPORT)

  rospy.init_node('robotino')
  srv01 = rospy.Service('rvw2/setVelocity', SetVelocity, setVelocity)
  srv02 = rospy.Service('rvw2/positionDriver', SetPosition, setPosition)
  srv03 = rospy.Service('rvw2/setOdometry', SetOdometry, setOdometry)
  # pub01 = rospy.Publisher('odometry', Float32MultiArray, queue_size = 10)
  pub01 = rospy.Publisher('robotino/odometry', Odometry, queue_size = 10)
  pub02 = rospy.Publisher('robotino/checkFlag', Bool, queue_size = 10)
  pub03 = rospy.Publisher('robotino/getVelocity', Float32MultiArray, queue_size = 10)
  rate = rospy.Rate(10)

  velocityData = SetVelocity()
  velocityData.pose = [0, 0, 0]
  positionDriver = Pose()
  positionDriver.position.x = 0
  positionDriver.position.y = 0
  positionDriver.position.z = 0
  positionDriver.orientation = 0
示例#7
0
    return True


def home(req):
    global navigateWithWait, Trigger, led, rospy, homeX, homeY, stopVosem
    stopVosem()
    led('red')
    navigateWithWait(x=homeX, y=homeY, z=0.4, yaw=1.5, frame_id='aruco_map')
    time.sleep(5)
    lands = rospy.ServiceProxy('land', Trigger)
    lands()
    led('off')
    return True


rospy.Service('take_off', srv.TakeOff, takeOff)
rospy.Service('home', srv.Home, home)
rospy.Service('detected', srv.Detected, detected)


def loop():
    global rospy
    while not rospy.is_shutdown():
        if (flyVosem):
            t = (time.time() - start) / 10
            x = homeX + cos(t) * 6
            y = homeY + sin(2 * t) * 3
            set_position(x=x, y=y, z=1.5, yaw=1.5, frame_id='aruco_map')
        rospy.spin()

示例#8
0
    global agent_bearing_measurement
    global bearing_measurement_subscribers
    bearing_measurement_subscribers[req.name] = rp.Subscriber(
        name='/' + req.name + '/bearing_measurement',
        data_class=gms.Vector,
        callback=agent_callback,
        callback_args=req.name,
        queue_size=1)
    LOCK.acquire()
    agent_names.append(req.name)
    agent_bearing_measurement[req.name] = None
    LOCK.release()
    return dns.AddAgentResponse()


rp.Service('AddAgent', dns.AddAgent, add_agent_handler)


# Handler for the service "RemoveAgent"
def remove_agent_handler(req):
    global bearing_measurement_subscribers
    global agent_names
    global agent_bearing_measurement
    LOCK.acquire()
    bearing_measurement_subscribers[req.name].unregister()
    agent_names.remove(req.name)
    del agent_bearing_measurement[req.name]
    LOCK.release()
    return dns.RemoveAgentResponse()

def arm_state_server():
    #rospy.init_node(NAME)
    s = rospy.Service('arm_state',arm_state, Arm_state) ##server arm state
    def __init__(self, epochs) :
        rospy.on_shutdown(self._on_node_shutdown)
        self.lnodes = []
        self.map_received =False
        self.range = epochs
        self.srv_lock=Lock()
        name= rospy.get_name()
        action_name = name+'/build_temporal_model'
        
        self.ignore_map_name = rospy.get_param("~ignore_map_name", False)
        
        if self.ignore_map_name:
            rospy.logwarn("Ignoring map name in model creation. All stats will be considered")
            print self.ignore_map_name
        else:
            rospy.logwarn("Using map name in model creation. Only stats for current map will be considered")
            print self.ignore_map_name
       

        # Creating fremen server client
        rospy.loginfo("Creating fremen server client.")
        self.FremenClient= actionlib.SimpleActionClient('fremenserver', fremenserver.msg.FremenAction)
        self.FremenClient.wait_for_server()
        rospy.loginfo(" ...done")


        #Creating Action Server
        rospy.loginfo("Creating action server.")
        self._as = actionlib.SimpleActionServer(action_name, strands_navigation_msgs.msg.BuildTopPredictionAction, execute_cb = self.BuildCallback, auto_start = False)
        self._as.register_preempt_callback(self.preemptCallback)
        rospy.loginfo(" ...starting")
        self._as.start()
        rospy.loginfo(" ...done")


        # Get Topological Map        
        rospy.Subscriber('topological_map', TopologicalMap, self.MapCallback)
        
        rospy.loginfo("Waiting for Topological map ...")
        while not self.map_received:
            rospy.sleep(rospy.Duration(1.0))
            #rospy.loginfo("Waiting for Topological map ...")
        rospy.loginfo("... Got Topological map")


        self.predict_srv=rospy.Service('topological_prediction/predict_edges', strands_navigation_msgs.srv.PredictEdgeState, self.predict_edge_cb)
        self.predict_srv=rospy.Service('topological_prediction/edge_entropies', strands_navigation_msgs.srv.PredictEdgeState, self.edge_entropies_cb)


        rospy.loginfo("Set-Up Fremenserver monitors")
        #Fremen Server Monitor
        self.fremen_monitor = rospy.Timer(rospy.Duration(10), self.monitor_cb)
        # Subscribe to fremen server start topic
        rospy.Subscriber('fremenserver_start', std_msgs.msg.Bool, self.fremen_start_cb)
        rospy.loginfo("... Done")


        rospy.loginfo("Subscribing to new stats ...")
        rospy.Subscriber('topological_navigation/Statistics', NavStatistics, self.stats_callback, queue_size=10)
        
        rospy.loginfo("All Done ...")
        rospy.spin()
示例#11
0
def TagCallback(data):
    """
    Callback for tag 

    :param data:  containing tag object

    """
    global tag
    tag = data


# Initialise node
rospy.init_node('dwm1001_service')
# Subscribe to anchors and tag topic
rospy.Subscriber("/dwm1001/anchor0", Anchor, Anchor0callback)
rospy.Subscriber("/dwm1001/anchor1", Anchor, Anchor1callback)
rospy.Subscriber("/dwm1001/anchor2", Anchor, Anchor2callback)
rospy.Subscriber("/dwm1001/anchor3", Anchor, Anchor3callback)
rospy.Subscriber("/dwm1001/tag", Tag, TagCallback)

# Declare services for tag and anchor
rospy.Service('/Anchor_0', Anchor_0, triggerResponseAnchor0)
rospy.Service('/Anchor_1', Anchor_1, triggerResponseAnchor1)
rospy.Service('/Anchor_2', Anchor_2, triggerResponseAnchor2)
rospy.Service('/Anchor_3', Anchor_3, triggerResponseAnchor3)
rospy.Service('/Tag', Tag_srv, triggerResponseTag)

# Spin ROS so it doesn'y stop
rospy.spin()
示例#12
0
        #if rospy.has_param('/auction_closed'):
        #    rospy.set_param('/auction_closed', False)
    else:
        return {'response_info': 'node already have a role'}


## End handle_auction_config_server_callback

############################################################################
## Main function
############################################################################
if __name__ == "__main__":

    # initialize node (we will have several nodes, anonymous=True)
    rospy.init_node('node', anonymous=True)

    # create the auction_config_server
    service_path = rospy.get_name() + "/auction_config_server"

    auction_config_server = rospy.Service(
        service_path, auction_srvs.srv.AuctionConfigService,
        handle_auction_config_server_callback)

    # ok, ready to participate
    #rospy.loginfo(rospy.get_name()+" is ready to participate in the auction.")

    # Prevent node from exit until shutdown
    rospy.spin()

## End main
示例#13
0
#!/usr/bin/env python
import rospy
from common_msgs.srv import AddTwoNum, AddTwoNumResponse


def service_callback(request):
    response = AddTwoNumResponse(sum=request.a + request.b)
    print "request data:", request.a, request.b, ", response:", response.sum
    return response


rospy.init_node('service_server')
service = rospy.Service('add_two_number', AddTwoNum, service_callback)
rospy.spin()
示例#14
0
def add_two_ints_server():
    rospy.init_node(NAME)
    s = rospy.Service('add_two_ints', AddTwoInts, add_two_ints)

    # spin() keeps Python from exiting until node is shutdown
    rospy.spin()
示例#15
0
    def Mapa_Costos(self):

        rospy.Service('/servicio_mapa_costos', Mapa_Costos, self.handle)
        print("Listo para devolver los datos del mapa de costos")
示例#16
0
def socket_server():
    rospy.init_node(NAME)
    a = rospy.Service('arm_mode', arm_mode, Arm_Mode)  ##server arm mode data
    s = rospy.Service('arm_pos', arm_data, point_data)  ##server arm point data
    print("Ready to connect")
    rospy.spin()  ## spin one
示例#17
0
    def __init__(self):
        self.node_name = "LaneDetectorNode"
        self.robot_name = "ubiquityrobot"
        # Thread lock
        self.thread_lock = threading.Lock()
        # Constructor of line detector
        self.bridge = CvBridge()

        # turn it on when need continuous detection
        self.active = rospy.get_param('~lane_detector', True)
        self.image_transform = rospy.get_param('~image_transformer', True)
        self.stats = Stats()
        # Only be verbose every 10 cycles
        self.intermittent_interval = 100
        self.intermittent_counter = 0
        # color correction
        # self.ai = AntiInstagram()
        # these will be added if it becomes verbose
        self.pub_edge = None
        self.pub_colorSegment = None
        # We use two different detectors (parameters) for lane following and
        # intersection navigation (both located in yaml file)
        self.detector = None
        self.detector_intersection = None
        self.detector_used = self.detector
        self.verbose = None
        self.updateParams(None)
        self.fsm_state = "NORMAL_JOYSTICK_CONTROL"
        self.image_msg = None

        self.pub_lineseglist_ = rospy.Publisher("~lineseglist_out",
                                                SegmentList,
                                                queue_size=1)
        self.gp = GroundProjectionNode()
        self.lane_filter = LaneFilterNode()
        self.cont_anti_instagram_node = ContAntiInstagramNode()
        self.image_transformer_node = ImageTransformerNode()
        # Publishers
        self.pub_lines = rospy.Publisher("~segment_list",
                                         SegmentList,
                                         queue_size=1)
        self.pub_image = rospy.Publisher("~image_with_lines",
                                         Image,
                                         queue_size=1)
        # Subscribers /ubiquityrobot/camera_node/image_raw/compressed

        # self.sub_transform = rospy.Subscriber("~transform", AntiInstagramTransform, self.cbTransform, queue_size=1)
        self.sub_switch = rospy.Subscriber("~switch",
                                           BoolStamped,
                                           self.cbSwitch,
                                           queue_size=1)
        self.sub_fsm = rospy.Subscriber("~fsm_mode",
                                        FSMState,
                                        self.cbFSM,
                                        queue_size=1)

        self.srv_get_lane_pose = rospy.Service('~get_lane_pose', GetLanePose,
                                               self.srvGetLanePose)
        if self.image_transform:
            self.sub_image = rospy.Subscriber("~corrected_image/compressed",
                                              CompressedImage,
                                              self.cbImage,
                                              queue_size=1)
        else:
            self.sub_image = rospy.Subscriber(
                "/ubiquityrobot/camera_node/image_raw/compressed",
                CompressedImage,
                self.cbImage,
                queue_size=1)
        rospy.loginfo("[%s] Initialized (verbose = %s)." %
                      (self.node_name, self.verbose))
        rospy.Timer(rospy.Duration.from_sec(2.0), self.updateParams)
示例#18
0
    parser = argparse.ArgumentParser()
    parser.add_argument("-n",
                        "--node",
                        required=True,
                        help="name of calibration node")
    parser.add_argument("-c",
                        "--num_cameras",
                        type=int,
                        required=True,
                        help="number of cameras")
    args = parser.parse_args()

    all_cameras = ["cam" + str(x) for x in range(args.num_cameras)]
    rospy.init_node('calib_manager')
    print "waiting for calibration service..."
    rospy.wait_for_service(args.node + '/calibration')
    print "waiting for calibration parameter service..."
    rospy.wait_for_service(args.node + '/set_parameter')
    run_calib = rospy.ServiceProxy(args.node + '/calibration',
                                   std_srvs.srv.Trigger)
    set_calib_param = rospy.ServiceProxy(args.node + '/set_parameter',
                                         ParameterCmd)
    print "found calibration services!"

    i = rospy.Service('intrinsic_calibration', Calibrate,
                      intrinsic_calibration)
    e = rospy.Service('extrinsic_calibration', Calibrate,
                      extrinsic_calibration)
    print "calibration manager running ..."
    rospy.spin()
示例#19
0
def add_two_ints_server():
    rospy.init_node('add_two_ints_server')
    s = rospy.Service('add_two_ints', AddTwoInts, handle_add_two_ints)
    print "Ready to add two ints."
    rospy.spin()
示例#20
0
def IK_server():
    # initialize node and declare calculate_ik service
    rospy.init_node('IK_server')
    s = rospy.Service('calculate_ik', CalculateIK, handle_calculate_IK)
    print "Ready to receive an IK request"
    rospy.spin()
示例#21
0
def name_of_week_server():
    rospy.init_node('name_of_week_server')
    s = rospy.Service('name_week', GetNameOfWeek, get_name_of_week_result)
    print("Ready to name day of week.")
    rospy.spin()
示例#22
0
 def __init__(self):
     self.server = rospy.Service('/location_setup', LocationSetup, self.execute)
     self.al = AddLocation()
示例#23
0
    if req.direc == 1:  #forr
        pubbed = True
        target = (yaw + req.yaw) % 360 - offset
        while (yaw - target) % 360 < 350:
            if pubbed == True:
                drive_pub.publish("right")
                # rospy.loginfo("RIGHT:", str(((yaw-target)%360)))
                pubbed = False
        drive_pub.publish("rright")

    if req.direc == 0:
        pubbed = True
        target = (yaw - req.yaw) % 360 + offset
        while (target - yaw) % 360 < 350:
            if pubbed == True:
                drive_pub.publish("left")
                # rospy.loginfo("left:", str(((yaw-target)%360)))
                pubbed = False
        drive_pub.publish("rleft")

    return True


if __name__ == "__main__":
    drive_pub = rospy.Publisher('/simple_ctrl', String, queue_size=1)
    rospy.init_node('angle_server')
    rospy.Subscriber("/yaw", Int16, callyaw)
    s = rospy.Service('angle', angle, handle_angle)
    s1 = rospy.Service('anglediff', angle, handle_diff)
    rospy.spin()
示例#24
0
def init():
    rospy.init_node(srv_name + "_node")
    svr = rospy.Service(srv_name, apc_2016.srv.DepObjSrv, callback)
    rospy.loginfo(srv_name + " running...")
    rospy.spin()
示例#25
0
def pwm_to_norm_server():
	rospy.init_node('pwm_to_norm_server')
	s = rospy.Service('pwm_to_norm', pwm_to_norm, handle_pwm_to_norm)
	rospy.loginfo("Setup pwm to norm server")
	rospy.spin()
示例#26
0
#!/usr/bin/env python
import rospy
from problem_no1.srv import servicedata


def handle(req):
	rospy.loginfo("Request received")
	rospy.loginfo("Entered data:")
	rospy.loginfo(req)
	availibility = False
	xt = target_x
	yt = target_y
	ls = [req.id, availibility, xt, yt]
	return ls

if __name__ == '__main__':
	rospy.init_node("server")
	rospy.loginfo("Server started")
	target_x = input("Enter x: ")
	target_y = input("Enter y: ")
	service = rospy.Service("/data_request", servicedata, handle)	
	rospy.spin()
示例#27
0
 def __init__(self):
     rospy.init_node('strategy_server')
     self._system = strategy()
     s = rospy.Service('strategy_service', strategy_srv, self.callback)
     print "Strategy ready."
     rospy.spin()
def arm_state_server():
    #rospy.init_node(NAME)
    s = rospy.Service('arm_state', arm_state, Arm_state)  ##server arm state
    a = rospy.Service('sent_flag', sent_flag, Sent_flag)
示例#29
0
def max_two_ints_server():
    rospy.init_node('max_two_ints_server')
    m = rospy.Service('max_two_ints', maxTwoInts, handle_max_two_ints)
    print("Ready to comppute max(a,b)")
    rospy.spin()
	def init_services(self):
		self.way_point_service = rospy.Service('way_point', add_way_point, self.way_point_response_func)
		self.way_point_command_service = rospy.Service('way_point_cmd', way_point_cmd, self.way_point_cmd_response_func)