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
22 changes: 22 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,28 @@ endif()
# Set up project
project("ProjectAirSimLibs")

# Capture build commit hash once during configure. Fallback to "unknown"
# when git is unavailable (or source is not a git checkout).
set(PROJECTAIRSIM_BUILD_COMMIT_HASH "unknown")
find_package(Git QUIET)
if(GIT_FOUND)
execute_process(
COMMAND ${GIT_EXECUTABLE} rev-parse HEAD
WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}
OUTPUT_VARIABLE PROJECTAIRSIM_BUILD_COMMIT_HASH
OUTPUT_STRIP_TRAILING_WHITESPACE
ERROR_QUIET
RESULT_VARIABLE PROJECTAIRSIM_GIT_RESULT
)

if(NOT PROJECTAIRSIM_GIT_RESULT EQUAL 0 OR PROJECTAIRSIM_BUILD_COMMIT_HASH STREQUAL "")
set(PROJECTAIRSIM_BUILD_COMMIT_HASH "unknown")
endif()
endif()
message("PROJECTAIRSIM_BUILD_COMMIT_HASH set to ${PROJECTAIRSIM_BUILD_COMMIT_HASH}")

file(WRITE ${CMAKE_BINARY_DIR}/commit_hash.txt "${PROJECTAIRSIM_BUILD_COMMIT_HASH}\n")

# Set up paths for packaging the sim libs build outputs as custom post-command steps
set(SIMLIBS_PACKAGE_DIR ${CMAKE_SOURCE_DIR}/packages/projectairsim_simlibs)
set(SIMLIBS_SHARED_LIB_DIR ${SIMLIBS_PACKAGE_DIR}/shared_libs)
Expand Down
9 changes: 9 additions & 0 deletions client/python/projectairsim/src/projectairsim/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -163,6 +163,15 @@ def set_interactive_feature(self, feature_name, enabled):
else:
utils.projectairsim_log().info("Successfully set interactive feature.")

def get_build_commit_hash(self) -> str:
"""Gets the commit hash used to build the current sim libs."""
hash_req: Dict = {
"method": "/Sim/GetBuildCommitHash",
"params": {},
"version": 1.0,
}
return self.request(hash_req)

def unsubscribe(self, topics):
"""Unsubscribes from one or more server topics

Expand Down
2 changes: 2 additions & 0 deletions core_sim/src/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,7 @@ endif()
# Set up nng and openssl for linking
target_link_directories(${TARGET_NAME} PRIVATE ${NNG_LIB_DIR})
target_compile_definitions(${TARGET_NAME} PRIVATE NNG_STATIC_LIB=ON)
target_compile_definitions(${TARGET_NAME} PRIVATE PROJECTAIRSIM_BUILD_COMMIT_HASH="${PROJECTAIRSIM_BUILD_COMMIT_HASH}")

target_include_directories(${TARGET_NAME} PRIVATE "${ONNXRUNTIME_ROOTDIR}/include")
target_link_directories(${TARGET_NAME} PRIVATE "${ONNXRUNTIME_ROOTDIR}/lib")
Expand Down Expand Up @@ -163,6 +164,7 @@ add_custom_command(TARGET ${TARGET_NAME}
COMMAND ${CMAKE_COMMAND} -E echo "Packaging [${TARGET_NAME}] build outputs to ${UE_PLUGIN_SIMLIBS_DIR}/${TARGET_NAME}/$<IF:$<CONFIG:Release>,Release,Debug>"
COMMAND ${CMAKE_COMMAND} -E copy_directory $<TARGET_FILE_DIR:${TARGET_NAME}> ${UE_PLUGIN_SIMLIBS_DIR}/${TARGET_NAME}/$<IF:$<CONFIG:Release>,Release,Debug>
COMMAND ${CMAKE_COMMAND} -E copy_directory ${CMAKE_CURRENT_SOURCE_DIR}/../include ${UE_PLUGIN_SIMLIBS_DIR}/${TARGET_NAME}/include
COMMAND ${CMAKE_COMMAND} -E copy_if_different ${CMAKE_BINARY_DIR}/commit_hash.txt ${UE_PLUGIN_SIMLIBS_DIR}/commit_hash.txt
COMMAND ${CMAKE_COMMAND} -E remove_directory ${UE_PLUGIN_SIMLIBS_DIR}/${TARGET_NAME}/$<IF:$<CONFIG:Release>,Release,Debug>/CMakeFiles
COMMAND ${CMAKE_COMMAND} -E remove -f ${UE_PLUGIN_SIMLIBS_DIR}/${TARGET_NAME}/$<IF:$<CONFIG:Release>,Release,Debug>/cmake_install.cmake
COMMAND ${CMAKE_COMMAND} -E remove -f ${UE_PLUGIN_SIMLIBS_DIR}/${TARGET_NAME}/$<IF:$<CONFIG:Release>,Release,Debug>/CTestTestfile.cmake
Expand Down
37 changes: 28 additions & 9 deletions core_sim/src/simulator.cpp
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright (C) Microsoft Corporation.
// Copyright (C) Microsoft Corporation.
// Copyright (C) 2025 IAMAI CONSULTING CORP

// MIT License. All rights reserved.
Expand Down Expand Up @@ -86,6 +86,7 @@ class Simulator::Impl : public ComponentWithTopicsAndServiceMethods {
friend class Simulator::Loader;

bool SetInteractiveFeature(const std::string& feature_id, bool enable);
std::string GetBuildCommitHash();

Simulator::Loader loader_;
Scene sim_scene_;
Expand Down Expand Up @@ -219,14 +220,23 @@ void Simulator::Impl::RegisterServiceMethod(const ServiceMethod& method,
service_manager_.RegisterMethod(unique_method, method_handler);
}

bool Simulator::Impl::SetInteractiveFeature(const std::string& feature_id, bool enable) {
if(feature_id == "viewport_camera"){
bool Simulator::Impl::SetInteractiveFeature(const std::string& feature_id,
bool enable) {
if (feature_id == "viewport_camera") {
sim_scene_.EnableViewportCamera(enable);
return true;
}
return false;
}

std::string Simulator::Impl::GetBuildCommitHash() {
#ifdef PROJECTAIRSIM_BUILD_COMMIT_HASH
return PROJECTAIRSIM_BUILD_COMMIT_HASH;
#else
return "unknown";
#endif
}

void Simulator::Impl::RegisterServiceMethods() {
auto unsubscribe_topic = ServiceMethod("Unsubscribe", {"topic_paths"});
auto unsubscribe_topic_handler = unsubscribe_topic.CreateMethodHandler(
Expand All @@ -238,13 +248,22 @@ void Simulator::Impl::RegisterServiceMethods() {
[this](const ServiceMethod& method, MethodHandler method_handler) {
RegisterServiceMethod(method, method_handler);
});

// Register service method SetInteractiveFeature( feature_id(str), enable(bool))
auto set_interactive_feature = ServiceMethod("SetInteractiveFeature", {"feature_id", "enable"});
auto set_interactive_feature_handler = set_interactive_feature.CreateMethodHandler(
&Simulator::Impl::SetInteractiveFeature, *this);
RegisterServiceMethod(set_interactive_feature, set_interactive_feature_handler);

// Register service method SetInteractiveFeature( feature_id(str),
// enable(bool))
auto set_interactive_feature =
ServiceMethod("SetInteractiveFeature", {"feature_id", "enable"});
auto set_interactive_feature_handler =
set_interactive_feature.CreateMethodHandler(
&Simulator::Impl::SetInteractiveFeature, *this);
RegisterServiceMethod(set_interactive_feature,
set_interactive_feature_handler);

auto get_build_commit_hash = ServiceMethod("GetBuildCommitHash", {});
auto get_build_commit_hash_handler =
get_build_commit_hash.CreateMethodHandler(
&Simulator::Impl::GetBuildCommitHash, *this);
RegisterServiceMethod(get_build_commit_hash, get_build_commit_hash_handler);
}

// -----------------------------------------------------------------------------
Expand Down
Loading