Skip to content

Commit

Permalink
Merge branch 'main' into JRA/ZED-Wrapper
Browse files Browse the repository at this point in the history
  • Loading branch information
jbrhm committed Sep 17, 2024
2 parents beb2e9d + ebbfa9d commit bfc4c79
Show file tree
Hide file tree
Showing 7 changed files with 83 additions and 34 deletions.
10 changes: 5 additions & 5 deletions bootstrap.sh
Original file line number Diff line number Diff line change
Expand Up @@ -50,16 +50,16 @@ echo -e "${GREY_BOLD}Using ${CATKIN_PATH} as ROS workspace${NC}"
readonly MROVER_PATH=${CATKIN_PATH}/src/mrover
FIRST_TIME_SETUP=false

if [ ! -d ${MROVER_PATH} ]; then
if [ ! -d "${MROVER_PATH}" ]; then
echo -e "${GREY_BOLD}Creating ROS workspace ...${NC}"
mkdir -p ${CATKIN_PATH}/src
git clone [email protected]:umrover/mrover-ros2 ${CATKIN_PATH}/src/mrover
cd ${CATKIN_PATH}/src/mrover
mkdir -p "${CATKIN_PATH}"/src
git clone [email protected]:umrover/mrover-ros2 "${CATKIN_PATH}"/src/mrover
cd "${CATKIN_PATH}"/src/mrover
FIRST_TIME_SETUP=true
fi

echo -e "${GREY_BOLD}Using Ansible to finish up ...${NC}"
${MROVER_PATH}/ansible.sh dev.yml
"${MROVER_PATH}"/ansible.sh dev.yml

if [ "${FIRST_TIME_SETUP}" ]; then
echo -e "${GREY_BOLD}All done! Welcome to MRover!${NC}"
Expand Down
2 changes: 1 addition & 1 deletion build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -18,4 +18,4 @@ colcon build \
--cmake-args -G Ninja -W no-dev -DCMAKE_BUILD_TYPE=RelWithDebInfo \
--symlink-install \
--event-handlers console_direct+ \
$@
"$@"
2 changes: 1 addition & 1 deletion build_ci.sh
Original file line number Diff line number Diff line change
Expand Up @@ -14,4 +14,4 @@ colcon build \
--cmake-args -G Ninja -W no-dev -D CMAKE_BUILD_TYPE=Release -D MROVER_CI=ON \
--symlink-install \
--event-handlers console_direct+ \
$@
"$@"
1 change: 0 additions & 1 deletion simulator/simulator.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -273,7 +273,6 @@ namespace mrover {
wgpu::Device mDevice;
std::unique_ptr<wgpu::ErrorCallback> mErrorCallback;
wgpu::Queue mQueue;
wgpu::SwapChain mSwapChain;
wgpu::Texture mDepthTexture;
wgpu::TextureView mDepthTextureView;
wgpu::Texture mNormalTexture;
Expand Down
47 changes: 30 additions & 17 deletions simulator/simulator.render.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -35,14 +35,15 @@ namespace mrover {
}

auto Simulator::makeFramebuffers(int width, int height) -> void {
wgpu::SwapChainDescriptor descriptor;
descriptor.usage = wgpu::TextureUsage::RenderAttachment;
descriptor.format = COLOR_FORMAT;
descriptor.width = width;
descriptor.height = height;
descriptor.presentMode = wgpu::PresentMode::Immediate;
mSwapChain = mDevice.createSwapChain(mSurface, descriptor);
if (!mSwapChain) throw std::runtime_error("Failed to create WGPU swap chain");
wgpu::SurfaceConfiguration surfaceConfiguration;
surfaceConfiguration.device = mDevice;
surfaceConfiguration.format = COLOR_FORMAT;
surfaceConfiguration.usage = wgpu::TextureUsage::RenderAttachment;
surfaceConfiguration.width = width;
surfaceConfiguration.height = height;
surfaceConfiguration.alphaMode = wgpu::CompositeAlphaMode::Auto;
surfaceConfiguration.presentMode = wgpu::PresentMode::Immediate;
mSurface.configure(surfaceConfiguration);
std::tie(mNormalTexture, mNormalTextureView) = makeTextureAndView(width, height, NORMAL_FORMAT, wgpu::TextureUsage::RenderAttachment, wgpu::TextureAspect::All);
std::tie(mDepthTexture, mDepthTextureView) = makeTextureAndView(width, height, DEPTH_FORMAT, wgpu::TextureUsage::RenderAttachment, wgpu::TextureAspect::DepthOnly);
}
Expand Down Expand Up @@ -203,7 +204,9 @@ namespace mrover {
constexpr auto WINDOW_NAME = "MRover Simulator (DEBUG BUILD, MAY BE SLOW)";
#endif
glfwWindowHint(GLFW_CLIENT_API, GLFW_NO_API);
glfwWindowHint(GLFW_RESIZABLE, GLFW_FALSE);
// There is still an off-by-one error on Vulkan with resizing windows and ImGui.
// See: https://matrix.to/#/!ZSOHTEPDbwuEgSJwYw:matrix.org
glfwWindowHint(GLFW_RESIZABLE, GLFW_TRUE);
glfwWindowHint(GLFW_COCOA_RETINA_FRAMEBUFFER, GLFW_FALSE);
mWindow = GlfwPointer<GLFWwindow, glfwCreateWindow, glfwDestroyWindow>{w, h, WINDOW_NAME, nullptr, nullptr};
RCLCPP_INFO_STREAM(get_logger(), std::format("Created window of size: {}x{}", w, h));
Expand Down Expand Up @@ -258,7 +261,7 @@ namespace mrover {
mNormalTextureView.release();
mNormalTexture.destroy();
mNormalTexture.release();
mSwapChain.release();
mSurface.unconfigure();

makeFramebuffers(width, height);
}
Expand Down Expand Up @@ -492,7 +495,7 @@ namespace mrover {
for (int i = 0; i < compound->getNumChildShapes(); ++i) {
SE3d modelInLink = btTransformToSe3(urdfPoseToBtTransform(link->collision_array.at(i)->origin));
SE3d modelInWorld = linkToWorld * modelInLink;
auto* shape = compound->getChildShape(i);
btCollisionShape* shape = compound->getChildShape(i);
if (auto* box = dynamic_cast<btBoxShape const*>(shape)) {
btVector3 extents = box->getHalfExtentsWithoutMargin() * 2;
SIM3 modelToWorld{modelInWorld, R3d{extents.x(), extents.y(), extents.z()}};
Expand Down Expand Up @@ -723,10 +726,20 @@ namespace mrover {
camerasUpdate(encoder, colorAttachment, normalAttachment, depthStencilAttachment, renderPassDescriptor);

if (!mIsHeadless) {
wgpu::TextureView nextTexture = mSwapChain.getCurrentTextureView();
if (!nextTexture) throw std::runtime_error("Failed to get WGPU next texture view");

colorAttachment.view = nextTexture;
wgpu::SurfaceTexture surfaceTexture;
mSurface.getCurrentTexture(&surfaceTexture);
if (surfaceTexture.status != wgpu::SurfaceGetCurrentTextureStatus::Success)
throw std::runtime_error{"Failed to get WGPU surface texture"};

wgpu::TextureViewDescriptor nextTextureViewDescriptor;
nextTextureViewDescriptor.format = COLOR_FORMAT;
nextTextureViewDescriptor.dimension = wgpu::TextureViewDimension::_2D;
nextTextureViewDescriptor.mipLevelCount = 1;
nextTextureViewDescriptor.arrayLayerCount = 1;
nextTextureViewDescriptor.aspect = wgpu::TextureAspect::All;
wgpu::TextureView nextTextureView = wgpu::Texture{surfaceTexture.texture}.createView(nextTextureViewDescriptor);

colorAttachment.view = nextTextureView;
normalAttachment.view = mNormalTextureView;
depthStencilAttachment.view = mDepthTextureView;

Expand Down Expand Up @@ -768,7 +781,7 @@ namespace mrover {

bindGroup.release();

nextTexture.release();
nextTextureView.release();
}

wgpu::CommandBuffer commands = encoder.finish();
Expand All @@ -791,7 +804,7 @@ namespace mrover {
}
#endif

if (!mIsHeadless) mSwapChain.present();
if (!mIsHeadless) mSurface.present();

// TODO(quintin): Remote duplicate code
for (StereoCamera& stereoCamera: mStereoCameras) {
Expand Down
52 changes: 43 additions & 9 deletions style.sh
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,9 @@ function print_update_error() {
}

function find_executable() {
local readonly executable="$1"
local readonly version="$2"
local readonly path=$(which "${executable}")
local -r executable="$1"
local -r version="$2"
local -r path=$(which "${executable}")
if [ ! -x "${path}" ]; then
echo -e "${RED}[Error] Could not find ${executable}${NC}"
print_update_error
Expand All @@ -44,24 +44,58 @@ function find_executable() {

## Check that all tools are installed

readonly CLANG_FORMAT_PATH=$(find_executable clang-format-18 18.1.8)
readonly CLANG_FORMAT_PATH=$(find_executable clang-format-18 18.1)
readonly BLACK_PATH=$(find_executable black 24.8.0)
readonly MYPY_PATH=$(find_executable mypy 1.11.2)

## Run checks

# Add new directories with C++ code here:
readonly CPP_DIRS=(
./perception
./lie
./esw
./simulator
)

echo "Style checking C++ ..."
find ./perception ./lie ./esw ./simulator -regex '.*\.\(cpp\|hpp\|h\)' -exec "${CLANG_FORMAT_PATH}" "${CLANG_FORMAT_ARGS[@]}" -i {} \;
readonly CPP_FILES=$(find "${CPP_DIRS[@]}" -name "*.cpp" -o -name "*.hpp" -o -name "*.h" -o -name "*.cu")
for file in $CPP_FILES; do
"${CLANG_FORMAT_PATH}" "${CLANG_FORMAT_ARGS[@]}" -i "${file}"
done
echo "Done"

# Add new directories with Python code here:
readonly PYTHON_LINT_DIRS=(
./navigation
./localization
./scripts
./state_machine
./lie
./superstructure
)
readonly PYTHON_STYLE_DIRS=(
"${PYTHON_LINT_DIRS[@]}"
./launch
)

echo
echo "Style checking Python with black ..."
"$BLACK_PATH" "${BLACK_ARGS[@]}" . --exclude=venv
"${BLACK_PATH}" "${BLACK_ARGS[@]}" "${PYTHON_STYLE_DIRS[@]}"

echo
echo "Style checking Python with mypy ..."
# TODO(quintin): Add other subteam folders and scripts folder
"$MYPY_PATH" --config-file=mypy.ini --check ./navigation ./scripts
echo "Linting Python with mypy ..."
"${MYPY_PATH}" --config-file=mypy.ini --check "${PYTHON_LINT_DIRS[@]}"

if command -v shellcheck &> /dev/null; then
echo
echo "Linting bash scripts with shellcheck ..."
readonly SHELL_FILES=$(find . -depth 1 -name "*.sh")
for file in $SHELL_FILES; do
# SC2155 is separate declaration and command.
shellcheck "${file}" --exclude=SC2155
done
fi

if [ $# -eq 0 ] || [ "$1" != "--fix" ]; then
echo
Expand Down
3 changes: 3 additions & 0 deletions units/units_eigen.hpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
#pragma once

// Including this file provides baseline compatibility with Eigen.
// Should be able to use unit types in Eigen matrices.

#include "units.hpp"

#include <Eigen/Core>
Expand Down

0 comments on commit bfc4c79

Please sign in to comment.