Skip to content

Commit

Permalink
Fix git conflicts
Browse files Browse the repository at this point in the history
  • Loading branch information
MaximilienNaveau committed Oct 11, 2023
1 parent 61bfc9a commit 1518022
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 21 deletions.
22 changes: 12 additions & 10 deletions sdk/master_board_sdk/example/com_analyser.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,11 @@
import time
import subprocess
try:
from time import process_time
from time import perf_counter
except(ImportError):
from time import clock as process_time
# You are still in python2… pleas upgrade :)
from time import clock as perf_counter


import libmaster_board_sdk_pywrap as mbs
import matplotlib.pyplot as plt
Expand Down Expand Up @@ -72,12 +74,12 @@ def example_script(name_interface):
robot_if.GetDriver(i).SetTimeout(5)
robot_if.GetDriver(i).Enable()

last = process_time()
last = perf_counter()
prev_time = 0

while (not robot_if.IsTimeout() and not robot_if.IsAckMsgReceived()):
if ((process_time() - last) > dt):
last = process_time()
if ((perf_counter() - last) > dt):
last = perf_counter()
robot_if.SendInit()

if robot_if.IsTimeout():
Expand All @@ -97,17 +99,17 @@ def example_script(name_interface):
last_cmd_packet_index = first_cmd_index

while ((not robot_if.IsTimeout())
and (process_time() < duration)): # Stop after 15 seconds (around 5 seconds are used at the start for calibration)
and (perf_counter() < duration)): # Stop after 15 seconds (around 5 seconds are used at the start for calibration)

if (robot_if.GetLastRecvCmdIndex() > robot_if.GetCmdPacketIndex()):
last_recv_cmd_index = (overflow_cmd_cpt-1) * 65536 + robot_if.GetLastRecvCmdIndex()
else:
last_recv_cmd_index = overflow_cmd_cpt * 65536 + robot_if.GetLastRecvCmdIndex()

if (last_recv_cmd_index >= first_cmd_index and received_list[last_recv_cmd_index-first_cmd_index] == 0):
received_list[last_recv_cmd_index-first_cmd_index] = process_time()
received_list[last_recv_cmd_index-first_cmd_index] = perf_counter()

if ((process_time() - last) > dt):
if ((perf_counter() - last) > dt):
last += dt
cpt += 1

Expand Down Expand Up @@ -144,9 +146,9 @@ def example_script(name_interface):
sensor_lost_list.append(robot_if.GetSensorsLost())
cmd_ratio_list.append(100.*robot_if.GetCmdLost()/robot_if.GetCmdSent())
sensor_ratio_list.append(100.*robot_if.GetSensorsLost()/robot_if.GetSensorsSent())
time_list.append(process_time())
time_list.append(perf_counter())

current_time = process_time()
current_time = perf_counter()

diff = robot_if.GetCmdPacketIndex() - last_cmd_packet_index
if diff < 0:
Expand Down
15 changes: 10 additions & 5 deletions sdk/master_board_sdk/example/example.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,11 @@
import math
import os
import sys
from time import perf_counter
try:
from time import perf_counter
except ImportError:
# You are still in python2… pleas upgrade :)
from time import clock as perf_counter

import libmaster_board_sdk_pywrap as mbs

Expand Down Expand Up @@ -53,9 +57,8 @@ def example_script(name_interface):
robot_if.GetDriver(i).SetTimeout(5)
robot_if.GetDriver(i).Enable()

start = perf_counter()
last = start

last = perf_counter()
print("last =",last)
while (not robot_if.IsTimeout() and not robot_if.IsAckMsgReceived()):
if ((perf_counter() - last) > dt):
last = perf_counter()
Expand All @@ -71,10 +74,11 @@ def example_script(name_interface):
# if slave i is connected then motors 2i and 2i+1 are potentially connected
motors_spi_connected_indexes.append(2 * i)
motors_spi_connected_indexes.append(2 * i + 1)
glob_last = perf_counter()

# Stop after 15 seconds (around 5 seconds are used at the start for calibration)
while ((not robot_if.IsTimeout())
and (perf_counter() - start < 20)):
and ( (perf_counter() - glob_last) < 20)): # Stop after 15 seconds (around 5 seconds are used at the start for calibration)

if ((perf_counter() - last) > dt):
last = perf_counter()
Expand Down Expand Up @@ -102,6 +106,7 @@ def example_script(name_interface):
continue #user should decide what to do in that case, here we ignore that motor

if robot_if.GetMotor(i).IsEnabled():
print("sending ",i," motor settings.")
ref = init_pos[i] + amplitude * math.sin(2.0 * math.pi * freq * t) # Sine wave pattern
v_ref = 2.0 * math.pi * freq * amplitude * math.cos(2.0 * math.pi * freq * t)
p_err = ref - robot_if.GetMotor(i).GetPosition() # Position error
Expand Down
13 changes: 7 additions & 6 deletions sdk/master_board_sdk/example/listener.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,10 @@
import os
import sys
try:
from time import process_time
except(ImportError):
from time import clock as process_time
from time import perf_counter
except ImportError:
# You are still in python2… pleas upgrade :)
from time import clock as perf_counter

import libmaster_board_sdk_pywrap as mbs

Expand All @@ -24,12 +25,12 @@ def listener_script(name_interface):
robot_if = mbs.MasterBoardInterface(name_interface, True)
robot_if.Init() # Initialization of the interface between the computer and the master board

last = process_time()
last = perf_counter()

while (True):

if ((process_time() - last) > dt):
last = process_time()
if ((perf_counter() - last) > dt):
last = perf_counter()
cpt += 1
t += dt
robot_if.ParseSensorData() # Read sensor data sent by the masterboard
Expand Down

0 comments on commit 1518022

Please sign in to comment.