blgimbal
plantimager.blgimbal Link
Implementation of a class dedicated to controlling a gimbal.
This gimbal implementation is based on a custom-built controller. The gimbal is used to orient a camera by controlling pan & tilt orientations. The control is done by a serial port that has to be defined.
Note that this module offer the ability to use one or two motors. With one, you control the pan orientation, this is like turning your head left or right. With two, you can also control the tilt, this is like looking up or down. In conjunction with a 3-axis CNC, that gives a total of 5 degrees of freedom and thus the ability to scan the whole volume around the plant.
Gimbal Link
Gimbal(port='/dev/ttyUSB0', baudrate=115200, has_tilt=True, steps_per_turn=360, zero_pan=0, zero_tilt=0, invert_rotation=False)
Bases: AbstractGimbal
Custom-built gimbal controller based on Feather M0 and a .
Attributes:
Name | Type | Description |
---|---|---|
port |
str
|
Serial port to use for communication with the Gimbal controller (Feather M0). |
baudrate |
(int, optional)
|
Communication baud rate, |
status |
str
|
Describe the gimbal current status, "idle" or "moving". |
p |
[float, float]
|
Current pan and tilt positions. |
serial_port |
Serial
|
The |
zero_pan |
float
|
The angle, in degree, to use as zero for pan. |
zero_tilt |
float
|
The angle, in degree, to use as zero for tilt. |
has_tilt |
bool
|
Indicate if the gimbal has a tilt motor or just a pan motor. |
steps_per_turn |
int
|
Number of steps required to complete a full rotation. |
invert_rotation |
bool
|
Use it to invert the rotation of the motor. |
See Also
plantimager.hal.AbstractGimbal
Examples:
>>> from plantimager.blgimbal import Gimbal
>>> g = Gimbal("Feather M0", has_tilt=False, invert_rotation=True)
>>> g.status
Constructor.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
port
|
str
|
Serial port to use for communication with the Gimbal controller.
This can also be a regular expression to identify in a unique way the corresponding port.
Defaults to |
'/dev/ttyUSB0'
|
baudrate
|
int
|
Communication baud rate, |
115200
|
has_tilt
|
bool
|
Indicate if the Gimbal has a tilt motor.
Defaults to |
True
|
steps_per_turn
|
int
|
Indicate the number of steps to perform for a full revolution (360°).
Defaults to |
360
|
zero_pan
|
float
|
Indicate the origin position of the Gimbal for the pan-axis.
Defaults to |
0
|
zero_tilt
|
float
|
Indicate the origin position of the Gimbal for the tilt-axis.
Defaults to |
0
|
invert_rotation
|
bool
|
Indicate if rotation direction should be inverted.
Defaults to |
False
|
Source code in plantimager/blgimbal.py
88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 |
|
__send Link
__send(s)
Send a command trough the serial port.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
s
|
str
|
The command to send to the custom board controlling the Gimbal. |
required |
Source code in plantimager/blgimbal.py
217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 |
|
get_position Link
get_position()
Returns the pan & tilt positions of the Gimbal.
Source code in plantimager/blgimbal.py
150 151 152 153 |
|
get_status Link
get_status()
Returns the status of the custom board controlling the Gimbal.
Source code in plantimager/blgimbal.py
155 156 157 158 |
|
moveto Link
moveto(pan, tilt)
Move to a target position for pan & tilt.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
pan
|
float
|
The desired |
required |
tilt
|
float
|
The desired |
required |
Source code in plantimager/blgimbal.py
180 181 182 183 184 185 186 187 188 189 190 191 192 |
|
moveto_async Link
moveto_async(pan, tilt)
Asynchronous move to a target position for pan & tilt.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
pan
|
float
|
The desired |
required |
tilt
|
float
|
The desired |
required |
Source code in plantimager/blgimbal.py
194 195 196 197 198 199 200 201 202 203 204 205 |
|
set_target_pos Link
set_target_pos(pan, tilt)
Set a target position for pan & tilt.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
pan
|
float
|
The desired |
required |
tilt
|
float
|
The desired |
required |
Source code in plantimager/blgimbal.py
160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 |
|
start Link
start()
Start the serial connection with the custom board controlling the Gimbal.
Source code in plantimager/blgimbal.py
131 132 133 134 135 |
|
stop Link
stop()
Stop the serial connection with the custom board controlling the Gimbal.
Source code in plantimager/blgimbal.py
137 138 139 140 141 142 |
|
update_status Link
update_status()
Update the pan & tilt positions.
Source code in plantimager/blgimbal.py
207 208 209 210 211 212 213 214 215 |
|