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
1 change: 0 additions & 1 deletion .github/workflows/build_windows.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
name: hutb Windows CI/CD

on:
push:
pull_request:


Expand Down
69 changes: 64 additions & 5 deletions Examples/CppClient/basic_usage.cpp
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
// 参考:https://zhuanlan.zhihu.com/p/663460928
#include <random>
#include <sstream>
#include <string>
#include <thread>
#include <tuple>

// 注意:hutb\Unreal\CarlaUE4\Plugins\Carla\CarlaDependencies\include\carla 不存在 carla/client 目录
#include <carla/client/ActorBlueprint.h>
#include <carla/client/BlueprintLibrary.h>
#include <carla/actors/ActorBlueprint.h>
#include <carla/actors/BlueprintLibrary.h>
#include <carla/client/Client.h>
#include <carla/client/Sensor.h>
#include <carla/client/TimeoutException.h>
Expand All @@ -24,6 +25,35 @@ static auto ParseArguments(int argc, const char* argv[])
return argc == 3u ? ResultType{ argv[1u], std::stoi(argv[2u]) } : ResultType{ "localhost", 2000u };
}


// 随机选取
template <typename RangeT, typename RNG>
static auto& RandomChoice(const RangeT& range, RNG&& generator)
{
std::uniform_int_distribution<size_t> dist{ 0u, range.size() - 1u };
return range[dist(std::forward<RNG>(generator))];
}

// 一个创建汽车的函数,方便循环使用
SharedPtr<client::Vehicle> SetVehicle(geom::Transform transform, client::World world)
{
std::mt19937_64 rng((std::random_device())());

// Get a random vehicle blueprint.
SharedPtr<actors::BlueprintLibrary> blueprint_library = world.GetBlueprintLibrary();
auto vehicles = blueprint_library->Filter("vehicle");
// 在容器中随机选取车型
actors::BlueprintLibrary vehicle_bp = RandomChoice(*vehicles, rng);

SharedPtr<client::Actor> actor = world.SpawnActor(vehicle_bp, transform);
SharedPtr<client::Vehicle> vehicle = boost::static_pointer_cast<client::Vehicle>(actor);
// 将汽车全部设置为自动驾驶模式
vehicle->SetAutopilot(true);
return vehicle;
}



int main(int argc, const char* argv[])
{
try
Expand All @@ -48,7 +78,9 @@ int main(int argc, const char* argv[])
// 获取推荐的车辆其实位置
std::vector<geom::Transform> spawn_point = map->GetRecommendedSpawnPoints();

// 构建汽车对象

// ********************************************************************************************
// 构建汽车对象********************************************************************************
// 获取这张地图中所有实物的蓝图
SharedPtr<actors::BlueprintLibrary> blueprint_library = world.GetBlueprintLibrary();
// 获取汽车的蓝图并指定其颜色
Expand All @@ -68,7 +100,6 @@ int main(int argc, const char* argv[])
view_transform.rotation.pitch = -15.0f;
spectator->SetTransform(view_transform);


// 参考:https://zhuanlan.zhihu.com/p/663726656
// 踩油门
// client::Vehicle::Control control;
Expand All @@ -77,6 +108,7 @@ int main(int argc, const char* argv[])
// {
// vehicle->ApplyControl(control);
// }

// 除了油门,还可以控制刹车、方向盘、传动比、手刹等
// control.brake = 0.1;
// control.steer = 0.02;
Expand All @@ -86,7 +118,34 @@ int main(int argc, const char* argv[])
// 速度加速度:AckermanControl

// 自动驾驶
vehicle->SetAutopilot(true);
// vehicle->SetAutopilot(true);
// std:cout << "Autopilot enabled" << std::endl;
// ********************************************************************************************



// ********************************************************************************************
// 添加行人************************************************************************************
actors::ActorBlueprint walker_bp = *blueprint_library->Find("walker.pedestrian.0037");
SharedPtr<client::Actor> walker_actor = world.SpawnActor(walker_bp, recommend_points[200]);
SharedPtr<client::Walker> walker = boost::static_pointer_cast<client::Walker>(walker_actor);
// 切换视角查看生成的行人
view_transform = recommend_points[200];
spectator = world.GetSpectator();
view_transform.location -= 5.0f * view_transform.GetForwardVector();
view_transform.location.z += 3.0f;
view_transform.rotation.yaw += 0.0f;
view_transform.rotation.pitch = -15.0f;
spectator->SetTransform(view_transform);
// 让行人动起来
client::Walker::Control walker_control;
walker_control.speed = 0.2;
walker_control.jump = false; // 爬坡的时候使用
walker_control.direction = { recommend_points[201].location.x,recommend_points[200].location.y,0.0 };
walker->ApplyControl(walker_control);
// ********************************************************************************************




}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@ void TrafficManagerLocal::SetupLocalMap() {
local_map->SetUp();
}
} else {
log_warning("No InMemoryMap cache found. Setting up local map. This may take a while...");
log_warning("No InMemoryMap cache found (TM). Setting up local map. This may take a while...");
local_map->SetUp();
}
}
Expand Down
1 change: 1 addition & 0 deletions Unreal/CarlaUE4/Plugins/Carla/Source/Carla/Carla.Build.cs
Original file line number Diff line number Diff line change
Expand Up @@ -223,6 +223,7 @@ private void AddCarlaServerDependency(ReadOnlyTargetRules Target)
PublicAdditionalLibraries.Add(Path.Combine(LibCarlaInstallPath, "lib", "proj.lib"));
PublicAdditionalLibraries.Add(Path.Combine(LibCarlaInstallPath, "lib", "osm2odr.lib"));
PublicAdditionalLibraries.Add(Path.Combine(LibCarlaInstallPath, "lib", "zlibstatic.lib"));

}
else
{
Expand Down
7 changes: 7 additions & 0 deletions Util/BuildTools/Package.bat
Original file line number Diff line number Diff line change
Expand Up @@ -298,6 +298,13 @@ if %DO_COPY_FILES%==true (
"%ProgramW6432%/7-Zip/7z.exe" x "!SUMO_TEMP_FILE_DIR!" -o"!XCOPY_FROM!Build\dependencies\Plugins\" -y
echo d | xcopy /y /s "!XCOPY_FROM!Build\dependencies\Plugins\sumo" "!XCOPY_TO!sumo"
)

:: copy DirectX Runtime dll to package
set DirectX_TEMP_FILE_DIR="!XCOPY_FROM!Build\dependencies\prerequisites\DirectX_Runtime"
if exist "!DirectX_TEMP_FILE_DIR!" (
:: 鎷疯礉DirectX Runtime涓墍鏈夌殑dll鏂囦欢鍒拌繍琛宔xe鎵�闇�鐨刣ll鐩綍涓�
echo d | xcopy /y /s "!XCOPY_FROM!Build\dependencies\prerequisites\DirectX_Runtime\*.dll" "!XCOPY_TO!CarlaUE4\Binaries\Win64"
)
)
call :get_current_time_in_seconds T_END_DO_COPY_FILES
set /A ELAPSED_TIME=!T_END_DO_COPY_FILES! - !T_START_DO_COPY_FILES!
Expand Down
13 changes: 9 additions & 4 deletions Util/InstallersWin/install_recast.bat
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ rem ============================================================================
set DEL_SRC=false
:: --build-debug true|false
:: Build the Debug version of Recast & Detour to debug LibCarla client
set BUILD_DEBUG=false
set IS_DEBUG=false

:arg-parse
if not "%1"=="" (
Expand All @@ -34,7 +34,7 @@ if not "%1"=="" (
shift
)
if "%1"=="--build-debug" (
set BUILD_DEBUG=true
set IS_DEBUG=true
shift
)
shift
Expand All @@ -59,7 +59,12 @@ set RECAST_BUILD_DIR=%RECAST_SRC_DIR%build\
set RECAST_BASENAME=%RECAST_SRC%

if exist "%RECAST_INSTALL_DIR%" (
goto already_build
if %IS_DEBUG% == true (
echo %FILE_N% A "Recast & Detour" installation already exists. Rebuild it.
) else (
echo %FILE_N% A "Recast & Detour" Release installation already exists.
goto already_build
)
)

if not exist "%RECAST_SRC_DIR%" (
Expand Down Expand Up @@ -88,7 +93,7 @@ echo.%GENERATOR% | findstr /C:"Visual Studio" >nul && (
set PLATFORM=
)

if %BUILD_DEBUG% == true (
if %IS_DEBUG% == true (
echo cmake .. -G %GENERATOR% %PLATFORM%^
-DCMAKE_BUILD_TYPE=Debug^
-DCMAKE_CXX_FLAGS_DEBUG="/MDd /MP"^
Expand Down
13 changes: 9 additions & 4 deletions Util/InstallersWin/install_rpclib.bat
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ rem ============================================================================
set DEL_SRC=false
:: --build-debug true|false
:: Build the Debug version of rpclib to debug LibCarla client
set BUILD_DEBUG=false
set IS_DEBUG=false

:arg-parse
if not "%1"=="" (
Expand All @@ -34,7 +34,7 @@ if not "%1"=="" (
set DEL_SRC=true
)
if "%1"=="--build-debug" (
set BUILD_DEBUG=true
set IS_DEBUG=true
shift
)
shift
Expand All @@ -61,7 +61,12 @@ set RPC_BUILD_DIR=%RPC_SRC_DIR%build\
set PUSHD_RPC=%RPC_SRC_DIR%

if exist "%RPC_INSTALL_DIR%" (
goto already_build
if %IS_DEBUG% == true (
echo %FILE_N% A rpclib Debug installation already exists. Rebuild it.
) else (
echo %FILE_N% A rpclib Release installation already exists.
goto already_build
)
)

if not exist "%RPC_SRC_DIR%" (
Expand Down Expand Up @@ -89,7 +94,7 @@ echo.%GENERATOR% | findstr /C:"Visual Studio" >nul && (
)


if %BUILD_DEBUG% == true (
if %IS_DEBUG% == true (
echo %FILE_N% cmake .. -G %GENERATOR% %PLATFORM% -DCMAKE_BUILD_TYPE=Debug -DRPCLIB_BUILD_EXAMPLES=OFF -DCMAKE_CXX_FLAGS_DEBUG="/MDd /MP" -DCMAKE_INSTALL_PREFIX="%RPC_INSTALL_DIR:\=/%" "%RPC_SRC_DIR%"
cmake .. -G %GENERATOR% %PLATFORM%^
-DCMAKE_BUILD_TYPE=Debug^
Expand Down
56 changes: 41 additions & 15 deletions Util/download_from_git.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,15 @@
# 2. python git_files.py 鐢熸垚git_files.txt鏂囦欢锛屽鍒跺叾涓殑鍐呭鍒癠til\hutb_downloader.spec鏂囦欢鐨凙nalysis瀵硅薄鐨刣atas鍙傛暟涓紝
# 灏唃it鐩綍娣诲姞鍒癲atas鍙傛暟涓紝鎹竴鍙版満鍣ㄨ繕鏄壘涓嶅埌git锛岃浆鑰屼粠gitee涓嬭浇git_min.zip锛屽苟瑙e帇鍒板綋鍓嶇洰褰曚笅锛岃繖鏍峰氨鍙互閬垮厤鍦ㄦ墦鍖呮垚exe鍚庯紝鎵句笉鍒癵it鍙墽琛屾枃浠剁殑闂
# 3. Pyinstaller download_from_git.py --onefile --name hutb_downloader -i hutb_log.ico
#
#
#
# 鏂版満鍣ㄩ棶棰橈細fatal: unable to access 'https://git.code.tencent.com/OpenHUTB/release.git/': error setting certificate verify locations: CAfile: E:/Projects/OpenHUTB-mcp/mcp/git/mingw64/ssl/certs/ca-bundle.crt/etc/ssl/certs/ca-bundle.crt CApath: none
# 瑙e喅锛歡it\bin\git.exe config --global http.sslVerify false
#
# 瑙e喅锛氭病鏈夋媺鍙栧ぇ鏂囦欢锛�
# 瑙e喅锛歡it\bin\git.exe lfs install
#
#
# 鍏朵粬锛堝紑鍙戣繃绋嬶級锛�
# 浣跨敤.spec鏂囦欢鎵撳寘锛歅yinstaller hutb_downloader.spec
# -i "icon.ico" 鎸囧畾鍥炬爣
Expand All @@ -26,6 +33,8 @@
# 鍗曚釜鏂囦欢锛�
# Pyinstaller download_from_git.py --onefile --add-data "git\bin\bash.exe;git\bin\" --add-data "git\bin\git.exe;git\bin\" -i hutb_log.ico --name hutb_downloader
#
#
#
# 涓婁紶鍒拌繙绋嬫湇鍔″櫒锛�
# python.exe download_from_git.py -u release

Expand All @@ -41,9 +50,6 @@
import urllib.request
import zipfile

from git.repo import Repo
from git.repo.fun import is_git_dir

# 鑾峰彇褰撳墠浠g爜璺緞鐨勪笂绾х洰褰�
home_dir = os.path.abspath(os.path.join(os.getcwd(), ".."))
# 鑾峰彇褰撳墠鑴氭湰鎵�鍦ㄧ殑璺緞
Expand All @@ -57,16 +63,13 @@
# 浣跨敤褰撳墠 git 鐩綍涓嬬殑 git 鍙墽琛屾枃浠�
# 鍒ゆ柇git鐩綍鏄惁瀛樺湪
prerequisites_dir = os.path.join(home_dir, "Build", "dependencies", "prerequisites")
if os.path.exists(os.path.join(prerequisites_dir, "git")) and not os.path.exists(
os.path.join(script_dir, "git", "bin", "git.exe")
):
if os.path.exists(os.path.join(prerequisites_dir, "git")) and not os.path.exists(os.path.join(script_dir, "git", "bin", "git.exe")):
# 灏唃it鐩綍鎷疯礉鍒板綋鍓嶈剼鏈墍鍦ㄧ殑璺緞涓�
print("Copying git directory from prerequisites to current script directory...")
shutil.copytree(
os.path.join(prerequisites_dir, "git"), os.path.join(script_dir, "git")
)
elif not os.path.exists(os.path.join(prerequisites_dir, "git")) and not os.path.exists(
os.path.join(script_dir, "git", "bin", "git.exe")
):
elif not os.path.exists(os.path.join(prerequisites_dir, "git")) and not os.path.exists(os.path.join(script_dir, "git", "bin", "git.exe")):
# 浠巊itee涓嬭浇git_min.zip锛屽苟瑙e帇鍒板綋鍓嶇洰褰曚笅
print(
"Git directory not found in prerequisites, download it from https://gitee.com/OpenHUTB/sw/releases/download/up/git_min.zip and extract it to %s"
Expand All @@ -78,14 +81,23 @@
)
with zipfile.ZipFile(os.path.join(script_dir, "git_min.zip"), "r") as zip_ref:
zip_ref.extractall(script_dir)
else:
print("Git directory not found in prerequisites or current script directory.")


# 杩欐牱鍙互閬垮厤鍦ㄦ墦鍖呮垚exe鍚庯紝鎵句笉鍒癵it鍙墽琛屾枃浠剁殑闂
git_path = os.path.join(script_dir, "git", "bin", "git.exe")
print("Using git executable: ", git_path)
os.environ["GIT_PYTHON_GIT_EXECUTABLE"] = git_path
git_exe = os.path.join(script_dir, "git", "bin", "git.exe")
print("Using git executable: ", git_exe)
os.environ["GIT_PYTHON_GIT_EXECUTABLE"] = git_exe

# 蹇呴』鍦ㄨ缃瓽IT_PYTHON_GIT_EXECUTABLE鐜鍙橀噺涔嬪悗锛屾墠鑳藉鍏it搴擄紝鍚﹀垯git搴撲細浣跨敤绯荤粺鐜鍙橀噺涓粯璁ょ殑git璺緞锛屽鑷存壘涓嶅埌git鍙墽琛屾枃浠剁殑闂
from git.repo import Repo
from git.repo.fun import is_git_dir

disable_ssl_verify_command = "%s config --global http.sslVerify false" % os.path.join(script_dir, 'git', 'bin', 'git.exe')
print(disable_ssl_verify_command)
os.system(disable_ssl_verify_command) # 瑙e喅鏂版満鍣ㄤ笂git鎷夊彇浠g爜鏃讹紝鍑虹幇鐨勮瘉涔﹂獙璇侀棶棰�

git_exe = os.environ.get("GIT_PYTHON_GIT_EXECUTABLE", "git")


def show_progress_bar(current, total, bar_length=40):
Expand Down Expand Up @@ -340,6 +352,7 @@ def remove_readonly(func, path, _):

if __name__ == "__main__":


argparser = argparse.ArgumentParser(description=__doc__)
argparser.add_argument(
"-r",
Expand Down Expand Up @@ -423,6 +436,15 @@ def remove_readonly(func, path, _):
# Remove previous download folder
shutil.rmtree(local_path, onerror=remove_readonly)
repo = GitRepository(local_path, remote_path)
# gitpython 搴撳湪鏂版満鍣ㄤ笅杞藉ぇ鏂囦欢鏃朵細鍑虹幇闂锛屾敼涓虹洿鎺ヨ皟鐢� git 鍛戒护琛屽伐鍏疯繘琛屼笅杞�
# repo = GitRepository(local_path, remote_path)
# 闂锛歋kipping object checkout, Git LFS is not installed for this repository.
# 瑙e喅锛歡it lfs install
# git_path = os.path.join(script_dir, 'git', 'bin', 'git.exe')
# clone_cmd = "%s clone %s %s && cd %s & %s lfs install && %s lfs pull && cd .." % (git_path, remote_path, local_path, save_dir, git_path, git_path)
# print("Cloning repository with command: ", clone_cmd)
# os.system(clone_cmd)


# 绉婚櫎宸ョ▼涓笉鐩稿叧鐨勬枃浠�
if os.path.exists(os.path.join(local_path, ".git")):
Expand Down Expand Up @@ -477,7 +499,11 @@ def remove_readonly(func, path, _):
cost_time = datetime.datetime.now() - start
# 褰撶綉缁滃甫瀹借冻澶熷ぇ鏃讹紝涓嬭浇鏃堕棿澶х害4-5鍒嗛挓宸﹀彸
print("Download finished, cost: %s" % (cost_time))
print("Download to: ", local_path)
print("Download path: ", local_path)

print("Launch simulator to click the file: %s" % os.path.join(local_path, 'CarlaUE4.exe'))
print("Press any key to continue...")
input()
# kill_process_on_port(2000) # 涓嬭浇瀹屾垚鍚庤嚜鍔ㄥ惎鍔–arlaUE4.exe锛屾柟渚跨敤鎴锋煡鐪嬩笅杞界粨鏋�
# if os.path.exists( os.path.join(local_path, 'CarlaUE4.exe') ):
# os.system("start "" %s" % os.path.join(local_path, 'CarlaUE4.exe')) # 鍚姩CarlaUE4.exe
Expand Down
Binary file modified Util/hutb_log.ico
Binary file not shown.
8 changes: 8 additions & 0 deletions setup.bat
Original file line number Diff line number Diff line change
Expand Up @@ -175,6 +175,14 @@ if exist "%cd%\Build\dependencies\" (
echo DirectX found!
)

rem Unzip DirectX Runtime
if not exist "prerequisites\DirectX_Runtime" (
echo Unzipping DirectX Runtime ...
"prerequisites\7zip\7z.exe" x "prerequisites\DirectX_Runtime.zip" -o"prerequisites\" -y >nul
) else (
echo DirectX Runtime already exists.
)

if not exist "prerequisites\miniconda3\" (
echo Unzipping miniconda...
"prerequisites\7zip\7z.exe" x "prerequisites\miniconda3.zip" -o"prerequisites\" -y >nul
Expand Down
Loading