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

Smart Home: Camera viewing and input streaming #128

Closed
wants to merge 4 commits into from

Conversation

garbear
Copy link
Owner

@garbear garbear commented Mar 24, 2022

Description

This PR introduces a new paradigm of Kodi usage: smart home interaction and control. Camera viewing and input streaming are provided as two initial use cases.

The approach I've taken with smart home is a bit unique: I built on ROS 2. While this introduces some heavy overhead, building on an industrial decentralized communication framework allows for scalability to virtually unlimited low power smart home devices. My smart home's computation graph is currently at 8 Linux nodes and 3 Arduino nodes and growing.

Alongside this PR is a repo devoted to my smart home OS: https://github.com/eigendude/OASIS.

OASIS provides a complete ROS 2 stack for computer vision, input streaming and general automation. It also provides a complete implementation of the Firmata protocol for communicating with Arduinos, with additional support for temperature and humidity sensors, I2C, servos, sonar, SPI, stepper motors, and 4-wire CPU fans.

Camera viewing

A new cameraview control is introduced. It takes a parameter, the ROS image topic to subscribe to. For testing, I created the following SmartHome.xml window:

<?xml version="1.0" encoding="UTF-8"?>
<window>
	<controls>
		<control type="cameraview">
			<width>50%</width>
			<height>50%</height>
			<topic>/oasis/netbook/image_raw</topic>
		</control>
		<control type="cameraview">
			<left>50%</left>
			<height>50%</height>
			<topic>/oasis/lenovo/image_raw</topic>
		</control>
		<control type="cameraview">
			<width>50%</width>
			<top>50%</top>
			<topic>/oasis/netbook/foreground</topic>
		</control>
		<control type="cameraview">
			<left>50%</left>
			<top>50%</top>
			<topic>/oasis/lenovo/foreground</topic>
		</control>
	</controls>
</window>

This window creates a 2x2 matrix. The top two cameraview controls are the direct output of two laptop cameras. The bottom two cameraview controls are the output of a rudimentary person detector using a background subtraction library applied to the camera feeds.

Screenshot of the above window (not bad for low light netbook cameras):

Not very good person tracker

I forked the Kinect 2 driver and ported it to ROS 2. You can see depth registration working, but I'll probably do skeletal tracking on the 2D image via MediaPipe as a person detection solution.

Smart Home Camera View

Input streaming

The second use case is input streaming for smart home control. Kodi advertises two ROS topics:

  • /peripherals - A list of attached input peripherals, which is all controllers plus the keyboard and mouse
  • /input - A topic that publishes the state of controllers

Kodi also provides a ROS service:

  • /capture_input - Calling this service causes a peripheral's input to be captured and sent over the input topic.

In my home, I'm using a PS controller to drive my childhood Lego train. The input is captured by Kodi running on my NAS with a Bluetooth dongle, and sent to a Raspberry Pi with an Ardiuno and a robotics motor controller that drives the train's 9V motors.

Lego Train via PS4 Controller

Motivation and context

Smart Home!!!!

How has this been tested?

I've been using Kodi as part of my smart home setup since May of 2021. ROS 2 is so robust that my system barely goes down.

What is the effect on users?

  • Smart Home!!!

Related PRs

Depends on:

Types of change

  • Bug fix (non-breaking change which fixes an issue)
  • Clean up (non-breaking change which removes non-working, unmaintained functionality)
  • Improvement (non-breaking change which improves existing functionality)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that will cause existing functionality to change)
  • Cosmetic change (non-breaking change that doesn't touch code)
  • None of the above (please explain below)

rcl_interfaces
rclcpp
rmw
sensor_msgs
Copy link

Choose a reason for hiding this comment

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

those must be optional, so we need an option ENABLE_SMARTHOME

if(CMAKE_GENERATOR MATCHES Makefile)
add_custom_target(uninstall COMMAND ${CMAKE_COMMAND} -P ${CMAKE_SOURCE_DIR}/cmake/scripts/common/Uninstall.cmake)
set_target_properties(uninstall PROPERTIES FOLDER "Build Utilities")
endif()
Copy link

Choose a reason for hiding this comment

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

why is this removed?

@@ -332,7 +332,9 @@ macro(export_dep)
set(SYSTEM_INCLUDES ${SYSTEM_INCLUDES} PARENT_SCOPE)
set(DEPLIBS ${DEPLIBS} PARENT_SCOPE)
set(DEP_DEFINES ${DEP_DEFINES} PARENT_SCOPE)
set(${dep}_FOUND ${${dep}_FOUND} PARENT_SCOPE)
Copy link

Choose a reason for hiding this comment

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

why do you need this? Please use ${depup} like all other depends

list(APPEND DEPLIBS ${${depup}_LIBRARIES})
list(APPEND DEP_DEFINES ${${dep}_DEFINITIONS})
Copy link

Choose a reason for hiding this comment

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

same as above, all those shouldn't be needed

@garbear
Copy link
Owner Author

garbear commented Mar 24, 2022

I'm very much building a stable system and then not touching it. Suggestions welcome but I don't currently have plans for this code.

@garbear garbear force-pushed the smarthome-features branch from d90c088 to 4928dc1 Compare March 24, 2022 10:01
garbear added 4 commits March 24, 2022 03:21
Error was:

  CMake Error at CMakeLists.txt:479 (add_custom_target):
    add_custom_target cannot create target "uninstall" because another target
    with the same name already exists.  The existing target is a custom target
    created in source directory.  See documentation for policy CMP0002 for
    more details.
@garbear
Copy link
Owner Author

garbear commented Mar 24, 2022

PR sent upstream, and it drops the some of the [temp] commits.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants