From 8581b8a2d3a32b4c2dba01eaaaba915111e26ae4 Mon Sep 17 00:00:00 2001 From: madratman Date: Wed, 1 Apr 2020 09:54:37 -0700 Subject: [PATCH] [ros] delete incomplete python wrapper and doc page --- PythonClient/ros/car_image_raw.py | 53 ------------------------- PythonClient/ros/car_pose.py | 60 ----------------------------- PythonClient/ros/drone_image_raw.py | 54 -------------------------- PythonClient/ros/setup_path.py | 52 ------------------------- docs/ros.md | 58 ---------------------------- 5 files changed, 277 deletions(-) delete mode 100644 PythonClient/ros/car_image_raw.py delete mode 100644 PythonClient/ros/car_pose.py delete mode 100644 PythonClient/ros/drone_image_raw.py delete mode 100644 PythonClient/ros/setup_path.py delete mode 100644 docs/ros.md diff --git a/PythonClient/ros/car_image_raw.py b/PythonClient/ros/car_image_raw.py deleted file mode 100644 index 4ffe5bece3..0000000000 --- a/PythonClient/ros/car_image_raw.py +++ /dev/null @@ -1,53 +0,0 @@ -#!/usr/bin/env python - -# Example ROS node for publishing AirSim images. - -import setup_path -import airsim - -import rospy - -# ROS Image message -from sensor_msgs.msg import Image - -def airpub(): - pub = rospy.Publisher("airsim/image_raw", Image, queue_size=1) - rospy.init_node('image_raw', anonymous=True) - rate = rospy.Rate(10) # 10hz - - # connect to the AirSim simulator - client = airsim.CarClient() - client.confirmConnection() - - while not rospy.is_shutdown(): - # get camera images from the car - responses = client.simGetImages([ - airsim.ImageRequest("1", airsim.ImageType.Scene, False, False)]) #scene vision image in uncompressed RGB array - - for response in responses: - img_rgb_string = response.image_data_uint8 - - # Populate image message - msg=Image() - msg.header.stamp = rospy.Time.now() - msg.header.frame_id = "frameId" - msg.encoding = "rgb8" - msg.height = 360 # resolution should match values in settings.json - msg.width = 640 - msg.data = img_rgb_string - msg.is_bigendian = 0 - msg.step = msg.width * 3 - - # log time and size of published image - rospy.loginfo(len(response.image_data_uint8)) - # publish image message - pub.publish(msg) - # sleep until next cycle - rate.sleep() - - -if __name__ == '__main__': - try: - airpub() - except rospy.ROSInterruptException: - pass diff --git a/PythonClient/ros/car_pose.py b/PythonClient/ros/car_pose.py deleted file mode 100644 index 789a635e35..0000000000 --- a/PythonClient/ros/car_pose.py +++ /dev/null @@ -1,60 +0,0 @@ -#!/usr/bin/env python - -import setup_path -import airsim - -import rospy -import tf -from std_msgs.msg import String -from geometry_msgs.msg import PoseStamped - -import time - - -def airpub(): - pub = rospy.Publisher("airsimPose", PoseStamped, queue_size=1) - rospy.init_node('airpub', anonymous=True) - rate = rospy.Rate(10) # 10hz - - # connect to the AirSim simulator - client = airsim.CarClient() - client.confirmConnection() - -# start = time.time() - - - while not rospy.is_shutdown(): - - # get state of the car - car_state = client.getCarState() - pos = car_state.kinematics_estimated.position - orientation = car_state.kinematics_estimated.orientation -# milliseconds = (time.time() - start) * 1000 - - - # populate PoseStamped ros message - simPose = PoseStamped() - simPose.pose.position.x = pos.x_val - simPose.pose.position.y = pos.y_val - simPose.pose.position.z = pos.z_val - simPose.pose.orientation.w = orientation.w_val - simPose.pose.orientation.x = orientation.x_val - simPose.pose.orientation.y = orientation.y_val - simPose.pose.orientation.z = orientation.z_val - simPose.header.stamp = rospy.Time.now() - simPose.header.seq = 1 - simPose.header.frame_id = "simFrame" - - # log PoseStamped message - rospy.loginfo(simPose) - #publish PoseStamped message - pub.publish(simPose) - # sleeps until next cycle - rate.sleep() - - -if __name__ == '__main__': - try: - airpub() - except rospy.ROSInterruptException: - pass diff --git a/PythonClient/ros/drone_image_raw.py b/PythonClient/ros/drone_image_raw.py deleted file mode 100644 index b41ba6248c..0000000000 --- a/PythonClient/ros/drone_image_raw.py +++ /dev/null @@ -1,54 +0,0 @@ -#!/usr/bin/env python - -# Example ROS node for publishing AirSim images. - -# AirSim Python API -import setup_path -import airsim - -import rospy - -# ROS Image message -from sensor_msgs.msg import Image - -def airpub(): - pub = rospy.Publisher("airsim/image_raw", Image, queue_size=1) - rospy.init_node('image_raw', anonymous=True) - rate = rospy.Rate(10) # 10hz - - # connect to the AirSim simulator - client = airsim.MultirotorClient() - client.confirmConnection() - - while not rospy.is_shutdown(): - # get camera images from the car - responses = client.simGetImages([ - airsim.ImageRequest("1", airsim.ImageType.Scene, False, False)]) #scene vision image in uncompressed RGB array - - for response in responses: - img_rgb_string = response.image_data_uint8 - - # Populate image message - msg=Image() - msg.header.stamp = rospy.Time.now() - msg.header.frame_id = "frameId" - msg.encoding = "rgb8" - msg.height = 360 # resolution should match values in settings.json - msg.width = 640 - msg.data = img_rgb_string - msg.is_bigendian = 0 - msg.step = msg.width * 3 - - # log time and size of published image - rospy.loginfo(len(response.image_data_uint8)) - # publish image message - pub.publish(msg) - # sleep until next cycle - rate.sleep() - - -if __name__ == '__main__': - try: - airpub() - except rospy.ROSInterruptException: - pass diff --git a/PythonClient/ros/setup_path.py b/PythonClient/ros/setup_path.py deleted file mode 100644 index 362113fea8..0000000000 --- a/PythonClient/ros/setup_path.py +++ /dev/null @@ -1,52 +0,0 @@ -# Import this module to automatically setup path to local airsim module -# This module first tries to see if airsim module is installed via pip -# If it does then we don't do anything else -# Else we look up grand-parent folder to see if it has airsim folder -# and if it does then we add that in sys.path - -import os,sys,inspect,logging - -#this class simply tries to see if airsim -class SetupPath: - @staticmethod - def getDirLevels(path): - path_norm = os.path.normpath(path) - return len(path_norm.split(os.sep)) - - @staticmethod - def getCurrentPath(): - cur_filepath = os.path.abspath(inspect.getfile(inspect.currentframe())) - return os.path.dirname(cur_filepath) - - @staticmethod - def getGrandParentDir(): - cur_path = SetupPath.getCurrentPath() - if SetupPath.getDirLevels(cur_path) >= 2: - return os.path.dirname(os.path.dirname(cur_path)) - return '' - - @staticmethod - def getParentDir(): - cur_path = SetupPath.getCurrentPath() - if SetupPath.getDirLevels(cur_path) >= 1: - return os.path.dirname(cur_path) - return '' - - @staticmethod - def addAirSimModulePath(): - # if airsim module is installed then don't do anything else - #import pkgutil - #airsim_loader = pkgutil.find_loader('airsim') - #if airsim_loader is not None: - # return - - parent = SetupPath.getParentDir() - if parent != '': - airsim_path = os.path.join(parent, 'airsim') - client_path = os.path.join(airsim_path, 'client.py') - if os.path.exists(client_path): - sys.path.insert(0, parent) - else: - logging.warning("airsim module not found in parent folder. Using installed package (pip install airsim).") - -SetupPath.addAirSimModulePath() diff --git a/docs/ros.md b/docs/ros.md deleted file mode 100644 index 690e4ef317..0000000000 --- a/docs/ros.md +++ /dev/null @@ -1,58 +0,0 @@ -# How to use AirSim with Robot Operating System (ROS) - -AirSim and ROS can be integrated using C++ or Python. Some example ROS nodes are provided demonstrating how to publish data from AirSim as ROS topics. - -# Python - -## Prerequisites - -These instructions are for Ubuntu 16.04, ROS Kinetic, UE4 4.22 or higher, and latest AirSim release. -You should have these components installed and working before proceeding - -## Setup - - -### Create a new ROS package in your catkin workspace following these instructions. - -Create a new ROS package called airsim or whatever you like. - -[Create ROS package](http://wiki.ros.org/ROS/Tutorials/CreatingPackage) - -If you don't already have a catkin workspace, you should first work through the ROS beginner tutorials. - -### Add AirSim ROS node examples to ROS package - -In the ROS package directory you made, copy the ros examples from the AirSim/PythonClient directory to your ROS package. Change the code below to match your AirSim and catkin workspace paths. - -``` -# copy package -mkdir -p ../catkin_ws/src/airsim/scripts/airsim -cp AirSim/PythonClient/airsim/*.py ../catkin_ws/src/airsim/scripts/airsim - -# copy ROS examples -cp AirSim/PythonClient/ros/*.py ../catkin_ws/src/airsim/scripts -``` - - -### Build ROS AirSim package - -Change directory to your top level catkin workspace folder i.e. ```cd ~/catkin_ws``` and run ```catkin_make``` -This will build the airsim package. Next, run ```source devel/setup.bash``` so ROS can find the new package. -You can add this command to your ~/.bashrc to load your catkin workspace automatically. - -## How to run ROS AirSim nodes - -First make sure UE4 is running an airsim project, the car or drone should be selected, and the simulations is playing. -Examples support car or drone. Make sure to have the correct vehicle for the ros example running. - -The example airsim nodes can be run using ```rosrun airsim example_name.py``` The output of the node -can be viewed in another terminal by running ```rostopic echo /example_name``` You can view a list of the -topics currently published via tab completion after typing ```rostopic echo``` in the terminal. -Rviz is a useful visualization tool that can display the published data. - -### Troubleshooting - -In the case of ```rosrun airsim example_name.py``` returning ```Couldn't find executable named...``` you may ```chmod +x example_name.py``` to tell the system that this is executable. - - -# C++ (coming soon)