Receiving and publishing data from Android via ROS 2
Once you have one Android application sending data via socket, you will be able to publish (talker) and subscriber (listener) via ROS 2. In this repository, you can find a simple Android application to use as example.
The video tutorial is available here.
cd $HOME
git clone https://github.com/mirellameelo/ROS_2_ANDROID.git
- Open your Android Studio
- Open the project "my_places"
- Go to app->java->com.example.myplaces->MainActivity and CHANGE the IP to your computer IP (you can verify it when running ifconfig in the terminal)
- Run the application in your phone
- Open the terminal and run:
cd $HOME/ROS_2_ANDROID/src
./a.out
Now, every time you click the connection button, you'll be able to see a variable incrementing. This indicates that the socket connection its working fine, and you're able to go to the next steps.
Open the terminal and source the ROS:
source /opt/ros/dashing/setup.bash
# Build the packages
cd $HOME/ROS_2_ANDROID
colcon build --packages-select cpp_pubsub
- Open your Android Studio
- Open the project "my_places"
- Go to app->java->com.example.myplaces->MainActivity and CHANGE the IP to your computer IP (you can verify it when running ifconfig in the terminal)
- Run the application in your phone
Open two terminals and source the cpp_pubsub setup file in both.
source $HOME/ROS_2_ANDROID/install/setup.bash
Terminal_1: Run the talker
#run the talker
ros2 run cpp_pubsub talker
The publisher now is waiting for data comming via Socket. Terminal_2: Run the listener
# run the listener
ros2 run cpp_pubsub listener