def __init__(self): self._cmdVel = rospy.Publisher('/cmd_vel', Twist, queue_size=1) self._pubRunData = rospy.Publisher('/run_data', RunData, queue_size=1) self._accel = rospy.get_param("/run_corridor/acceleration", 0.01) self._decel = rospy.get_param("/run_corridor/deceleration", 0.02) self._maxSpeed = rospy.get_param("/run_corridor/max_speed", 0.3) self._minSpeed = rospy.get_param("/run_corridor/min_speed", 0.1) self._servoTarget = rospy.get_param("/run_corridor/servo_target", 14.0) self._servoKp = rospy.get_param("/run_corridor/servo_kp", 8.0) self._servoKd = rospy.get_param("/run_corridor/servo_kd", 0.16) self._servoOffThreshold = rospy.get_param( "/run_corridor/servo_off_threshold", 4.0) self._wallGain = rospy.get_param("/run_corridor/wall_gain", 1.0) self._wallThreshold = rospy.get_param("/run_corridor/wall_threshold", 15.0) self._nearWallThreshold = rospy.get_param( "/run_corridor/near_wall_threshold", 10.0) self._rightThreshold = rospy.get_param("/run_corridor/right_threshold", 21.0) self._leftThreshold = rospy.get_param("/run_corridor/left_threshold", 21.0) self._distanceValues = DistanceValues(LightSensorValues()) self._leftSideBuffer = [0.0, 0.0, 0.0] self._rightSideBuffer = [0.0, 0.0, 0.0] self._bufferIndex = 0 self._leftAverage = 0.0 self._rightAverage = 0.0 rospy.Subscriber('/lightsensors', LightSensorValues, self.Callback)
def __init__(self): self.state = self.State.LINEAR1 self.cmd_vel = rospy.Publisher('/cmd_vel', Twist, queue_size=1) self.sensor_values = LightSensorValues() self.switch_values = SwitchValues() rospy.Subscriber('/lightsensors', LightSensorValues, self.callback) rospy.Subscriber('/switchs', SwitchValues, self.callback2)
def setUp(self): self.count = 0 rospy.Subscriber('/lightsensors', LightSensorValues, self.callback) self.values = LightSensorValues()
def __init__(self): self.cmd_vel = rospy.Publisher('/cmd_vel', Twist, queue_size=1) self.sensor_values = LightSensorValues() rospy.Subscriber('/lightsensors', LightSensorValues, self.callback)
def __init__(self): self.cmd_vel = rospy.Publisher('/cmd_vel', Twist, queue_size=1) self.led_values = LightSensorValues() rospy.Subscriber('/lightsensors', LightSensorValues, self.led_callback) self.range_values = [0] * 726 rospy.Subscriber("scan", LaserScan, self.urg_callback)
def __init__(self): self.data = Twist() self.threshold = 500 self.cmd_vel = rospy.Publisher('/cmd_vel', Twist, queue_size=1) self.sensor_values = LightSensorValues() self.switch_values = SwitchValues() rospy.Subscriber('/lightsensors', LightSensorValues, self.LightSensors) rospy.Subscriber('/switchs', SwitchValues, self.Switchs)
def __init__(self): self.cmd_vel = rospy.Publisher('/cmd_vel', Twist, queue_size=1) self.accel = rospy.get_param("/run_corridor/acceleration") self.max_speed = rospy.get_param("/run_corridor/max_speed") self.min_speed = rospy.get_param("/run_corridor/min_speed") self.servo_target = rospy.get_param("/run_corridor/servo_target") self.servo_kp = rospy.get_param("/run_corridor/servo_kp") self.sensor_values = LightSensorValues() rospy.Subscriber('/lightsensors', LightSensorValues, self.callback)
def __init__(self): self.state = 0 self.sensor_values = LightSensorValues() self.button_status = ButtonValues() self.led = rospy.Publisher('led_values', LedValues, queue_size=1) self.cmd_vel = rospy.Publisher('/cmd_vel', Twist, queue_size=1) rospy.Subscriber('/lightsensors', LightSensorValues, self.callback) rospy.Subscriber('/button_values', ButtonValues, self.callback_button_status)
def __init__(self): self.cmd_vel = rospy.Publisher('/cmd_vel', Twist, queue_size=1) self.goahead_param = 500 self.back_param = 1000 self.sensor_values = LightSensorValues() rospy.Subscriber('/lightsensors', LightSensorValues, self.callback) self.M = 0.10 self.M1 = 0.00 self.e = 0.00 self.e1 = 0.00 self.e2 = 0.00 self.goal = 600 self.Kp = 0.0002 self.Ki = 0.000025 self.Kd = 0.00010
def __init__(self): self.count = 0 self.LAV = 0 self.RAV = 0 self.last_time = rospy.Time.now() self.buzzerCount() print "=======Sensor subscribing=======" self.sub_sensor_bef = rospy.Subscriber('lightsensors', LightSensorValues, self.calc_bef) self.values = LightSensorValues() print "=======motor controling=======" self.rate = rospy.Rate(1) self.sub_cmd_vel_con = rospy.Subscriber('/turtle1/cmd_vel', Twist, self.callback_cmd_vel) self.cmd = Twist() self.pub_cmd_vel_con = rospy.Publisher('/cmd_vel', Twist, queue_size=1) rospy.spin()
return f if __name__=='__main__': devfile = '/dev/rtlightsensor0' rospy.init_node('lightsensors') pub = rospy.Publisher('lightsensors', LightSensorValues, queue_size=1) freq = get_freq() rate = rospy.Rate(freq) while not rospy.is_shutdown(): try: with open(devfile,'r') as f: data = f.readline().split() data = [ int(e) for e in data] d = LightSensorValues() d.right_forward = data[0] d.right_side = data[1] d.left_side = data[2] d.left_forward = data[3] d.sum_all = sum(data) d.sum_forward = data[0] + data[3] pub.publish(d) except IOError: rospy.logerr("cannot write to " + devfile) f = get_freq() if f != freq: freq = f rate = rospy.Rate(freq)
for i in range(2): pub_cal.publish(500) time.sleep(0.5) pub_cal.publish(0) time.sleep(0.5) for i in range(1): pub_cal.publish(500) time.sleep(0.5) pub_cal.publish(0) time.sleep(0.5) for i in range(1): pub_cal.publish(1000) time.sleep(0.5) pub_cal.publish(0) if __name__ == '__main__': rospy.init_node('calibSensors') pub_cal = rospy.Publisher('buzzer', UInt16, queue_size=1) c = CalcAverage() c.buzzerCount() for i in range(1): sub_sensor = rospy.Subscriber('lightsensors', LightSensorValues, c.calc) c.values = LightSensorValues() time.sleep(1)
#freq = 10 #if rospy.has_param('lightsensors_freq'): #freq = rospy.get_param('lightsensors_freq',10) devfile = '/dev/rtlightsensor0' rospy.init_node('lightsensors') pub = rospy.Publisher('lightsensors', LightSensorValues, queue_size=1) freq = get_freq() rate = rospy.Rate(freq) while not rospy.is_shutdown(): try: with open(devfile, 'r') as f: data = f.readline().split() d = LightSensorValues() d.right_forward = int(data[0]) d.right_side = int(data[1]) d.left_side = int(data[2]) d.left_forward = int(data[3]) #d.sum_all = sum(data) d.sum_forward = int(data[0]) + int(data[3]) pub.publish(d) except IOError: rospy.logerr("cannot write to " + devfile) f = get_freq() if f != freq: freq = f rate = rospy.Rate(freq)
def __init__(self): self.alert = rospy.Publisher('/buzzer',UInt16,queue_size=1) self.sensor_values = LightSensorValues() rospy.Subscriber('/lightsensors', LightSensorValues, self.callback)