Skip to content

dynamixel

plantimager.dynamixel Link

Implementation of a class dedicated to controlling a Gimbal.

This Gimbal implementation is based on the Dynamixel xl430 SDK wrapping.

Gimbal Link

Gimbal(dev='/dev/ttyUSB1', baud_rate=1000000, pan_id=1, tilt_id=2, pan0=0, tilt0=1024)

Bases: AbstractGimbal

Source code in plantimager/dynamixel.py
43
44
45
46
47
48
49
50
51
52
53
54
def __init__(self, dev: str = "/dev/ttyUSB1", baud_rate: int = 1000000,
             pan_id: int = 1, tilt_id: int = 2, pan0: int = 0, tilt0: int = 1024):
    self.baud_rate = baud_rate
    self.dev = dev
    self.port = xl430.USB2Dynamixel(dev)
    self.port.start(baud_rate)  # Start USB serial connection
    self.pan_zero = pan0
    self.tilt_zero = tilt0
    self.pan_id = pan_id
    self.tilt_id = tilt_id
    self.start()
    atexit.register(self.stop)

moveto Link

moveto(pan, tilt)

Move to given angles (in degrees)

Source code in plantimager/dynamixel.py
90
91
92
93
94
95
def moveto(self, pan: deg, tilt: deg) -> None:
    """
    Move to given angles (in degrees)
    """
    self.moveto_async(pan, tilt)
    self.wait()

moveto_async Link

moveto_async(pan, tilt)

Move to given angles (in degrees)

Source code in plantimager/dynamixel.py
81
82
83
84
85
86
87
88
def moveto_async(self, pan: deg, tilt: deg) -> None:
    """
    Move to given angles (in degrees)
    """
    pan = self.__pan_angle2steps(pan)
    tilt = self.__tilt_angle2steps(tilt)
    self.pan.set_goal_position(pan)
    self.tilt.set_goal_position(tilt)