Skip to content
Open
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
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -15,3 +15,7 @@ __pycache__/

#vscode config
.vscode/

#Generated MPC Code
main/src/vtr_path_planning/include/vtr_path_planning/mpc/mpc_solver.hpp
main/src/vtr_path_planning/src/mpc/mpc_solver.cpp
8 changes: 4 additions & 4 deletions main/src/vtr_common/vtr_include.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -36,18 +36,18 @@ endif()
set(SelectedPipeline "$ENV{VTR_PIPELINE}")


if(SelectedPipeline MATCHES "LIDAR")
if(SelectedPipeline STREQUAL "LIDAR")
add_definitions(-DVTR_ENABLE_LIDAR)
set(VTR_ENABLE_LIDAR true)
elseif(SelectedPipeline MATCHES "RADAR")
elseif(SelectedPipeline STREQUAL "RADAR")
add_definitions(-DVTR_ENABLE_RADAR)
set(VTR_ENABLE_RADAR true)
elseif(SelectedPipeline MATCHES "RADAR-LIDAR")
elseif(SelectedPipeline STREQUAL "RADAR-LIDAR")
add_definitions(-DVTR_ENABLE_RADAR)
set(VTR_ENABLE_RADAR true)
add_definitions(-DVTR_ENABLE_LIDAR)
set(VTR_ENABLE_LIDAR true)
elseif(SelectedPipeline MATCHES "VISION")
elseif(SelectedPipeline STREQUAL "VISION")
## GPUSURF enable/disable flag (used by vision pipeline only)
# Note: currently assume that gpusurf is always available, because we have no
# other options, so do not disable (i.e. comment out) this flag
Expand Down
6 changes: 5 additions & 1 deletion main/src/vtr_path_planning/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,12 @@ ament_target_dependencies(${PROJECT_NAME}_base
vtr_path_planning_msgs
)


execute_process(COMMAND ${PYTHON_EXECUTABLE} scripts/export_unicycle.py
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR})

add_custom_command(OUTPUT "include/vtr_path_planning/mpc/mpc_solver.hpp"
COMMAND "${PYTHON_EXECUTABLE}" "${CMAKE_CURRENT_SOURCE_DIR}/scripts/export_unicycle.py"
COMMAND ${PYTHON_EXECUTABLE} "${CMAKE_CURRENT_SOURCE_DIR}/scripts/export_unicycle.py"
DEPENDS "scripts/unicycle_solver.py")

add_custom_target(generate_header ALL
Expand Down

This file was deleted.

20 changes: 18 additions & 2 deletions main/src/vtr_path_planning/scripts/export_unicycle.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,25 @@
#! /usr/bin/python3

import sys
from unicycle_solver import solver
import shutil
import os

solver.generate_dependencies("mpc_solver.cpp", {"cpp": True, "with_header": True})
shutil.move('mpc_solver.cpp', os.getenv("VTRSRC") + '/main/src/vtr_path_planning/src/mpc/mpc_solver.cpp')
shutil.move('mpc_solver.h', os.getenv("VTRSRC") + '/main/src/vtr_path_planning/include/vtr_path_planning/mpc/mpc_solver.hpp')
print("Generated MPC files.", file=sys.stderr)
try:
if os.path.exists('mpc_solver.cpp'):
shutil.move(os.getcwd() + '/mpc_solver.cpp', os.getenv("VTRSRC") + '/main/src/vtr_path_planning/src/mpc/mpc_solver.cpp')
elif not os.path.exists(os.getenv("VTRSRC") + '/main/src/vtr_path_planning/src/mpc/mpc_solver.cpp'):
raise FileNotFoundError("An error occurred while exporting the MPC.")


if os.path.exists('mpc_solver.h'):
shutil.move(os.getcwd() + '/mpc_solver.h', os.getenv("VTRSRC") + '/main/src/vtr_path_planning/include/vtr_path_planning/mpc/mpc_solver.hpp')
elif not os.path.exists(os.getenv("VTRSRC") + '/main/src/vtr_path_planning/include/vtr_path_planning/mpc/mpc_solver.hpp'):
raise FileNotFoundError("An error occurred while exporting the MPC.")

print("Copied files successfully", file=sys.stderr)
except Exception as e:
print(f"Unknown error. Debug info pwd: {os.getcwd()}\nls: {os.listdir(os.getcwd())}", file=sys.stderr)
raise e
Loading
Loading