コード例 #1
0
ファイル: specificworker.py プロジェクト: ibarbech/hexapod
	def __init__(self, proxy_map):
		super(SpecificWorker, self).__init__(proxy_map)
		self.mutmState=mutex()
		self.busParams=BusParams()
		self.motores={}
		self.SDK=False
		self.lisPos=collections.deque()
		self.lisVel=collections.deque()
		self.mstateMap ={}

		self.setParams()
#		try:
		self.ser = dynamixel.get_serial_for_url(self.busParams.device,self.busParams.baudRate)
		for m in self.motores:
			dynamixel.init(self.ser,m.busId)
#		except Exception as e:
#			print('Unable to move to desired position.')
 #       	print e
		self.timer.timeout.connect(self.compute)
		self.Period = 100
		self.timer.start(self.Period)
コード例 #2
0
from pydynamixel import dynamixel

# You'll need to change this to the serial port of your USB2Dynamixel
serial_port = '/dev/ttyUSB0'

# You'll need to modify these for your setup
servo_id = 1
target_position = 768  # (range: 0 to 1023)

# If this is the first time the robot was powered on,
# you'll need to read and set the current position.
# (See the documentation above.)
first_move = True

try:
    ser = dynamixel.get_serial_for_url(serial_port)

    if first_move == True:
        dynamixel.init(ser, servo_id)

    dynamixel.set_position(ser, servo_id, target_position)
    dynamixel.send_action_packet(ser)

    print('Success!')

except Exception as e:
    print('Unable to move to desired position.')
    print(e)
コード例 #3
0
from pydynamixel import dynamixel

# You'll need to change this to the serial port of your USB2Dynamixel
serial_port = "/dev/ttyUSB0"

# You'll need to modify these for your setup
target_position = 512  # (range: 0 to 1023)

# If this is the first time the robot was powered on,
# you'll need to read and set the current position.
# (See the documentation above.)
first_move = True

ser = dynamixel.get_serial_for_url(serial_port, baudrate=1000000)

for i in range(1, 19):
    dynamixel.init(ser, i)

for i in range(1, 19):
    try:
        p = dynamixel.get_position(ser, i, num_error_attempts=10)
        print "motor", i, "pos", p
        dynamixel.set_position(ser, i, 512)
        dynamixel.send_action_packet(ser)
        # print('Success!')

    except Exception as e:
        # print('Unable to move to desired position.')
        # print(e)
        pass
コード例 #4
0
target_position = 0
velocity = 20 # very slow

# If this is the first time the robot was powered on, we need to read 
# and set the current position.
# (See the documentation above.)
first_move = True

try:
    ser = dynamixel.get_serial_for_url(serial_port)
    
    # Turn the LED off
    dynamixel.set_led(ser, servo_id, registers.LED_STATE.OFF)
    
    if first_move == True:
        dynamixel.init(ser, servo_id)
    
    # Set the desired position
    dynamixel.set_position(ser, servo_id, target_position)
    
    # Set the velocity
    dynamixel.set_velocity(ser, servo_id, velocity)
    
    # Move to the desired position
    dynamixel.send_action_packet(ser)
    
    # Wait for the arm to stop moving
    print('Waiting...')
    
    # Loop until the robot is done moving.
    while True:
コード例 #5
0
ファイル: dynamixel.py プロジェクト: daviesian/charles
def init_dynamixel_servo(id):
    try:
        dyn_raw.init(dyn_serial, id, False, 1)
    except dyn_raw.DynamixelException as e:
        print(e)