Skip to content

Cleaned up the DepthImageBodyCollisionFilter in java and in c++, moved it above the RapidHeightMapManager. Deleted the duplicate thread for the height map #798

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 20 commits into from
May 8, 2025

Conversation

PotatoPeeler3000
Copy link
Contributor

@PotatoPeeler3000 PotatoPeeler3000 commented May 6, 2025

No description provided.

…eightMapData and the TerrainMapData individually
# Conflicts:
#	ihmc-footstep-planning/src/main/java/us/ihmc/footstepPlanning/FootstepPlannerRequest.java
# Conflicts:
#	ihmc-perception/src/main/java/us/ihmc/perception/gpuHeightMap/RapidHeightMapExtractorCUDA.java
#	ihmc-perception/src/main/java/us/ihmc/perception/gpuHeightMap/RapidHeightMapManager.java
# Conflicts:
#	ihmc-high-level-behaviors/src/main/java/us/ihmc/behaviors/activeMapping/ContinuousHikingProcess.java
…d it above the RapidHeightMapManager. Deleted the duplicate thread for the height map
@PotatoPeeler3000 PotatoPeeler3000 changed the title Cleaned up the DepthImageBodyCollisionFilter in java and in c++, move… Cleaned up the DepthImageBodyCollisionFilter in java and in c++, moved it above the RapidHeightMapManager. Deleted the duplicate thread for the height map May 6, 2025
Base automatically changed from cleanup/move-snapping-extractor to develop May 7, 2025 16:14
# Conflicts:
#	ihmc-high-level-behaviors/src/main/java/us/ihmc/perception/RapidHeightMapAutonomyUpdateThread.java
#	ihmc-high-level-behaviors/src/main/java/us/ihmc/perception/RapidHeightMapThread.java
#	ihmc-perception/src/main/java/us/ihmc/perception/gpuHeightMap/RapidHeightMapManager.java
CameraIntrinsics depthIntrinsicsCopy = depthImageCopy.getIntrinsicsCopy();

// Process body collisions
GpuMat depthImageWithoutBodyCollisions = new GpuMat(latestDepthImage.size(), latestDepthImage.type());
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pulled the body collision filter outside of the height map manager

@@ -16,8 +22,15 @@
import static org.bytedeco.cuda.global.cudart.cudaFree;
import static org.bytedeco.cuda.global.cudart.cudaStreamSynchronize;

public class CUDABodyCollisionFilter
/**
* This class removes the points of a depth image that are on parts of the body.
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice


// Note: We get the expected number of collidables and allocate that memory amount on the GPU
// By allocating once we don't have to free the memory in each call, just at the end
numberOfCollidables = countSupportedCollidables(robotCollidables);
numberOfCollidables = robotCollidables.size();
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We don't need to go through this method

@@ -391,7 +391,8 @@ public void destroy()
planOffsetKernel.close();

emptyGlobalHeightMapImage.close();
planOffsetKernelGridDim.close();
if (planOffsetKernelGridDim != null)
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That was a problem when closing, it would throw an exception, not relavent to this PR

float* collidableGeometryPointer,
int numCollidables,
int numberOfAttributes)
{
int x = Utils::getThreadCoordX();
int y = Utils::getThreadCoordY();
int x_index = blockIdx.x * blockDim.x + threadIdx.x;
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Less code

@ihmcrobotics ihmcrobotics deleted a comment from PotatoPeeler3000 May 7, 2025

public class RapidHeightMapThread
public class RapidHeightMapThread extends RepeatingTaskThread
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

😍

int x = Utils::getThreadCoordX();
int y = Utils::getThreadCoordY();
int x_index = blockIdx.x * blockDim.x + threadIdx.x;
int y_index = blockIdx.y * blockDim.y + threadIdx.y;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Shouldn't it be xIndex and yIndex? We don't really use snake case in our code

Comment on lines -91 to +86
*row(col(collisionMask, x), collisionMaskPitch, y) = depthValue;
unsigned short *matrixRow = (unsigned short *)((char *)collisionMaskMap + y_index * pitchCollisionMaskMap) + x_index;
*matrixRow = depthValue;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hmmm idk, using the row col functions seems much easier to read

Copy link
Contributor

@TomaszTB TomaszTB left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Noooooo I wrote a comment in IntelliJ and it didn't get added to the review 😭

RawImage depthImage = imageSensor.getImage(depthImageKey).get();

// Get everything we need from the image
RawImage depthImageCopy = depthImage.get();
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This depthImageCopy isn't actually a copy. It's the same reference to the depth image object, so the name is somewhat misleading.

Also, you shouldn't call get() when you just got an image from the ImageSensor. I know it's a bit confusing. Sorry 😅

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Talked over slack

@ihmc-rosie ihmc-rosie merged commit 2581f82 into develop May 8, 2025
64 of 68 checks passed
@ihmc-rosie ihmc-rosie deleted the cleanup/body-collision-filter-real branch May 8, 2025 17:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants