Skip to content
Open
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
42 changes: 42 additions & 0 deletions bwi_elev_detection/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
# Compiled Object files
*.slo
*.lo
*.o
*.obj

# Precompiled Headers
*.gch
*.pch

# Compiled Dynamic libraries
*.so
*.dylib
*.dll

# Fortran module files
*.mod

# Compiled Static libraries
*.lai
*.la
*.a
*.lib

# Executables
*.exe
*.out
*.app

build/*
Project
CMakeFiles/*
src/CMakeFiles/*
src/audio_sandbox/CMakeFiles/*
src/audio_sandbox/Makefile
**.cmake
CMakeCache.txt
Makefile
src/Makefile

#Audacity files
audacity/
173 changes: 173 additions & 0 deletions bwi_elev_detection/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,173 @@
cmake_minimum_required(VERSION 2.8.3)
project(elevators)

## 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 std_msgs genmsg cv_bridge)
find_package(OpenCV REQUIRED)
find_package(message_generation REQUIRED)
find_package(std_msgs REQUIRED)
find_package(cv_bridge REQUIRED)

## 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 and a run_depend tag for each package in MSG_DEP_SET
## * If MSG_DEP_SET isn't empty the following dependencies might have been
## pulled in transitively but can be declared for certainty nonetheless:
## * add a build_depend tag for "message_generation"
## * add a run_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
fft_col.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
std_msgs # Or other packages containing msgs
)

###################################
## 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 you 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 src
LIBRARIES audio_sandbox
# CATKIN_DEPENDS other_catkin_pkg
# DEPENDS system_lib
)

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

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

## Declare a cpp library
# add_library(elevators
# src/${PROJECT_NAME}/elevators.cpp
# )

include(src/audio_sandbox/CMakeLists.txt)
add_subdirectory(src)


## Declare a cpp executable
add_executable(elevator_node ${exec_SRC})
add_executable(fft_node src/audio_sandbox/src/ROSInterface.cpp)

## Add cmake target dependencies of the executable/library
## as an example, message headers may need to be generated before nodes
add_dependencies(elevator_node elevators_generate_messages_cpp)
add_dependencies(fft_node elevators_generate_messages_cpp)

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

target_link_libraries(fft_node
${catkin_LIBRARIES}
${ALSA_LIBRARY}
${FFTW_LIBRARIES}
${OpenCV_LIBS}
)

#############
## 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
# install(PROGRAMS
# scripts/my_python_script
# DESTINATION ${CATKIN_PACKAGE_BIN_DESTINATION}
# )

## Mark executables and/or libraries for installation
# install(TARGETS elevators elevators_node
# ARCHIVE DESTINATION ${CATKIN_PACKAGE_LIB_DESTINATION}
# LIBRARY DESTINATION ${CATKIN_PACKAGE_LIB_DESTINATION}
# RUNTIME DESTINATION ${CATKIN_PACKAGE_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_elevators.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)
7 changes: 7 additions & 0 deletions bwi_elev_detection/data/config/demo.cfg
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
image_topic=camera/image_raw
ideal=8 175 175
range=10 75 85
convert_hsv=false
area_threshold=50 200
strictness=10
flip_dir=true
3 changes: 3 additions & 0 deletions bwi_elev_detection/data/config/elevator_settings.cfg
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
image_topic=usb_cam/image_raw
range=100 100 100
ideal=255 255 255
4 changes: 4 additions & 0 deletions bwi_elev_detection/data/config/paper_settings.cfg
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
image_topic=usb_cam/image_raw
ideal=133 48 189
range=100 100 100
convert_hsv=false
7 changes: 7 additions & 0 deletions bwi_elev_detection/data/config/paper_settings_cam.cfg
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
image_topic=camera/image_raw
ideal=8 175 175
range=10 75 85
convert_hsv=false
area_threshold=50 200
strictness=10
flip_dir=true
4 changes: 4 additions & 0 deletions bwi_elev_detection/launch/camera.launch
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
<launch>
<include file="$(find elevators)/launch/fft_launch.launch"/>
<include file="$(find segbot_sensors)/launch/ptgrey/usbcam.launch"/>
</launch>
9 changes: 9 additions & 0 deletions bwi_elev_detection/launch/fft_launch.launch
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
<launch>
<include file="$(find audio_capture)/launch/capture.launch"/>
<node
name="fft_publisher"
pkg="elevators"
type="fft_node"
args="false"
/>
</launch>
10 changes: 10 additions & 0 deletions bwi_elev_detection/launch/sensors.launch
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
<launch>
<include file="$(find elevators)/launch/fft_launch.launch"/>
<include file="$(find segbot_sensors)/launch/ptgrey/usbcam.launch"/>
<node
name="elevator_sensors"
pkg="elevators"
type="elevator_node"
args="/home/fri/brian_ws/src/elevators/data/config/paper_settings.cfg"
/>
</launch>
5 changes: 5 additions & 0 deletions bwi_elev_detection/launch/usb_cam/.rosinstall
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# IT IS UNLIKELY YOU WANT TO EDIT THIS FILE BY HAND,
# UNLESS FOR REMOVING ENTRIES.
# IF YOU WANT TO CHANGE THE ROS ENVIRONMENT VARIABLES
# USE THE rosinstall TOOL INSTEAD.
# IF YOU CHANGE IT, USE rosinstall FOR THE CHANGES TO TAKE EFFECT
14 changes: 14 additions & 0 deletions bwi_elev_detection/launch/webcam.launch
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
<launch>
<node name="usb_cam" pkg="usb_cam" type="usb_cam_node" >
<param name="video_device" value="/dev/video0" />
<param name="image_width" value="640" />
<param name="image_height" value="480" />
<param name="pixel_format" value="mjpeg" />
<param name="camera_frame_id" value="usb_cam" />
<param name="io_method" value="mmap"/>
</node>
<node name="image_view" pkg="image_view" type="image_view" respawn="false" output="screen">
<remap from="image" to="/usb_cam/image_raw"/>
<param name="autosize" value="true" />
</node>
</launch>
1 change: 1 addition & 0 deletions bwi_elev_detection/msg/fft_col.msg
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
float64[] data
56 changes: 56 additions & 0 deletions bwi_elev_detection/package.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
<?xml version="1.0"?>
<package>
<name>elevators</name>
<version>0.0.0</version>
<description>The elevators package</description>

<!-- One maintainer tag required, multiple allowed, one person per tag -->
<!-- Example: -->
<!-- <maintainer email="[email protected]">Jane Doe</maintainer> -->
<maintainer email="[email protected]">Brian Wang</maintainer>


<!-- One license tag required, multiple allowed, one license per tag -->
<!-- Commonly used license strings: -->
<!-- BSD, MIT, Boost Software License, GPLv2, GPLv3, LGPLv2.1, LGPLv3 -->
<license>TODO</license>


<!-- Url tags are optional, but mutiple are allowed, one per tag -->
<!-- Optional attribute type can be: website, bugtracker, or repository -->
<!-- Example: -->
<!-- <url type="website">http://wiki.ros.org/elevators</url> -->


<!-- Author tags are optional, mutiple are allowed, one per tag -->
<!-- Authors do not have to be maintianers, but could be -->
<!-- Example: -->
<!-- <author email="[email protected]">Jane Doe</author> -->


<!-- The *_depend tags are used to specify dependencies -->
<!-- Dependencies can be catkin packages or system dependencies -->
<!-- Examples: -->
<!-- Use build_depend for packages you need at compile time: -->
<!-- <build_depend>message_generation</build_depend> -->
<!-- Use buildtool_depend for build tool packages: -->
<!-- <buildtool_depend>catkin</buildtool_depend> -->
<!-- Use run_depend for packages you need at runtime: -->
<!-- <run_depend>message_runtime</run_depend> -->
<!-- Use test_depend for packages you need only for testing: -->
<!-- <test_depend>gtest</test_depend> -->
<buildtool_depend>catkin</buildtool_depend>
<build_depend>cv_bridge</build_depend>

<run_depend>cv_bridge</run_depend>


<!-- The export tag contains other, unspecified, tags -->
<export>
<!-- You can specify that this package is a metapackage here: -->
<!-- <metapackage/> -->

<!-- Other tools can request additional information be placed here -->

</export>
</package>
6 changes: 6 additions & 0 deletions bwi_elev_detection/src/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
SET( exec_SRC ${exec_SRC}
${CMAKE_CURRENT_SOURCE_DIR}/main.cpp
${CMAKE_CURRENT_SOURCE_DIR}/SoundInterface.cpp
${CMAKE_CURRENT_SOURCE_DIR}/CameraInterface.cpp
${CMAKE_CURRENT_SOURCE_DIR}/CameraController.cpp
PARENT_SCOPE)
29 changes: 29 additions & 0 deletions bwi_elev_detection/src/CameraController.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
#include "lib/CameraController.h"

void CameraController::moveTo(float f) {
std_msgs::Float32 msg;
msg.data = f;

publisher->publish(msg);
}

void CameraController::wait(int ms) {
usleep(1000 * ms);
}

void CameraController::alternate() {
if (currentPosition >= 0)
moveTo(range[0]);
else
moveTo(range[1]);
}

void CameraController::status_callback(const std_msgs::Float32::ConstPtr &msg) {
currentPosition = msg->data;
if (currentPosition <= range[0] + 0.05 || currentPosition >= range[1] - 0.05)
counter++;
if (counter >= 60) {
counter = 0;
alternate();
}
}
Loading