Coder Social home page Coder Social logo

sensors_for_ros's Introduction

Sensors for ROS

Sensors for ROS is an app that publishes sensor data from an Android device onto ROS 2 topics. Currently it supports ROS Humble.

Supported sensors

  • Accelerometer
  • Barometer
  • Camera(s)
  • Gyroscope
  • Illuminance
  • Magnetometer

This app is built using only CMake and C++. It does not use Java or Kotlin. ROS 2 packages up to rclcpp are cross-compiled. A successful build produces an .apk file called sensors_for_ros.apk in the build directory.

Inspiration

These projects were extremely helpful, and used as a reference for this one:

How to install it

Currently the only way to get Sensors for ROS is to build it from source. It is not yet available on Google's app store.

How to build it from source

You do not need ROS installed on your machine to build the Sensors for ROS app. However, it's needed to use the sensor data being published by your Android device. Follow these instructions to install ROS Humble.

Computer setup

Download the Android SDK "Command-line tools only" version. Other versions may work, but this is the minimum needed.

Make a folder for the SDK and extract the archive.

mkdir ~/android-sdk
cd ~/android-sdk
unzip ~/Downloads/commandlinetools-linux-8512546_latest.zip

Install some Android SDK components

./cmdline-tools/bin/sdkmanager --sdk_root=$HOME/android-sdk "build-tools;33.0.0" "platforms;android-30" "ndk;25.1.8937393"

Install adb

# If you're using Ubuntu
sudo apt install adb android-sdk-platform-tools-common
# If you're using Fedora
sudo dnf install android-tools

Install catkin-pkg, empy, and lark

# If you're using ubuntu
sudo apt install python3-catkin-pkg-modules python3-empy python3-lark-parser
# If you're using Fedora
sudo dnf install python3-catkin_pkg python3-empy python3-lark-parser

You may need to do additional setup to use adb. Follow the Set up a device for development instructions if you're using Ubuntu, or follow the instructions in this thread if you're using Fedora.

Create debug keys

You'll need to install openjdk to get access to keytool.

sudo apt install openjdk-11-jre-headless

Create a debug keystore

mkdir ~/.android
keytool -genkey -v -keystore ~/.android/debug.keystore -alias adb_debug_key -keyalg RSA -keysize 2048 -validity 10000 -storepass android -keypass android

Clone the repo

The official repo is sloretz/sensors_for_ros.

git clone https://github.com/sloretz/sensors_for_ros.git

Next initialize the git submodules.

git submodule init
git submodule update

Download ROS dependencies

Use vcstool to download the ROS packages we need to cross compile into the deps folder.

vcs import --input ros.repos deps/

Building the App

Build the software

mkdir build
cd build
cmake ../ -DANDROID_HOME=$HOME/android-sdk/
make -j`nproc`

Installing the App on your Android Device

Install the APK in the build directory onto a device.

adb install -r sensors_for_ros.apk

Development tips

Use logcat to view the logs from the app

adb logcat

Sometimes you may want to try out a permission without writing the code to request it. The app must be installed, but not running already for this command to work.

adb shell pm grant com.github.sloretz.sensors_for_ros android.permission.CAMERA

The main activity can be started directly from the CLI

adb shell am start -n com.github.sloretz.sensors_for_ros/android.app.NativeActivity

Getting stack traces

adb logcat | $HOME/android-sdk/ndk/*/ndk-stack -sym lib/arm64-v8a/

Random lessons

During development I documented problems I encountered and fixes for them in the Problems Encountered document.

sensors_for_ros's People

Contributors

sloretz avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.