-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Loading status checks…
reorganized files
- Loading branch information
Showing
11 changed files
with
74 additions
and
25 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Empty file.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,15 +1,25 @@ | ||
# This test aims to check the byte split function which splits a given 2-byte (16-bit) value into 2 separate bytes (8 bits each). | ||
import numpy as np | ||
|
||
for i in range(8): | ||
number = int(65535/7 * i) | ||
print("Number in hexadecimal: ", format(number, 'x')) | ||
print("Number in binary: ", format(number, 'b')) | ||
index = 0 | ||
byte_list = [0,0] | ||
byte_list[index] = number & 0xFF # Low byte | ||
byte_list[index + 1] = (number >> 8) & 0xFF # High byte | ||
def split_2_bytes(byte_list, number, index): | ||
"""Sets a 2-byte number in a list of bytes. | ||
Args: | ||
byte_list (list): The list of bytes. | ||
number (int): The 2-byte number to set. | ||
index (int): The starting index in the list to set the number. | ||
""" | ||
if number < 0 or number > 65535: | ||
raise ValueError("Number must be between 0 and 65535") | ||
byte_list[index] = number & 0xFF # Low byte | ||
byte_list[index + 1] = (number >> 8) & 0xFF # High byte | ||
print("High byte: ", "{0:b}".format(byte_list[1]), "{0:x}".format(byte_list[1])) | ||
print("Low byte: " , "{0:b}".format(byte_list[0]), "{0:x}".format(byte_list[0])) | ||
|
||
print() | ||
for i in range(8): | ||
number = np.uint16(65535/7 * i) | ||
print("Number in hexadecimal: ", format(number, 'x')) | ||
print("Number in binary: " , format(number, 'b')) | ||
index = 0 | ||
byte_list = [0,0] | ||
split_2_bytes(byte_list, number, index) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
import numpy as np | ||
|
||
lin_vel_step_size = 1/128 | ||
lin_vel_min = -250 # km/hr | ||
lin_vel_eff_max = 40 # km/h | ||
|
||
ang_vel_step_size = 1/1024 | ||
ang_vel_min = -31.25 # rad/s | ||
ang_vel_eff_max = 31.25 # rad/s | ||
|
||
lin_percent_range = 100.0 | ||
ang_percent_range = 200.0 | ||
ang_percent_offset = 100.0 | ||
|
||
lin_offset = abs(lin_vel_min / lin_vel_step_size) | ||
lin_spd_range = lin_vel_eff_max / lin_vel_step_size | ||
|
||
ang_offset = abs(ang_vel_min / ang_vel_step_size) | ||
ang_spd_range = (ang_vel_eff_max - ang_vel_min) / ang_vel_step_size | ||
|
||
throttle_cmd_new = [] | ||
steering_cmd_new = [] | ||
|
||
for i in range(21): | ||
throttle_percentage = 100/20 * i | ||
steering_percentage = 200/20 * i - 100 | ||
|
||
gear = i%3 | ||
|
||
if gear == 1: | ||
# print('gear: forward') | ||
throttle_cmd = np.uint16(lin_spd_range * throttle_percentage / lin_percent_range + lin_offset) | ||
throttle_cmd_new.append(throttle_cmd) | ||
elif gear == 2: | ||
# print('gear: backward') | ||
throttle_cmd = np.uint16(lin_spd_range * -throttle_percentage / lin_percent_range + lin_offset) | ||
throttle_cmd_new.append(throttle_cmd) | ||
else: | ||
# print('gear: neutral') | ||
throttle_cmd = np.uint16(lin_offset) | ||
throttle_cmd_new.append(throttle_cmd) | ||
|
||
steering_cmd = np.uint16(ang_spd_range * (steering_percentage + ang_percent_offset) / ang_percent_range) | ||
steering_cmd_new.append(steering_cmd) | ||
|
||
print(throttle_cmd_new) | ||
print(steering_cmd_new) |