Skip to content
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

Costmap #639

Merged
merged 94 commits into from
May 19, 2024
Merged
Show file tree
Hide file tree
Changes from 33 commits
Commits
Show all changes
94 commits
Select commit Hold shift + click to select a range
8691b67
Test
RyanAspen Sep 19, 2023
46a2479
First commit
RyanAspen Sep 21, 2023
ca4cb07
Initial Cost_map commit
RyanAspen Nov 1, 2023
f79037b
Removed costmap folder copy
RyanAspen Nov 5, 2023
01cca13
Initial README.md
RyanAspen Nov 5, 2023
c61599b
Update README.md
RyanAspen Nov 5, 2023
c3bd12f
Update README.md
RyanAspen Nov 5, 2023
6eb8d2b
Update README.md to account for clarification on project specifications
RyanAspen Nov 10, 2023
d945109
Added clarification
RyanAspen Nov 10, 2023
7c2c227
Created water_bottle_search.py
26pawarp Nov 12, 2023
6d08489
Updated code for new project scope
RyanAspen Nov 14, 2023
db012d2
Added more complete logic for stitching
RyanAspen Nov 17, 2023
5bf78fa
Removed Line which kills Clang servers
RyanAspen Nov 17, 2023
0e6360d
Added rostopic and started callback function
26pawarp Nov 19, 2023
95761c0
add costmap nodelet in cmakelists
alisonryckman Nov 19, 2023
d82f70a
Added a debug file for testng the occupency grid message
26pawarp Nov 19, 2023
2ff1505
changed costmap removed redundant code
MackenzieMurphy Nov 19, 2023
9a82b0c
add costmap to cmakelists, fix some includes compatibility issues
umroverPerception Nov 26, 2023
782e22a
Started publisher for msg debugging
26pawarp Nov 26, 2023
bf8c75f
Debug course publisher update with test, also added temporary subscri…
26pawarp Nov 29, 2023
de8ce87
Callback function done and tested, data retrieved properly
26pawarp Nov 29, 2023
234315f
Removed duplicate code
Depicar Nov 30, 2023
6a448eb
remove pcl from build
alisonryckman Dec 3, 2023
c06b6f3
worked on grid filling
Crypt1cG Dec 3, 2023
5e0f139
merge
Crypt1cG Dec 3, 2023
ea4471e
fixed build and header
alisonryckman Jan 16, 2024
70aa5f0
add normals to zed processing
alisonryckman Jan 19, 2024
d452ba4
Cartesian Coordinates COnverting Function
26pawarp Jan 21, 2024
8535c3e
Merge branch 'master' into obs-avoidance
Emerson-Ramey Jan 21, 2024
da29226
Merge remote-tracking branch 'origin/integration' into obs-avoidance
qhdwight Jan 23, 2024
4b4df3b
Merge remote-tracking branch 'origin/integration' into costmap
umroverPerception Jan 23, 2024
beae107
Fix compile
umroverPerception Jan 23, 2024
40acab3
Update
umroverPerception Jan 24, 2024
41c4681
costmap stuff
umroverPerception Jan 24, 2024
5342537
Merge remote-tracking branch 'origin/integration' into costmap
qhdwight Jan 24, 2024
3039c9c
Remove old file
qhdwight Jan 24, 2024
5c65ea4
Merge remote-tracking branch 'origin/integration' into obs-avoidance
kayleyge Jan 25, 2024
36c1351
costmap node
Crypt1cG Jan 26, 2024
3e9cbb0
Merge remote-tracking branch 'origin/obs-avoidance' into obs-avoidance
kayleyge Jan 26, 2024
996575b
normal tweaks
Crypt1cG Jan 26, 2024
52a5bd8
Conversion function (Real World -> Occupancy Grid) & (Occupancy Grid …
26pawarp Jan 26, 2024
4a4afa8
Added setup for the A* program
26pawarp Jan 27, 2024
04654f3
pointcloud working
Crypt1cG Jan 31, 2024
e987b17
fast costmap
Crypt1cG Jan 31, 2024
99bb271
fixed costmap
Crypt1cG Jan 31, 2024
227170c
faster costmap
Crypt1cG Feb 1, 2024
6b74531
Finished adding A-Start
26pawarp Feb 2, 2024
52df6b2
Added A-Star call, but we need to do something with the list returned
26pawarp Feb 2, 2024
be439f3
Added reset cur point in trajector.py and made small changes to conve…
26pawarp Feb 3, 2024
e8b314c
reorganize and add path logic to on_loop
Emerson-Ramey Feb 4, 2024
caec28b
change incrementing of paths
Emerson-Ramey Feb 4, 2024
3f9c09c
minor tweaks
Crypt1cG Feb 6, 2024
57a5b43
removed allocations from hot-path
Crypt1cG Feb 6, 2024
973f25a
cleaned up starter project stuff
Crypt1cG Feb 6, 2024
aea0665
small changes for nav
Crypt1cG Feb 7, 2024
6c8f040
Merge remote-tracking branch 'origin/obs-avoidance' into costmap
Crypt1cG Feb 8, 2024
3cfd481
fix errors when running and add transitions
umroverPerception Feb 10, 2024
890cb25
minor fixes
Crypt1cG Feb 11, 2024
17b3a55
fix driving to same target point
umroverPerception Feb 11, 2024
ef3c646
Merge branch 'costmap' of github.com:umrover/mrover-ros into costmap
umroverPerception Feb 11, 2024
ce364ac
small fixes
Crypt1cG Feb 11, 2024
d555242
Merge branch 'costmap' of github.com:umrover/mrover-ros into costmap
Crypt1cG Feb 11, 2024
2be051e
got rid of z limit (might be needed in real world though)
Crypt1cG Feb 11, 2024
572e818
not done - testing path planning
umroverPerception Feb 18, 2024
a2592d4
Merge remote-tracking branch 'origin/integration' into costmap
qhdwight Feb 20, 2024
bc8d1f3
Update to use manif
qhdwight Feb 20, 2024
a13a89d
Formatting
qhdwight Feb 20, 2024
60fa76b
Fix nav imports
qhdwight Feb 20, 2024
59fb619
Merge remote-tracking branch 'origin/integration' into costmap
qhdwight Feb 20, 2024
e5d9092
Correct frame
qhdwight Feb 20, 2024
b877028
Enable ekf
qhdwight Feb 20, 2024
4cb242e
Merge remote-tracking branch 'origin/integration' into costmap
qhdwight Feb 20, 2024
6b466e5
Merge remote-tracking branch 'origin/integration' into costmap
qhdwight Feb 22, 2024
3e3b545
changed debug course publisher for waterbottle
kayleyge Feb 23, 2024
3e27986
Costmap touchup (#652)
qhdwight Feb 26, 2024
1cbff99
fix zed frame name
alisonryckman Feb 27, 2024
1d277cd
Merge remote-tracking branch 'origin/integration' into costmap
qhdwight Mar 3, 2024
cd678cf
fix navigation merge conflicts
Emerson-Ramey Mar 4, 2024
3728c6d
add message file
umroverPerception Mar 4, 2024
fe8ab31
fix percep topic name and testing nav path planning
umroverPerception Mar 8, 2024
d794ae4
fix orientation of costmap and start to consider average of neighbor …
umroverPerception Mar 8, 2024
eaa6467
update printed map, add kernel, traversable terrian
umroverPerception Mar 12, 2024
e5179c7
add transition to approach object, add exceptions and reset trajectory
umroverPerception Mar 16, 2024
7e69d19
add extra points to water bottle search spiral
umroverPerception Mar 22, 2024
bb27616
create new file for astar, move costmap callback to context
umroverPerception Mar 26, 2024
40d8b3e
Added ground1 test One mountain test
26pawarp Mar 28, 2024
ca76f89
Adding ground2.fbx and ground2.blend for testing and there's some tes…
arleencheema Mar 28, 2024
3effc25
added the arena for the 70th hunger games as a map
kayleyge Mar 31, 2024
fb9b018
Merge remote-tracking branch 'refs/remotes/origin/costmap' into costmap
kayleyge Mar 31, 2024
f7c85ea
update grounds
umroverPerception Apr 4, 2024
93fce06
worked on moving costmap
Crypt1cG Apr 11, 2024
87bbb85
forgot to add something
Crypt1cG Apr 11, 2024
054b377
Merge remote-tracking branch 'origin/integration' into costmap
Apr 28, 2024
a29f629
Merge remote-tracking branch 'origin/integration' into costmap
umroverPerception Apr 25, 2024
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 CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -180,6 +180,10 @@ endif ()
## Perception

mrover_add_nodelet(tag_detector src/perception/tag_detector/*.cpp src/perception/tag_detector src/perception/tag_detector/pch.hpp)
mrover_nodelet_link_libraries(tag_detector opencv_core opencv_objdetect opencv_aruco opencv_imgproc tbb lie)

mrover_add_nodelet(costmap src/perception/cost_map/*.cpp src/perception/cost_map src/perception/cost_map/pch.hpp)
mrover_nodelet_link_libraries(costmap lie)
mrover_nodelet_link_libraries(tag_detector opencv_core opencv_objdetect opencv_aruco opencv_imgproc opencv_highgui lie)

# if (CUDA_FOUND)
Expand Down
1 change: 1 addition & 0 deletions package.xml
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,7 @@
<export>
<nodelet plugin="${prefix}/plugins/tag_detector_plugin.xml" />
<nodelet plugin="${prefix}/plugins/zed_plugin.xml" />
<nodelet plugin="${prefix}/plugins/costmap.xml" />
<nodelet plugin="${prefix}/plugins/can.xml" />
<nodelet plugin="${prefix}/plugins/simulator.xml" />
</export>
Expand Down
6 changes: 6 additions & 0 deletions plugins/costmap.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
<library path="lib/libcostmap_nodelet">
<class name="mrover/CostMapNodelet"
type="mrover::CostMapNodelet"
base_class_type="nodelet::Nodelet">
</class>
</library>
21 changes: 21 additions & 0 deletions src/perception/cost_map/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
(WIP)

### Code Layout

- [cost_map.cpp](./cost_map.cpp) Mainly ROS node setup (topics, parameters, etc.)
- [cost_map.processing.cpp](./cost_map.processing.cpp) Processes ~~pointclouds~~ occupancy grids to continuously update the global terrain occupancy grid

### Explanation

The goal of this code is to take in a local occupancy grid / costmap (using http://docs.ros.org/en/melodic/api/nav_msgs/html/msg/OccupancyGrid.html) and output a global occupancy grid (again using http://docs.ros.org/en/melodic/api/nav_msgs/html/msg/OccupancyGrid.html).

~~The goal of this code is to take in pointcloud data from the zed and output a cost map / occupancy grid that represents the difficulty of passing terrain.~~

When a new local occupancy grid is received, the nodelet transforms it into the global frame using tf_tree information about the rover's frame relative to a chosen origin. The resolution (size of each grid space in physical units), grid width (in physical units), and grid height (in physical units) is used to determine the size of the costmap and to which grid space a given cost point is used to update. For simplicity, the new grid space's cost is equal to the maximum cost among the point cloud points that fall within the grid space. The cost map is then published for use by navigation nodelets.

~~When a new pointcloud is received, the nodelet first calculates the costs associated with each point in the pointcloud. The cost at a particular location is 100 if the curvature estimate is above our threshold, 0 if it is not, or -1 if there is no data for that location. This discreteness is helpful for the navigation functions using this costmap, as it minimizes erratic movement to account for new data.~~

~~After costs are calculated, each point's location is transformed from the local basis (relative to the rover) to the global basis (relative to the starting location).~~

~~Processed cost point data is then used to update the rover's costmap. The resolution (size of each grid space in physical units), grid width (in physical units), and grid height (in physical units) is used to determine the size of the costmap and to which grid space a given cost point is used to update. For simplicity, the new grid space's cost is equal to the maximum cost among the point cloud points that fall within the grid space. The cost map is then published for use by navigation nodelets.~~

37 changes: 37 additions & 0 deletions src/perception/cost_map/cost_map.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
#include "cost_map.hpp"

namespace mrover {

void CostMapNodelet::onInit() {
mNh = getMTNodeHandle();
mPnh = getMTPrivateNodeHandle(); // Unused for now
mNh.param<bool>("publish_cost_map", mPublishCostMap, true);
mNh.param<float>("resolution", mResolution, 0.5);
mNh.param<float>("map_width", mDimension, 60);

mCostMapPub = mCmt.advertise<nav_msgs::OccupancyGrid>("costmap", 1); // We publish our results to "costmap"

mPcSub = mNh.subscribe("camera/left/points", 1, &CostMapNodelet::pointCloudCallback, this);

mGlobalGridMsg.info.resolution = mResolution;
mGlobalGridMsg.info.width = (int) (mDimension / mResolution);
mGlobalGridMsg.info.height = (int) (mDimension / mResolution);
// make center of map at (0, 0)
mGlobalGridMsg.info.origin.position.x = -1 * mDimension / 2;
mGlobalGridMsg.info.origin.position.y = -1 * mDimension / 2;

mGlobalGridMsg.data.resize(mGlobalGridMsg.info.width * mGlobalGridMsg.info.height);
std::fill(mGlobalGridMsg.data.begin(), mGlobalGridMsg.data.end(), -1);
}
} // namespace mrover

/*
TODO:
- Nodelet takes in pointcloud
PARALLELIZE
- Get cost of point
- Transform point to nav basis
- Stitch to nav grid
END

*/
32 changes: 32 additions & 0 deletions src/perception/cost_map/cost_map.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
#include "pch.hpp"

namespace mrover {


class CostMapNodelet : public nodelet::Nodelet {
private:
ros::NodeHandle mNh, mPnh, mCmt;
ros::Publisher mCostMapPub;
ros::Subscriber mPcSub;
void onInit() override;

bool mPublishCostMap{}; // If set, publish the global costmap
float mResolution{}; // Meters per cell
float mDimension{}; // Dimensions of the square costmap in meters
float mNormalThreshold = 0.9;
tf2_ros::Buffer tf_buffer;
tf2_ros::TransformListener tf_listener{tf_buffer};

std::optional<SE3> mPreviousPose;
nav_msgs::OccupancyGrid mGlobalGridMsg;


public:
CostMapNodelet() = default;

~CostMapNodelet() override = default;

void configCallback();
void pointCloudCallback(sensor_msgs::PointCloud2ConstPtr const& msg);
};
} // namespace mrover
62 changes: 62 additions & 0 deletions src/perception/cost_map/cost_map.processing.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
#include "cost_map.hpp"
#include "../point.hpp"

#include "loop_profiler.hpp"
#include <Eigen/src/Core/Matrix.h>
#include <Eigen/src/Core/util/ForwardDeclarations.h>
#include <cstdint>
#include <pstl/glue_execution_defs.h>
#include <regex>

namespace mrover {

void CostMapNodelet::pointCloudCallback(sensor_msgs::PointCloud2ConstPtr const& msg) {
assert(msg);
assert(msg->height > 0);
assert(msg->width > 0);

if (!mPublishCostMap) return;
try {
SE3 zed_to_map = SE3::fromTfTree(tf_buffer, "map", "zed2i_left_camera_frame");
auto* points = reinterpret_cast<Point const*>(msg->data.data());
int step = 4;
uint32_t num_points = msg->width * msg->height / step;
Eigen::MatrixXd point_matrix(4, num_points);
qhdwight marked this conversation as resolved.
Show resolved Hide resolved
Eigen::MatrixXd normal_matrix(4, num_points);
// std::for_each(points, points + msg->width * msg->height, [&](auto* point) {
Copy link
Collaborator

Choose a reason for hiding this comment

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

I'm pretty sure this iteration method bands vertically. What I mean is that it skips more horizontally rather than vertically. A good solution would be to make a custom iterator that is cognizant of the current row so it knows to skip them. Then we can use that iterator in std::for_each with par_unseq.

for (auto point = points; point - points < msg->width * msg->height; point += step) {
Eigen::Vector4d p{point->x, point->y, 0, 1};
Copy link
Collaborator

Choose a reason for hiding this comment

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

Im pretty sure you should leave the z component in the point here and only set it to zero once its in the map frame, since if the zed is rotated you end up removing parts of the true x and y components

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This makes sense. Should be fixed now.

point_matrix.col((point - points) / step) = p;
Eigen::Vector4d normal{point->normal_x, point->normal_y, point->normal_z, 0};
normal_matrix.col((point - points) / step) = normal;
}

point_matrix = zed_to_map.matrix() * point_matrix;
normal_matrix = zed_to_map.matrix() * normal_matrix;

for (uint32_t i = 0; i < num_points; i++) {
double x = point_matrix(0, i);
double y = point_matrix(1, i);
Eigen::Vector4d n = normal_matrix.col(i);
Copy link
Collaborator

Choose a reason for hiding this comment

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

Eigen::Vector3d normalInMap = normal_matrix.col(i).head<3>()

head will grab the first three. No need to do Eigen::Vector3d normal{n.x(), n.y(), n.z()}; later.

This automatically de-homogenizes the vector. Note that we are not dividing by w which is usually done. But we know w=1 because we are multipliying by a SO3 matrix which is orthnormal and has det=1 so w won't change. Distance between points in your rigidbody is preservedi n other words


if (x >= -1 * mDimension / 2 && x <= mDimension / 2 &&
y >= -1 * mDimension / 2 && y <= mDimension / 2) {
int x_index = floor((x - mGlobalGridMsg.info.origin.position.x) / mGlobalGridMsg.info.resolution);
int y_index = floor((y - mGlobalGridMsg.info.origin.position.y) / mGlobalGridMsg.info.resolution);
auto i = mGlobalGridMsg.info.width * y_index + x_index;

Eigen::Vector3d normal{n.x(), n.y(), n.z()};
Copy link
Collaborator

Choose a reason for hiding this comment

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

Same thing with naming here. Indicate the frame.

normal.normalize();
Copy link
Collaborator

Choose a reason for hiding this comment

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

is this normalization step necessary after just a single matrix multiplication? I assume the zed gives us unit vectors. although ig it probably doesn't slow things down much

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yeah I just wasn't sure if the vectors in the pointcloud were unit vectors but it seems like they are.

Copy link
Collaborator

Choose a reason for hiding this comment

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

We can add an assert that the normal given by the zed is close to normalized.

// get vertical component of (unit) normal vector
double z_comp = normal.z();
// small z component indicates largely horizontal normal (surface is vertical)
signed char cost = z_comp < mNormalThreshold ? 100 : 0;

mGlobalGridMsg.data[i] = std::max(mGlobalGridMsg.data[i], cost);
}
}
mCostMapPub.publish(mGlobalGridMsg);
} catch (...) {
}
}
} // namespace mrover
22 changes: 22 additions & 0 deletions src/perception/cost_map/main.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
#include "cost_map.hpp"

#ifdef MROVER_IS_NODELET

#include <pluginlib/class_list_macros.h>
PLUGINLIB_EXPORT_CLASS(mrover::CostMapNodelet, nodelet::Nodelet)

#else

int main(int argc, char** argv) {
ros::init(argc, argv, "costmap");

// Start Costmap Nodelet
nodelet::Loader nodelet;
nodelet.load(ros::this_node::getName(), "mrover/CostMapNodelet", ros::names::getRemappings(), {});

ros::spin();

return EXIT_SUCCESS;
}

#endif
16 changes: 16 additions & 0 deletions src/perception/cost_map/pch.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
#pragma once

#include <algorithm>
#include <cstdint>

#include <nav_msgs/OccupancyGrid.h>
#include <nodelet/loader.h>
#include <nodelet/nodelet.h>
#include <ros/node_handle.h>
#include <ros/publisher.h>
#include <se3.hpp>
#include <sensor_msgs/PointCloud2.h>
#include <sensor_msgs/point_cloud2_iterator.h>
#include <tf2_ros/transform_broadcaster.h>

#include <mrover/DetectorParamsConfig.h>
11 changes: 8 additions & 3 deletions src/perception/zed_wrapper/zed_wrapper.bridge.cu
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ namespace mrover {
/**
* @brief Runs on the GPU, interleaving the XYZ and BGRA buffers into a single buffer of #Point structs.
*/
__global__ void fillPointCloudMessageKernel(sl::float4* xyzGpuPtr, sl::uchar4* bgraGpuPtr, Point* pcGpuPtr, size_t size) {
__global__ void fillPointCloudMessageKernel(sl::float4* xyzGpuPtr, sl::uchar4* bgraGpuPtr, sl::float4* normalsGpuPtr, Point* pcGpuPtr, size_t size) {
// This function is invoked once per element at index #i in the point cloud
size_t i = blockIdx.x * blockDim.x + threadIdx.x;
if (i >= size) return;
Expand All @@ -23,6 +23,10 @@ namespace mrover {
pcGpuPtr[i].g = bgraGpuPtr[i].g;
pcGpuPtr[i].r = bgraGpuPtr[i].b;
pcGpuPtr[i].a = bgraGpuPtr[i].a;
pcGpuPtr[i].normal_x = normalsGpuPtr[i].x;
pcGpuPtr[i].normal_x = normalsGpuPtr[i].y;
pcGpuPtr[i].normal_x = normalsGpuPtr[i].z;
// ROS_WARN(xyzGpuPtr[i].x);
}

/**
Expand All @@ -33,7 +37,7 @@ namespace mrover {
* @param pcGpu Point cloud buffer on the GPU (@see Point)
* @param msg Point cloud message with buffer on the CPU
*/
void fillPointCloudMessageFromGpu(sl::Mat& xyzGpu, sl::Mat& bgraGpu, PointCloudGpu& pcGpu, sensor_msgs::PointCloud2Ptr const& msg) {
void fillPointCloudMessageFromGpu(sl::Mat& xyzGpu, sl::Mat& bgraGpu, sl::Mat& normalsGpu, PointCloudGpu& pcGpu, sensor_msgs::PointCloud2Ptr const& msg) {
assert(bgraGpu.getWidth() >= xyzGpu.getWidth());
assert(bgraGpu.getHeight() >= xyzGpu.getHeight());
assert(bgraGpu.getChannels() == 4);
Expand All @@ -42,6 +46,7 @@ namespace mrover {

auto* bgraGpuPtr = bgraGpu.getPtr<sl::uchar4>(sl::MEM::GPU);
auto* xyzGpuPtr = xyzGpu.getPtr<sl::float4>(sl::MEM::GPU);
auto* normalsGpuPtr = normalsGpu.getPtr<sl::float4>(sl::MEM::GPU);
msg->is_bigendian = __BYTE_ORDER__ == __ORDER_BIG_ENDIAN__;
msg->is_dense = true;
msg->height = bgraGpu.getHeight();
Expand All @@ -53,7 +58,7 @@ namespace mrover {
Point* pcGpuPtr = pcGpu.data().get();
dim3 threadsPerBlock{BLOCK_SIZE};
dim3 numBlocks{static_cast<uint>(std::ceil(static_cast<float>(size) / BLOCK_SIZE))};
fillPointCloudMessageKernel<<<numBlocks, threadsPerBlock>>>(xyzGpuPtr, bgraGpuPtr, pcGpuPtr, size);
fillPointCloudMessageKernel<<<numBlocks, threadsPerBlock>>>(xyzGpuPtr, bgraGpuPtr, normalsGpuPtr, pcGpuPtr, size);
checkCudaError(cudaPeekAtLastError());
checkCudaError(cudaMemcpy(msg->data.data(), pcGpuPtr, size * sizeof(Point), cudaMemcpyDeviceToHost));
}
Expand Down
6 changes: 5 additions & 1 deletion src/perception/zed_wrapper/zed_wrapper.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@ namespace mrover {

mImageResolution = sl::Resolution(imageWidth, imageHeight);
mPointResolution = sl::Resolution(imageWidth, imageHeight);
mNormalsResolution = sl::Resolution(imageWidth, imageHeight);

NODELET_INFO("Resolution: %s image: %zux%zu points: %zux%zu",
grabResolutionString.c_str(), mImageResolution.width, mImageResolution.height, mPointResolution.width, mPointResolution.height);
Expand Down Expand Up @@ -139,7 +140,7 @@ namespace mrover {
mIsSwapReady = false;
mPcThreadProfiler.measureEvent("Wait");

fillPointCloudMessageFromGpu(mPcMeasures.leftPoints, mPcMeasures.leftImage, mPointCloudGpu, pointCloudMsg);
fillPointCloudMessageFromGpu(mPcMeasures.leftPoints, mPcMeasures.leftImage, mPcMeasures.leftNormals, mPointCloudGpu, pointCloudMsg);
pointCloudMsg->header.seq = mPointCloudUpdateTick;
pointCloudMsg->header.stamp = mPcMeasures.time;
pointCloudMsg->header.frame_id = "zed2i_left_camera_frame";
Expand Down Expand Up @@ -227,6 +228,8 @@ namespace mrover {
throw std::runtime_error("ZED failed to retrieve left image");
if (mZed.retrieveMeasure(mGrabMeasures.leftPoints, sl::MEASURE::XYZ, sl::MEM::GPU, mPointResolution) != sl::ERROR_CODE::SUCCESS)
throw std::runtime_error("ZED failed to retrieve point cloud");
if (mZed.retrieveMeasure(mGrabMeasures.leftNormals, sl::MEASURE::NORMALS, sl::MEM::GPU, mNormalsResolution) != sl::ERROR_CODE::SUCCESS)
throw std::runtime_error("ZED failed to retrieve point cloud normals");

assert(mGrabMeasures.leftImage.timestamp == mGrabMeasures.leftPoints.timestamp);

Expand Down Expand Up @@ -315,6 +318,7 @@ namespace mrover {
sl::Mat::swap(other.leftImage, leftImage);
sl::Mat::swap(other.rightImage, rightImage);
sl::Mat::swap(other.leftPoints, leftPoints);
sl::Mat::swap(other.leftNormals, leftNormals);
std::swap(time, other.time);
return *this;
}
Expand Down
5 changes: 3 additions & 2 deletions src/perception/zed_wrapper/zed_wrapper.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ namespace mrover {
sl::Mat leftImage;
sl::Mat rightImage;
sl::Mat leftPoints;
sl::Mat leftNormals;

Measures() = default;

Expand All @@ -31,7 +32,7 @@ namespace mrover {

PointCloudGpu mPointCloudGpu;

sl::Resolution mImageResolution, mPointResolution;
sl::Resolution mImageResolution, mPointResolution, mNormalsResolution;
sl::String mSvoPath;
int mGrabTargetFps{};
int mDepthConfidence{};
Expand Down Expand Up @@ -70,7 +71,7 @@ namespace mrover {

auto slTime2Ros(sl::Timestamp t) -> ros::Time;

auto fillPointCloudMessageFromGpu(sl::Mat& xyzGpu, sl::Mat& bgraGpu, PointCloudGpu& pcGpu, sensor_msgs::PointCloud2Ptr const& msg) -> void;
void fillPointCloudMessageFromGpu(sl::Mat& xyzGpu, sl::Mat& bgraGpu, sl::Mat& normalsGpu, PointCloudGpu& pcGpu, sensor_msgs::PointCloud2Ptr const& msg);

auto fillCameraInfoMessages(sl::CalibrationParameters& calibration, sl::Resolution const& resolution,
sensor_msgs::CameraInfoPtr const& leftInfoMsg, sensor_msgs::CameraInfoPtr const& rightInfoMsg) -> void;
Expand Down
2 changes: 1 addition & 1 deletion src/simulator/simulator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ namespace mrover {
#else
glfwPollEvents();
#endif
// glfwSetInputMode(mWindow.get(), GLFW_CURSOR, mInGui ? GLFW_CURSOR_NORMAL : GLFW_CURSOR_DISABLED);
glfwSetInputMode(mWindow.get(), GLFW_CURSOR, mInGui ? GLFW_CURSOR_NORMAL : GLFW_CURSOR_DISABLED);
mLoopProfiler.measureEvent("GLFW Events");

userControls(dt);
Expand Down
4 changes: 2 additions & 2 deletions src/util/lie/se3.cpp
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#include "se3.hpp"

SE3 SE3::fromTfTree(tf2_ros::Buffer const& buffer, std::string const& fromFrameId, std::string const& toFrameId) {
geometry_msgs::TransformStamped transform = buffer.lookupTransform(fromFrameId, toFrameId, ros::Time{});
SE3 SE3::fromTfTree(tf2_ros::Buffer const& buffer, std::string const& toFrameId, std::string const& fromFrameId) {
geometry_msgs::TransformStamped transform = buffer.lookupTransform(toFrameId, fromFrameId, ros::Time{});
return fromTf(transform.transform);
}

Expand Down
4 changes: 4 additions & 0 deletions starter_project/autonomy/msg/StarterProjectTag.msg
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
int32 tagId
Copy link
Collaborator

Choose a reason for hiding this comment

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

we should remove all these starter project files right

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Fixed?

Copy link
Collaborator

Choose a reason for hiding this comment

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

Looks like it. Instead of doing this manually (idk what you did) you can do git restore --source origin/integration starter_project or whatever to revert whole folders to certain branches (in this case the target merge branch).

float32 xTagCenterPixel
float32 yTagCenterPixel
float32 closenessMetric
2 changes: 2 additions & 0 deletions starter_project/autonomy/src/perception.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,8 @@ namespace mrover {
// hint: you have mTagDictionary, mTagCorners, mTagIds, and mTagDetectorParams member variables already defined!
// hint: write and use the "getCenterFromTagCorners" and "getClosenessMetricFromTagCorners" functions

cv::aruco::detectMarkers(image, mTagDictionary, mTagCorners, mTagIds, mTagDetectorParams);

tags.clear(); // Clear old tags in output vector

// TODO: implement me!
Expand Down
2 changes: 1 addition & 1 deletion urdf/meshes/bottle.fbx
Git LFS file not shown
4 changes: 2 additions & 2 deletions urdf/meshes/ground.fbx
Git LFS file not shown
2 changes: 1 addition & 1 deletion urdf/rover/rover.urdf.xacro
Original file line number Diff line number Diff line change
Expand Up @@ -278,7 +278,7 @@
</link>

<joint name="chassis_link_to_long_range_camera_link" type="fixed">
<origin xyz="0.3 0 1"/>
<origin xyz="0.3 0 0"/>
<parent link="chassis_link"/>
<child link="long_range_camera_link"/>
</joint>
Expand Down