mirror of
https://github.com/apirrone/Open_Duck_Mini_Runtime.git
synced 2025-09-02 19:23:54 +00:00
test
This commit is contained in:
parent
6b6da795f9
commit
819a87f7b4
1 changed files with 12 additions and 10 deletions
|
@ -14,6 +14,7 @@ parser.add_argument(
|
||||||
args = parser.parse_args()
|
args = parser.parse_args()
|
||||||
io = FeetechSTS3215IO("/dev/ttyACM0")
|
io = FeetechSTS3215IO("/dev/ttyACM0")
|
||||||
|
|
||||||
|
|
||||||
def convert_load(raw_load):
|
def convert_load(raw_load):
|
||||||
sign = -1
|
sign = -1
|
||||||
if raw_load > 1023:
|
if raw_load > 1023:
|
||||||
|
@ -22,19 +23,19 @@ def convert_load(raw_load):
|
||||||
return sign * raw_load * 0.001
|
return sign * raw_load * 0.001
|
||||||
|
|
||||||
|
|
||||||
id = 1
|
id = 1 if args.new_firmware else 11
|
||||||
kp = 16
|
kp = 32
|
||||||
kd = 0
|
kd = 0
|
||||||
acceleration = 0
|
acceleration = 0
|
||||||
maximum_acceleration = 0
|
maximum_acceleration = 0
|
||||||
maximum_velocity = 0
|
maximum_velocity = 0
|
||||||
|
goal_speed = 0
|
||||||
|
|
||||||
io.set_mode({id: 0})
|
|
||||||
io.set_lock({id: 1})
|
|
||||||
time.sleep(1)
|
time.sleep(1)
|
||||||
io.set_maximum_acceleration({id: maximum_acceleration})
|
io.set_maximum_acceleration({id: maximum_acceleration})
|
||||||
io.set_acceleration({id: acceleration})
|
io.set_acceleration({id: acceleration})
|
||||||
io.set_maximum_velocity({id: maximum_velocity})
|
io.set_maximum_velocity({id: maximum_velocity})
|
||||||
|
io.set_goal_speed({id: goal_speed})
|
||||||
io.set_P_coefficient({id: kp})
|
io.set_P_coefficient({id: kp})
|
||||||
io.set_D_coefficient({id: kd})
|
io.set_D_coefficient({id: kd})
|
||||||
time.sleep(1)
|
time.sleep(1)
|
||||||
|
@ -44,6 +45,7 @@ goal_position = 90
|
||||||
io.set_goal_position({id: 0})
|
io.set_goal_position({id: 0})
|
||||||
time.sleep(3)
|
time.sleep(3)
|
||||||
|
|
||||||
|
exit()
|
||||||
|
|
||||||
times = []
|
times = []
|
||||||
positions = []
|
positions = []
|
||||||
|
@ -52,18 +54,18 @@ speeds = []
|
||||||
loads = []
|
loads = []
|
||||||
currents = []
|
currents = []
|
||||||
|
|
||||||
io.set_goal_position({1: goal_position})
|
io.set_goal_position({id: goal_position})
|
||||||
|
|
||||||
s = time.time()
|
s = time.time()
|
||||||
set = False
|
set = False
|
||||||
while True:
|
while True:
|
||||||
t = time.time() - s
|
t = time.time() - s
|
||||||
# goal_position = np.rad2deg(np.sin(t**2))
|
# goal_position = np.rad2deg(np.sin(t**2))
|
||||||
io.set_goal_position({1: goal_position})
|
io.set_goal_position({id: goal_position})
|
||||||
present_position = np.deg2rad(io.get_present_position([1])[0])
|
present_position = np.deg2rad(io.get_present_position([id])[0])
|
||||||
present_speed = np.deg2rad(io.get_present_speed([1])[0])
|
present_speed = np.deg2rad(io.get_present_speed([id])[0])
|
||||||
present_load = convert_load(io.get_present_load([1])[0])
|
present_load = convert_load(io.get_present_load([id])[0])
|
||||||
present_current = io.get_present_current([1])[0]
|
present_current = io.get_present_current([id])[0]
|
||||||
|
|
||||||
times.append(t)
|
times.append(t)
|
||||||
positions.append(present_position)
|
positions.append(present_position)
|
||||||
|
|
Loading…
Reference in a new issue