EasyManua.ls Logo

WR BEAR - Page 24

WR BEAR
37 pages
Print Icon
To Next Page IconTo Next Page
To Next Page IconTo Next Page
To Previous Page IconTo Previous Page
To Previous Page IconTo Previous Page
Loading...
Example:
# Create a serial port object
# A typical port will be /dev/ttyUSB*
# The default (and fastest) baud rate is 8000000 bps
bear = Manager.BEAR(port='/dev/ttyUSB0', baudrate=8000000)
To disconnect from BEAR(clear existing PyBEAR instance), simply call the close() function:
bear.close()
1) Ping BEAR The ping function can be used to detect if one or multiple BEARs are online, or
to read their error codes. It will return firmware and hardware version information along with
error code if successfully pinged, or ‘None’ for the specific BEAR(s).
Example:
# Ping BEAR with ID 1
rtn = bear.ping(1)[0]
if bool(rtn):
pass
else:
print("BEAR 1 not detected.")
2) Read from BEAR The value of configure and status registers of BEAR can be read by calling
get functions.
a) Read from a single register
The functions have a format of:
get_name-of-register(motor_id)
Register value of multiple BEAR actuators can be read at one time, and the function return
format is:
[([data_of_motor1], error_code_of_motor1),
([data_of_motor2], error_code_of_motor2) ...]
Example:
# Read torque_enable status from BEAR 1, 2, 3
bear.get_torque_enable(1,2,3)
# Read p_gain_position from BEAR 1, 4
bear.get_p_gain_position(1,4)
# Read present_velocity from BEAR 2, 3
bear.get_present_velocity(2,3)
If bad connection happens and nothing is heard from the BEAR actuator(s) or the return
packets are damaged, PyBEAR automatically retries the read function, and a warning is
generated:
24