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

Created example with DOPE and DIff-DOPE integration through ROS actinolib. #7

Open
wants to merge 47 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
47 commits
Select commit Hold shift + click to select a range
3a6d6f2
Created a config file for demo with multi-object with ROS and DOPE
rpapallas Jan 18, 2024
457dc44
Modified Scene dataclass to allow memory image representation
rpapallas Jan 18, 2024
053f252
Updated model paths and added rgb/depth topics.
rpapallas Jan 18, 2024
55e1d0a
Corrected typo
rpapallas Jan 18, 2024
0a465bf
Minor changes to yaml file
rpapallas Jan 18, 2024
b361465
Added some HOPE object models as examples.
rpapallas Jan 18, 2024
deb545f
Added .mp4 in gitignore
rpapallas Jan 18, 2024
e7ccf35
Implemented first version of ROS+DOPE demo with multi-object tracking.
rpapallas Jan 18, 2024
e77f4eb
Ignore _build directory in docs
rpapallas Jan 18, 2024
66d318c
Created a new docs page for demos
rpapallas Jan 18, 2024
eeea44d
Added URL to the ROS bag.
rpapallas Jan 19, 2024
c36572b
Added readme to demos to help people realise that the docs include in…
rpapallas Jan 19, 2024
e6fe8f3
Converted the demo into a catkin package
rpapallas Jan 19, 2024
6d08c96
Updated msgs
rpapallas Jan 19, 2024
0b335f3
Implemented first version of actionlib server
rpapallas Jan 19, 2024
40fa711
Implemented a class to support segmentation based on segment-anything
rpapallas Jan 19, 2024
4406f5a
Reformmating based on pre-commit rules
rpapallas Jan 19, 2024
3eb186c
Added some segmentation test images
rpapallas Jan 19, 2024
195f74d
Renamed segmentation class
rpapallas Jan 19, 2024
239bc07
Added script to build and zip website for deployment
rpapallas Jan 19, 2024
a699d7f
Updated meshes of HOPE objects.
rpapallas Jan 22, 2024
e932625
Implemented actionlib demo
rpapallas Jan 22, 2024
aadfe1f
Updated the mesh for bbq sauce
rpapallas Jan 22, 2024
ddc0dd7
Updated meshes for other HOPE objects.
rpapallas Jan 22, 2024
3dbd21f
Camera intrinsic params dynamically retrieved from ROS topic.
rpapallas Jan 22, 2024
fdffe0e
General refactoring
rpapallas Jan 22, 2024
b7bdf99
Updated docs to include instructions of how to run the demo and how t…
rpapallas Jan 22, 2024
a9cd963
Updated the roslaunch commands for refine client
rpapallas Jan 23, 2024
463c8cb
Updated model's frame orientation to match DOPE
rpapallas Mar 7, 2024
56a8248
Update demos.rst
rpapallas Mar 7, 2024
494c12c
Minor change.
rpapallas Apr 3, 2024
b2e6901
Reverted models back to original format and instead added transformat…
rpapallas Apr 3, 2024
fd5c2c4
Minor changes.
rpapallas Apr 3, 2024
c709929
Updated models.
rpapallas Apr 5, 2024
51c84cb
Fixed pose output issue
rpapallas Apr 5, 2024
7495914
Merge branch 'ros-example' of github.com:rpapallas/diff-dope into ros…
rpapallas Apr 5, 2024
a033fb1
Removed unused libraries.
rpapallas Apr 5, 2024
08d465a
Updated docs.
rpapallas Apr 5, 2024
8520f05
Removed old model of orange_juice and added object textures
rpapallas Apr 5, 2024
a3198fc
Added ROS example in README.
rpapallas Apr 27, 2024
48bd007
Moved diffdope_ros to root dir.
rpapallas Apr 27, 2024
4eeeceb
Updated docs to include step to run DOPE.
rpapallas Apr 27, 2024
8aaa647
Made rgb and depth callbacks atomic and not one per object.
rpapallas Apr 30, 2024
6a8f526
Added check to ensure all data available before refining.
rpapallas Apr 30, 2024
13a41fd
Added limit of saved videos per run to avoid saving too many during c…
rpapallas Apr 30, 2024
6c335fe
Implemented continuous tracking and publishing of refined pose to a t…
rpapallas Apr 30, 2024
4b7d46f
Updated docs to include details about continuous tracking launch file
rpapallas Apr 30, 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
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,4 @@ docs/_buid/
*.png
*.jpg
*.jpeg
*.mp4
41 changes: 22 additions & 19 deletions diffdope/diffdope.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,10 @@

import collections
import io
import sys
import math
import pathlib
import random
import sys
import warnings
from dataclasses import dataclass
from itertools import repeat
Expand All @@ -36,7 +36,7 @@

# for better print debug
print()
if not hasattr(sys, 'ps1'):
if not hasattr(sys, "ps1"):
print = ic

# A logger for this file
Expand Down Expand Up @@ -209,9 +209,14 @@ def render_texture_batch(
depth = depth.reshape(shape_keep)[..., 2] * -1

# mask , _ = dr.interpolate(torch.ones(pos_idx.shape).cuda(), rast_out, pos_idx)
mask, _ = dr.interpolate(torch.ones(pos_idx.shape).cuda(),
rast_out, pos_idx[0],rast_db=rast_out_db,diff_attrs="all")
mask = dr.antialias(mask, rast_out, pos_clip_ja, pos_idx[0])
mask, _ = dr.interpolate(
torch.ones(pos_idx.shape).cuda(),
rast_out,
pos_idx[0],
rast_db=rast_out_db,
diff_attrs="all",
)
mask = dr.antialias(mask, rast_out, pos_clip_ja, pos_idx[0])

# compute vertex color interpolation
if vtx_color is None:
Expand All @@ -237,7 +242,7 @@ def render_texture_batch(
color = color * torch.clamp(rast_out[..., -1:], 0, 1) # Mask out background.
if not return_rast_out:
rast_out = None
return {"rgb": color, "depth": depth, "rast_out": rast_out, 'mask':mask}
return {"rgb": color, "depth": depth, "rast_out": rast_out, "mask": mask}


##############################################################################
Expand Down Expand Up @@ -973,7 +978,7 @@ def __init__(
self.qx = None # to load on cpu and not gpu

if model_path is None:
self.mesh = None
self.mesh = None
else:
self.mesh = Mesh(path_model=model_path, scale=scale)

Expand Down Expand Up @@ -1227,11 +1232,11 @@ def set_batchsize(self, batchsize):
Args:
batchsize (int): batchsize for the tensors
"""
if not self.path_img is None:
if not self.tensor_rgb is None:
self.tensor_rgb.set_batchsize(batchsize)
if not self.path_depth is None:
if not self.tensor_depth is None:
self.tensor_depth.set_batchsize(batchsize)
if not self.path_segmentation is None:
if not self.tensor_segmentation is None:
self.tensor_segmentation.set_batchsize(batchsize)

def get_resolution(self):
Expand All @@ -1241,17 +1246,17 @@ def get_resolution(self):
Return
(list): w,h of the image for optimization
"""
if not self.path_img is None:
if not self.tensor_rgb is None:
return [
self.tensor_rgb.img_tensor.shape[-3],
self.tensor_rgb.img_tensor.shape[-2],
]
if not self.path_depth is None:
if not self.tensor_depth is None:
return [
self.tensor_depth.img_tensor.shape[-2],
self.tensor_depth.img_tensor.shape[-1],
]
if not self.path_segmentation is None:
if not self.tensor_segmentation is None:
return [
self.tensor_segmentation.img_tensor.shape[-3],
self.tensor_segmentation.img_tensor.shape[-2],
Expand All @@ -1262,11 +1267,11 @@ def cuda(self):
Put on cuda the image tensors
"""

if not self.path_img is None:
if not self.tensor_rgb is None:
self.tensor_rgb.cuda()
if not self.path_depth is None:
if not self.tensor_depth is None:
self.tensor_depth.cuda()
if not self.path_segmentation is None:
if not self.tensor_segmentation is None:
self.tensor_segmentation.cuda()


Expand Down Expand Up @@ -1424,7 +1429,7 @@ def render_img(

else:
crop = find_crop(self.optimization_results[index][render_selection][0])

if batch_index is None:
# make a grid
if self.cfg.render_images.crop_around_mask:
Expand Down Expand Up @@ -1656,7 +1661,6 @@ def run_optimization(self):
if self.scene.tensor_segmentation is not None:
self.gt_tensors["segmentation"] = self.scene.tensor_segmentation.img_tensor


pbar = tqdm(range(self.cfg.hyperparameters.nb_iterations + 1))

for iteration_now in pbar:
Expand Down Expand Up @@ -1728,4 +1732,3 @@ def cuda(self):
self.object3d.cuda()
self.scene.cuda()
self.camera.cuda()
pass
213 changes: 213 additions & 0 deletions diffdope_ros/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,213 @@
cmake_minimum_required(VERSION 3.0.2)
project(diffdope_ros)

## Compile as C++11, supported in ROS Kinetic and newer
# add_compile_options(-std=c++11)

## Find catkin macros and libraries
## if COMPONENTS list like find_package(catkin REQUIRED COMPONENTS xyz)
## is used, also find other catkin packages
find_package(catkin REQUIRED COMPONENTS
rospy
std_msgs
geometry_msgs
sensor_msgs
actionlib
actionlib_msgs
)

## System dependencies are found with CMake's conventions
# find_package(Boost REQUIRED COMPONENTS system)


## Uncomment this if the package has a setup.py. This macro ensures
## modules and global scripts declared therein get installed
## See http://ros.org/doc/api/catkin/html/user_guide/setup_dot_py.html
# catkin_python_setup()

################################################
## Declare ROS messages, services and actions ##
################################################

## To declare and build messages, services or actions from within this
## package, follow these steps:
## * Let MSG_DEP_SET be the set of packages whose message types you use in
## your messages/services/actions (e.g. std_msgs, actionlib_msgs, ...).
## * In the file package.xml:
## * add a build_depend tag for "message_generation"
## * add a build_depend and a exec_depend tag for each package in MSG_DEP_SET
## * If MSG_DEP_SET isn't empty the following dependency has been pulled in
## but can be declared for certainty nonetheless:
## * add a exec_depend tag for "message_runtime"
## * In this file (CMakeLists.txt):
## * add "message_generation" and every package in MSG_DEP_SET to
## find_package(catkin REQUIRED COMPONENTS ...)
## * add "message_runtime" and every package in MSG_DEP_SET to
## catkin_package(CATKIN_DEPENDS ...)
## * uncomment the add_*_files sections below as needed
## and list every .msg/.srv/.action file to be processed
## * uncomment the generate_messages entry below
## * add every package in MSG_DEP_SET to generate_messages(DEPENDENCIES ...)

## Generate messages in the 'msg' folder
add_message_files(
FILES
TargetObject.msg
)

## Generate services in the 'srv' folder
# add_service_files(
# FILES
# Service1.srv
# Service2.srv
# )

# Generate actions in the 'action' folder
add_action_files(
FILES
RefineObject.action
RefineAll.action
)

# Generate added messages and services with any dependencies listed here
generate_messages(
DEPENDENCIES
std_msgs
geometry_msgs
sensor_msgs
actionlib_msgs
)

################################################
## Declare ROS dynamic reconfigure parameters ##
################################################

## To declare and build dynamic reconfigure parameters within this
## package, follow these steps:
## * In the file package.xml:
## * add a build_depend and a exec_depend tag for "dynamic_reconfigure"
## * In this file (CMakeLists.txt):
## * add "dynamic_reconfigure" to
## find_package(catkin REQUIRED COMPONENTS ...)
## * uncomment the "generate_dynamic_reconfigure_options" section below
## and list every .cfg file to be processed

## Generate dynamic reconfigure parameters in the 'cfg' folder
# generate_dynamic_reconfigure_options(
# cfg/DynReconf1.cfg
# cfg/DynReconf2.cfg
# )

###################################
## catkin specific configuration ##
###################################
## The catkin_package macro generates cmake config files for your package
## Declare things to be passed to dependent projects
## INCLUDE_DIRS: uncomment this if your package contains header files
## LIBRARIES: libraries you create in this project that dependent projects also need
## CATKIN_DEPENDS: catkin_packages dependent projects also need
## DEPENDS: system dependencies of this project that dependent projects also need
# catkin_package(
# INCLUDE_DIRS include
# LIBRARIES diffdope_ros
# CATKIN_DEPENDS acitonlib actionlib_msgs rospy
# DEPENDS system_lib
# )

###########
## Build ##
###########

## Specify additional locations of header files
## Your package locations should be listed before other locations
# include_directories(
# include
# ${catkin_INCLUDE_DIRS}
# )

## Declare a C++ library
# add_library(${PROJECT_NAME}
# src/${PROJECT_NAME}/diffdope_ros.cpp
# )

## Add cmake target dependencies of the library
## as an example, code may need to be generated before libraries
## either from message generation or dynamic reconfigure
# add_dependencies(${PROJECT_NAME} ${${PROJECT_NAME}_EXPORTED_TARGETS} ${catkin_EXPORTED_TARGETS})

## Declare a C++ executable
## With catkin_make all packages are built within a single CMake context
## The recommended prefix ensures that target names across packages don't collide
# add_executable(${PROJECT_NAME}_node src/diffdope_ros_node.cpp)

## Rename C++ executable without prefix
## The above recommended prefix causes long target names, the following renames the
## target back to the shorter version for ease of user use
## e.g. "rosrun someones_pkg node" instead of "rosrun someones_pkg someones_pkg_node"
# set_target_properties(${PROJECT_NAME}_node PROPERTIES OUTPUT_NAME node PREFIX "")

## Add cmake target dependencies of the executable
## same as for the library above
# add_dependencies(${PROJECT_NAME}_node ${${PROJECT_NAME}_EXPORTED_TARGETS} ${catkin_EXPORTED_TARGETS})

## Specify libraries to link a library or executable target against
# target_link_libraries(${PROJECT_NAME}_node
# ${catkin_LIBRARIES}
# )

#############
## Install ##
#############

# all install targets should use catkin DESTINATION variables
# See http://ros.org/doc/api/catkin/html/adv_user_guide/variables.html

## Mark executable scripts (Python etc.) for installation
## in contrast to setup.py, you can choose the destination
catkin_install_python(PROGRAMS
scripts/server.py
scripts/refine.py
scripts/refine_continuous.py
DESTINATION ${CATKIN_PACKAGE_BIN_DESTINATION}
)

## Mark executables for installation
## See http://docs.ros.org/melodic/api/catkin/html/howto/format1/building_executables.html
# install(TARGETS ${PROJECT_NAME}_node
# RUNTIME DESTINATION ${CATKIN_PACKAGE_BIN_DESTINATION}
# )

## Mark libraries for installation
## See http://docs.ros.org/melodic/api/catkin/html/howto/format1/building_libraries.html
# install(TARGETS ${PROJECT_NAME}
# ARCHIVE DESTINATION ${CATKIN_PACKAGE_LIB_DESTINATION}
# LIBRARY DESTINATION ${CATKIN_PACKAGE_LIB_DESTINATION}
# RUNTIME DESTINATION ${CATKIN_GLOBAL_BIN_DESTINATION}
# )

## Mark cpp header files for installation
# install(DIRECTORY include/${PROJECT_NAME}/
# DESTINATION ${CATKIN_PACKAGE_INCLUDE_DESTINATION}
# FILES_MATCHING PATTERN "*.h"
# PATTERN ".svn" EXCLUDE
# )

## Mark other files for installation (e.g. launch and bag files, etc.)
# install(FILES
# # myfile1
# # myfile2
# DESTINATION ${CATKIN_PACKAGE_SHARE_DESTINATION}
# )

#############
## Testing ##
#############

## Add gtest based cpp test target and link libraries
# catkin_add_gtest(${PROJECT_NAME}-test test/test_diffdope_ros.cpp)
# if(TARGET ${PROJECT_NAME}-test)
# target_link_libraries(${PROJECT_NAME}-test ${PROJECT_NAME})
# endif()

## Add folders to be run by python nosetests
# catkin_add_nosetests(test)
8 changes: 8 additions & 0 deletions diffdope_ros/action/RefineAll.action
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
# Request
diffdope_ros/TargetObject[] target_objects
---
# Result
diffdope_ros/TargetObject[] refined_estimations
---
# Feedback
bool finished
8 changes: 8 additions & 0 deletions diffdope_ros/action/RefineObject.action
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
# Request
diffdope_ros/TargetObject target_object
---
# Result
diffdope_ros/TargetObject refined_estimation
---
# Feedback
bool finished
Loading