-
Notifications
You must be signed in to change notification settings - Fork 133
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Integrate fixes, improve documentation, and create simple example for…
… collecting 3d data for mapping (#58) * add first-pass 3d mapping script update dependencies and make sure it gets set up properly add detectron2 as a dependency add home-robot branch of contact graspnet to the repo add a simple ROS data colector remove torchaudio capture data + update debugging instructions udo not use segmentation algo update build scritp to see whats going on build 3d map fixes - integrate pointclouds over time via voxelize update dependencies and make sure it gets set up properly add a simple ROS data colector remove torchaudio capture data + update debugging instructions update build scritp to see whats going on build 3d map fixes - integrate pointclouds over time via voxelize fix controller problems update setup for assets - newest version of stretch urdf fix issues with run controller teleop scritp fix issues + add voxel grid * aggregate from one ptc * update script - change sample freq * correction when turning things into and out of open3d point clouds * fix point cloud math * update goto controller node - make sure it starts * fix issues with slow start for cameras * update readme + install guide to add some more details * add a note about project contents * add some notes on setup * update some things that cause failures on older cpus - removing open3d from various places * add first-pass 3d mapping script update dependencies and make sure it gets set up properly add detectron2 as a dependency add home-robot branch of contact graspnet to the repo add a simple ROS data colector remove torchaudio capture data + update debugging instructions udo not use segmentation algo update build scritp to see whats going on build 3d map fixes - integrate pointclouds over time via voxelize update dependencies and make sure it gets set up properly add a simple ROS data colector remove torchaudio capture data + update debugging instructions update build scritp to see whats going on build 3d map fixes - integrate pointclouds over time via voxelize fix controller problems update setup for assets - newest version of stretch urdf fix issues with run controller teleop scritp fix issues + add voxel grid * update goto controller node - make sure it starts * aggregate from one ptc * update script - change sample freq * correction when turning things into and out of open3d point clouds * fix point cloud math * fix issues with slow start for cameras * update readme + install guide to add some more details * add a note about project contents * add some notes on setup * update some things that cause failures on older cpus - removing open3d from various places * update bullet config * update visualization code * update stretch controller - make sure that it's setting position mode * switch to position mode if we need to control the base via the controller - switching back and forth from nav/position * update point cloud tools - remove from data_tools * update code - fixes to open3d point cloud paths * remove color fixes in open3d code - this really should not happen * resolve this issue #69 * update basic environment to resolve #68 * update to resolve #70 * clean up some debug print statements * update header for function * resolve a couple comments from PR * remove bad import
- Loading branch information
Showing
25 changed files
with
271 additions
and
1,323 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -10,3 +10,9 @@ | |
[submodule "src/third_party/habitat-lab"] | ||
path = src/third_party/habitat-lab | ||
url = https://github.com/facebookresearch/habitat-lab | ||
[submodule "src/third_party/detectron2"] | ||
path = src/third_party/detectron2 | ||
url = [email protected]:facebookresearch/detectron2.git | ||
[submodule "src/third_party/contact_graspnet"] | ||
path = src/third_party/contact_graspnet | ||
url = [email protected]:cpaxton/contact_graspnet.git |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Submodule hab_stretch
updated
from 5130c5 to f188cf
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,108 @@ | ||
# Copyright (c) Meta Platforms, Inc. and affiliates. | ||
# | ||
# This source code is licensed under the MIT license found in the | ||
# LICENSE file in the root directory of this source tree. | ||
import argparse | ||
import sys | ||
import timeit | ||
|
||
import click | ||
import numpy as np | ||
import open3d | ||
import rospy | ||
|
||
from home_robot.agent.motion.stretch import STRETCH_PREGRASP_Q, HelloStretchIdx | ||
from home_robot.utils.point_cloud import ( | ||
numpy_to_pcd, | ||
pcd_to_numpy, | ||
show_point_cloud, | ||
) | ||
from home_robot.utils.pose import to_pos_quat | ||
from home_robot_hw.env.stretch_grasping_env import StretchGraspingEnv | ||
|
||
|
||
def combine_point_clouds(pc_xyz: np.ndarray, pc_rgb: np.ndarray, xyz: np.ndarray, rgb: np.ndarray) -> np.ndarray: | ||
"""Tool to combine point clouds without duplicates. Concatenate, voxelize, and then return | ||
the finished results.""" | ||
if pc_rgb is None: | ||
pc_rgb, pc_xyz = rgb, xyz | ||
else: | ||
np.concatenate([pc_rgb, rgb], axis=0) | ||
np.concatenate([pc_xyz, xyz], axis=0) | ||
pcd = numpy_to_pcd(xyz, rgb).voxel_down_sample(voxel_size=0.05) | ||
return pcd_to_numpy(pcd) | ||
|
||
|
||
class RosMapDataCollector(object): | ||
"""Simple class to collect RGB, Depth, and Pose information for building 3d spatial-semantic | ||
maps for the robot. Needs to subscribe to: | ||
- color images | ||
- depth images | ||
- camera info | ||
- joint states/head camera pose | ||
- base pose (relative to world frame) | ||
This is an example collecting the data; not necessarily the way you should do it. | ||
""" | ||
|
||
def __init__(self, env): | ||
self.env = env # Get the connection to the ROS environment via agent | ||
self.observations = [] | ||
self.started = False | ||
|
||
def step(self): | ||
"""Step the collector. Get a single observation of the world. Remove bad points, such as | ||
those from too far or too near the camera.""" | ||
rgb, depth, xyz = self.env.get_images(compute_xyz=True) | ||
q, dq = self.env.update() | ||
|
||
# apply depth filter | ||
depth = depth.reshape(-1) | ||
rgb = rgb.reshape(-1, 3) | ||
xyz = xyz.reshape(-1, 3) | ||
valid_depth = np.bitwise_and(depth > 0.1, depth < 4.) | ||
rgb = rgb[valid_depth, :] | ||
xyz = xyz[valid_depth, :] | ||
self.observations.append((rgb, xyz, q, dq)) | ||
|
||
def show(self): | ||
"""Display the aggregated point cloud.""" | ||
|
||
# Create a combined point cloud | ||
# Do the other stuff we need | ||
pc_xyz, pc_rgb = None, None | ||
for obs in self.observations: | ||
rgb = obs[0] | ||
xyz = obs[1] | ||
pc_xyz, pc_rgb = combine_point_clouds(pc_xyz, pc_rgb, xyz, rgb) | ||
|
||
show_point_cloud(pc_xyz, pc_rgb / 255) | ||
|
||
|
||
@click.command() | ||
@click.option("--rate", default=1, type=int) | ||
@click.option("--max-frames", default=5, type=int) | ||
def main(rate=10, max_frames=-1): | ||
rospy.init_node("build_3d_map") | ||
env = StretchGraspingEnv(segmentation_method=None) | ||
collector = RosMapDataCollector(env) | ||
|
||
rate = rospy.Rate(rate) | ||
print("Press ctrl+c to finish...") | ||
frames = 0 | ||
while not rospy.is_shutdown(): | ||
# Run until we control+C this script | ||
collector.step() # Append latest observations | ||
rate.sleep() | ||
|
||
frames += 1 | ||
if max_frames > 0 and frames >= max_frames: | ||
break | ||
|
||
print("Done collecting data.") | ||
collector.show() | ||
|
||
|
||
if __name__ == "__main__": | ||
"""run the test script.""" | ||
main() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.