def __init__(self, target_name, target_addr, port, default_update_rate=50.0): self.update_rate = default_update_rate self.sampling_divisor = int(400 / self.update_rate) self.is_connected = False #self._init_pubsub() self._init_params() #self.robot = sphero_driver.Sphero(target_name, target_addr) if target_name: if target_addr: if port: self.robot = sphero_driver.Sphero(target_name, target_addr, port) else: self.robot = sphero_driver.Sphero(target_name, target_addr) else: self.robot = sphero_driver.Sphero(target_name) else: self.robot = sphero_driver.Sphero() #self.imu = Imu() #self.imu.orientation_covariance = [1e-6, 0, 0, 0, 1e-6, 0, 0, 0, 1e-6] #self.imu.angular_velocity_covariance = [1e-6, 0, 0, 0, 1e-6, 0, 0, 0, 1e-6] #self.imu.linear_acceleration_covariance = [1e-6, 0, 0, 0, 1e-6, 0, 0, 0, 1e-6] #self.last_cmd_vel_time = rospy.Time.now() #self.last_diagnostics_time = rospy.Time.now() self.cmd_heading = 0 self.cmd_speed = 0 self.power_state_msg = "No Battery Info" self.power_state = 0
def __init__(self, default_update_rate=50.0): self.update_rate = default_update_rate self.sampling_divisor = int(400 / self.update_rate) self.is_connected = False self.robot = sphero_driver.Sphero() self.cmd_heading = 0 self.cmd_speed = 0 self.power_state_msg = "No Battery Info" self.power_state = 0 self.collipy = np.matrix([0, 0, 0, 0, 0, 0]) self.t = np.matrix([0])
def __init__(self, default_update_rate=50.0): """ Initialize internal sampling frequency, parameters and subscribers and publishers. """ # Set desired update rate. self.update_rate = default_update_rate self.sampling_divisor = int(400 / self.update_rate) # Get Sphero name and address. self.is_connected = False self.is_enabled = False self._namespace = rospy.get_namespace() self._address = rospy.get_param("~address") self.robot = sphero_driver.Sphero( self._address) # A new instance of Sphero self._init_pubsub() # Create publishers and subscribers. self._init_params() # Initialize parameters.
#!/usr/bin/python import time import sphero_driver import sys sp = sphero_driver.Sphero() sp.connect() #sp.set_raw_data_strm(40, 1 , 0, False) #sp.start() sp.set_rgb_led(255, 0, 0, 0, False) time.sleep(1) sp.set_rgb_led(0, 255, 0, 0, False) time.sleep(1) sp.set_rgb_led(0, 0, 255, 0, False) time.sleep(1) #sp.set_heading(180, False) #time.sleep(3) sp.roll(100, 0, 1, False) time.sleep(1) sp.roll(100, 90, 1, False) time.sleep(1) sp.roll(100, 180, 1, False) time.sleep(1) sp.roll(100, 270, 1, False) time.sleep(1) #sphero.join() #sphero.disconnect() sys.exit(1)
patterns. You can find more infomation using this link: http://zeromq.org ''' import zmq import math import signal import sphero_driver import time import matplotlib.pyplot as plt import numpy as np from sys import stdin, exit sphero = sphero_driver.Sphero(); def signal_handler(signal, frame): print 'Exiting the program right now' sphero.set_back_led(0, False) sphero.disconnect(); exit(0) def det_angle(confidence, norm_pos, con_level, data_range): ''' Determite which angle the user is looking at. By the definition of sphero. 0 degree is going forward. So in y direction it is considered as 0 degree. The minimum is 0 degree. The maximum is 359 degree. '''