Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 13 additions & 16 deletions radio/ateam_radio_bridge/src/radio_bridge_node.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -419,22 +419,19 @@ class RadioBridgeNode : public rclcpp::Node

HelloRequest hello_data = std::get<HelloRequest>(data_variant);

// Commented out until firmware implements git hash populating

// const uint32_t incoming_coms_hash = hello_data.coms_hash[0] | (hello_data.coms_hash[1] << 8) |
// (hello_data.coms_hash[2] << 16) | (hello_data.coms_hash[3] << 24);
// if (incoming_coms_hash != ateam_radio_msgs::kComsHash) {
// RCLCPP_WARN(get_logger(), "Ignoring discovery packet. Packet version hash mismatch.");
// return;
// }

// if (ateam_radio_msgs::kComsDirty) {
// RCLCPP_WARN(get_logger(), "Local packet version is dirty. Compatibility check may be unreliable.");
// }

// if (hello_data.coms_repo_dirty) {
// RCLCPP_WARN(get_logger(), "Remote robot's packet version is dirty. Compatibility check may be unreliable.");
// }
const uint32_t incoming_coms_hash = hello_data.coms_hash[0] << 24 | hello_data.coms_hash[1] << 16 | hello_data.coms_hash[2] << 8 | hello_data.coms_hash[3];
if (incoming_coms_hash != ateam_radio_msgs::kComsHash) {
RCLCPP_WARN(get_logger(), "Ignoring discovery packet. Packet version hash mismatch. Robot: %x Local: %x", incoming_coms_hash, ateam_radio_msgs::kComsHash);
return;
}

if (ateam_radio_msgs::kComsDirty) {
RCLCPP_WARN(get_logger(), "Local packet version is dirty. Compatibility check may be unreliable.");
}

if (hello_data.coms_repo_dirty) {
RCLCPP_WARN(get_logger(), "Remote robot's packet version is dirty. Compatibility check may be unreliable.");
}

if (!(game_controller_listener_.GetTeamColor() == ateam_common::TeamColor::Blue &&
hello_data.color == TC_BLUE) &&
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,7 @@ def test_2_vision_updates(self):
vis_msg.pose.orientation.y = 0.0
vis_msg.pose.orientation.z = 0.707
vis_msg.pose.orientation.w = 0.707
vis_msg.visible = True
self.vis_pub.publish(vis_msg)

timeout = time.time() + 1
Expand All @@ -118,10 +119,12 @@ def test_2_vision_updates(self):
self.vis_pub.publish(vis_msg)
last_packet = self.robot.getLastCmdMessage()
if len(last_packet) != 64:
print(f'unexpected packet length: {len(last_packet)}')
continue
# Extract vision updates
vision_update_flag = struct.unpack("<B", last_packet[8:9])[0]
if vision_update_flag & (1 << 6) == 0:
print(f'vision flag is 0')
continue
vision_x, vision_y, vision_yaw = struct.unpack("<fff", last_packet[12:24])
if (
Expand All @@ -131,6 +134,8 @@ def test_2_vision_updates(self):
):
# Pass the test
return
else:
print(f'Values wrong: x: {vision_x} y: {vision_y} t: {vision_yaw}')

@launch_testing.post_shutdown_test()
class TestProcessExit(unittest.TestCase):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,8 @@ def find_constant_value(symbol_name):

def get_coms_submodule_hash():
"""Get the current commit hash of the software communication submodule."""
return int(find_constant_value("kComsHash"))
hash_raw = int(find_constant_value("kComsHash"))
return int.from_bytes(hash_raw.to_bytes(4, byteorder='little'), byteorder='big')

def get_coms_submodule_dirty():
"""Check if the software communication submodule has uncommitted changes."""
Expand Down
6 changes: 6 additions & 0 deletions radio/ateam_radio_msgs/cmake/generate_conversion_code.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@
# THE SOFTWARE.

function(generate_conversion_code)
message(STATUS "Generating conversion code...")

set(oneValueArgs SOURCE DESTINATION)
set(multiValueArgs STRUCTS)
cmake_parse_arguments(PARSE_ARGV 0 arg "" "${oneValueArgs}" "${multiValueArgs}")
Expand Down Expand Up @@ -53,4 +55,8 @@ function(generate_conversion_code)
if(result)
message(FATAL_ERROR "Failed to generate conversion code: ${error}")
endif()

cmake_path(GET arg_SOURCE PARENT_PATH _header_dir)
file(GLOB _source_files "${_header_dir}/**/*")
set_property(DIRECTORY APPEND PROPERTY CMAKE_CONFIGURE_DEPENDS ${_source_files})
endfunction()
6 changes: 6 additions & 0 deletions radio/ateam_radio_msgs/cmake/generate_msgs.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@
# THE SOFTWARE.

function(generate_msgs)
message(STATUS "Generating ROS message types...")

set(oneValueArgs SOURCE DESTINATION)
set(multiValueArgs STRUCTS)
cmake_parse_arguments(PARSE_ARGV 0 arg "" "${oneValueArgs}" "${multiValueArgs}")
Expand Down Expand Up @@ -50,4 +52,8 @@ function(generate_msgs)
if(result)
message(FATAL_ERROR "Failed to generate messages: ${error}")
endif()

cmake_path(GET arg_SOURCE PARENT_PATH _header_dir)
file(GLOB _source_files "${_header_dir}/**/*")
set_property(DIRECTORY APPEND PROPERTY CMAKE_CONFIGURE_DEPENDS ${_source_files})
endfunction()
5 changes: 5 additions & 0 deletions radio/ateam_radio_msgs/cmake/generate_version_header.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@


function(generate_version_header)
message(STATUS "Generating version header...")

set(SOFT_COMS_SUBMODULE_DIR "${CMAKE_CURRENT_SOURCE_DIR}/software-communication")

find_package(Git REQUIRED)
Expand Down Expand Up @@ -55,4 +57,7 @@ function(generate_version_header)
@ONLY
)

file(GLOB submodule_files "${SOFT_COMS_SUBMODULE_DIR}/**/*")
set_property(DIRECTORY APPEND PROPERTY CMAKE_CONFIGURE_DEPENDS ${submodule_files})

endfunction()
Loading