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

Vision pipeline #1134

Closed
wants to merge 11 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
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
3 changes: 3 additions & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
Expand Up @@ -23,3 +23,6 @@
[submodule "mil_common/perception/yolov7-ros"]
path = mil_common/perception/yolov7-ros
url = https://github.com/uf-mil/yolov7-ros.git
[submodule "mil_common/perception/vision_stack"]
path = mil_common/perception/vision_stack
url = https://github.com/uf-mil/vision_stack.git
4 changes: 3 additions & 1 deletion .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ repos:
rev: v1.32.0
hooks:
- id: yamllint
exclude: mil_common/perception/yoloros
- repo: https://github.com/psf/black
rev: 23.7.0
hooks:
Expand All @@ -31,7 +32,7 @@ repos:
rev: v0.9.0.5
hooks:
- id: shellcheck
exclude: ^docker|deprecated|NaviGator/simulation/VRX
exclude: ^docker|deprecated|NaviGator/simulation/VRX|mil_common/perception/yoloros
args: [--severity=warning, --exclude=SC1090]
- repo: https://github.com/scop/pre-commit-shfmt
rev: v3.7.0-1
Expand All @@ -44,6 +45,7 @@ repos:
hooks:
- id: ruff
args: [--fix, --exit-non-zero-on-fix]
exclude: mil_common/perception/yoloros
- repo: https://github.com/codespell-project/codespell
rev: v2.2.5
hooks:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
<rosparam file="$(find subjugator_launch)/config/path_localizer.yaml" command="load" />
</node>
</group>-->
<node pkg="subjugator_perception" type="vision_pipeline_test.py" name="vision_pipeline_test" />

<!-- TODO: Create weights file for sub-->
<arg name="weights" default="" />
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
from yoloros import Detector

Detector("robosub24").test_detection(conf_thres=0.77)
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
#!/usr/bin/env python3
import rospy
from image_geometry import PinholeCameraModel
from mil_ros_tools import (
Image_Subscriber,
)
from yoloros import Detector

# from vision_stack import VisionStack

__author__ = "Daniel Parra"


class ObjectDetectionTest:
def __init__(self):
camera = rospy.get_param("~image_topic", "/camera/front/right/image_rect_color")
self.detector = Detector("robosub24", device="cpu")

self.image_sub = Image_Subscriber(camera, self.detection_callback)
self.camera_info = self.image_sub.wait_for_camera_info()
assert self.camera_info is not None
self.cam = PinholeCameraModel()
self.cam.fromCameraInfo(self.camera_info)

def detection_callback(self, msg):
# Create Image from array
print("Detecting...")
self.detector.display_detection_ros_msg(msg, conf_thres=0.85)


if __name__ == "__main__":
rospy.init_node("vision_pipeline_test")
ObjectDetectionTest()
rospy.spin()
1 change: 1 addition & 0 deletions docs/software/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ Various documentation related to practices followed by the MIL Software team.
documentation_syntax
adding_documentation
help
vrx_2023
zobelisk
asyncio
rqt
Expand Down
64 changes: 64 additions & 0 deletions docs/software/vrx_2023.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
# VRX 2023

Thanks for your interest in working with the VRX tasks for 2023! We're happy to
have you participate in the competition!

There are some design changes for the competition this year that you need to be
aware of. First, VRX now defaults to supporting ROS 2, which is unfortunate for
us since we use ROS 1. But, don't be afraid! Thankfully, the VRX staff have built
a bridge between ROS 1 and ROS 2 that we can use to connect our submission with
their competition environment. This guide will help you get familiar with that
setup and how to work with VRX.

## Working with ROS 2

Your machine will have both ROS 1 and ROS 2 running on it. To work with two versions
of ROS, it's best to only source one version of ROS at a time.

### Installing ROS 2

To install ROS 2, run the `./scripts/install_ros2.sh` script. This will install
ROS 2, the ROS 1 to 2 bridge, and the bridge VRX messages packages.

### Working with ROS 1 and 2

Currently, the MIL installation will source `./scripts/setup.bash` each time you
open your terminal. While this works for most members and most applications, for
VRX this is no longer ideal. We recommend changing that line to this (or
something similar) such that you will be able to choose a version to run with each
new terminal:

```bash
noetic() {
source ~/catkin_ws/src/mil/scripts/setup.bash
}

humble() {
source ./ros2_humble/install/local_setup.bash
}
```

Then, in terminals where you want to run ROS 2, you can type `humble`. Likewise,
in terminals where you want to run ROS 1, run `noetic`.

## Bridging VRX

Because the VRX platform is built for ROS 2 and our current software focuses on
ROS 1, we will create a ROS 1 to 2 bridge to allow for communication. The bridge,
our ROS 1 code, and the VRX platform (in ROS 2) will all run on your host machine.

## Launching Missions

To run the entire the entire VRX simulation, you can `roslaunch`. This launches
the example world (a basic setup).

```bash
roslaunch navigator_launch vrx.launch --screen
```

Some arguments you may want to provide include:

* `run_task` - This flag allows you to run and get scored for a certain task.
An example argument includes `Navigation` (to run the navigation task). The
task runs the mission named `Vrx<your_argument>` (so in our case, it would
run `VrxNavigation`).
1 change: 1 addition & 0 deletions mil_common/perception/vision_stack
Submodule vision_stack added at 00ac8b
208 changes: 208 additions & 0 deletions mil_common/perception/yoloros/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,208 @@
cmake_minimum_required(VERSION 3.0.2)
project(mil_yolov7_pkg)

## 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
roscpp
rospy
sensor_msgs
std_msgs
vision_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
# Message1.msg
# Message2.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
# Action1.action
# Action2.action
# )

## Generate added messages and services with any dependencies listed here
# generate_messages(
# DEPENDENCIES
# sensor_msgs# std_msgs# vision_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 mil_yolov7_pkg
# CATKIN_DEPENDS roscpp rospy sensor_msgs std_msgs vision_msgs
# 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}/mil_yolov7_pkg.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/mil_yolov7_pkg_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/my_python_script
# 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_mil_yolov7_pkg.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)
Loading
Loading