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

Unity: Placeholder functions for compilation #2514

Merged
merged 3 commits into from
Apr 2, 2020
Merged
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
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -358,11 +358,14 @@ xcuserdata/
!*.xcworkspace/contents.xcworkspacedata
/*.gcno

# Unity
/Unity/UnityDemo/Library
/Unity/UnityDemo/Assembly-CSharp.csproj
/Unity/UnityDemo/UnityDemo.sln
/Unity/UnityDemo/Logs/
/Unity/UnityDemo/Assets/Plugins/AirsimWrapper.dll
/Unity/UnityDemo/Assets/Plugins/libAirsimWrapper.so
/Unity/linux-build/

# ROS
ros/.catkin_tools/
Expand Down
8 changes: 5 additions & 3 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ before_install:
sudo apt-get update;
sudo apt-get -y install git wget unzip;
sudo apt-get -y install build-essential software-properties-common cmake rsync libboost-all-dev;
elif [[ "$TRAVIS_OS_NAME" == "osx" ]] && [[ "$TOOL" == "cmake" ]]; then
elif [[ "$TRAVIS_OS_NAME" == "osx" ]]; then
echo "No before_install actions for OSX";
elif [[ "$TRAVIS_OS_NAME" == "windows" ]]; then
choco install visualstudio2019buildtools --package-parameters "--includeRecommended --includeOptional";
Expand All @@ -39,7 +39,8 @@ script:
- if [[ "$TRAVIS_OS_NAME" == "linux" ]]; then
./setup.sh;
./build.sh;
cd Unity && ./build.sh 2> Unity_error.txt || (tail -n 100 Unity_error.txt && exit 1);
echo "Starting Unity Build!";
cd Unity && ./build.sh 2> Unity_error.txt || ((cat Unity_error.txt | grep -i "error:" -B 10 -A 10) && exit 1);
elif [[ "$TRAVIS_OS_NAME" == "windows" ]]; then
export PATH=$MSBUILD_PATH:$PATH_FIX:$PATH;
cmd.exe //C 'C:\Program Files (x86)\Microsoft Visual Studio\2019\BuildTools\VC\Auxiliary\Build\vcvarsall.bat' amd64 '&&'
Expand All @@ -48,5 +49,6 @@ script:
elif [[ "$TRAVIS_OS_NAME" == "osx" ]]; then
./setup.sh;
./build.sh;
cd Unity && ./build.sh 2> Unity_error.txt || (tail -n 100 Unity_error.txt && exit 1);
echo "Starting Unity Build!";
cd Unity && ./build.sh 2> Unity_error.txt || ((cat Unity_error.txt | grep -i "error:" -B 10 -A 10) && exit 1);
fi
65 changes: 65 additions & 0 deletions Unity/AirLibWrapper/AirsimWrapper/Source/WorldSimApi.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,14 @@ void WorldSimApi::printLogMessage(const std::string& message, const std::string&
PrintLogMessage(message.c_str(), message_param.c_str(), vehicle_name_.c_str(), severity);
}

std::unique_ptr<std::vector<std::string>> WorldSimApi::swapTextures(const std::string& tag, int tex_id, int component_id, int material_id)
{
std::unique_ptr<std::vector<std::string>> result;
throw std::invalid_argument(common_utils::Utils::stringf(
"swapTextures is not supported on unity").c_str());
return result;
}

std::vector<std::string> WorldSimApi::listSceneObjects(const std::string& name_regex) const
{
std::vector<std::string> result;
Expand Down Expand Up @@ -84,4 +92,61 @@ void WorldSimApi::setWeatherParameter(WeatherParameter param, float val)
//TODO: implement weather for Unity
}

//----------------Plotting APIs-----------/
void WorldSimApi::simFlushPersistentMarkers()
{
throw std::invalid_argument(common_utils::Utils::stringf(
"simFlushPersistentMarkers is not supported on unity").c_str());
}

void WorldSimApi::simPlotPoints(const std::vector<Vector3r>& points, const std::vector<float>& color_rgba, float size, float duration, bool is_persistent)
{
throw std::invalid_argument(common_utils::Utils::stringf(
"simPlotPoints is not supported on unity").c_str());
}

void WorldSimApi::simPlotLineStrip(const std::vector<Vector3r>& points, const std::vector<float>& color_rgba, float thickness, float duration, bool is_persistent)
{
throw std::invalid_argument(common_utils::Utils::stringf(
"simPlotLineStrip is not supported on unity").c_str());
}

void WorldSimApi::simPlotLineList(const std::vector<Vector3r>& points, const std::vector<float>& color_rgba, float thickness, float duration, bool is_persistent)
{
throw std::invalid_argument(common_utils::Utils::stringf(
"simPlotLineList is not supported on unity").c_str());
}

void WorldSimApi::simPlotArrows(const std::vector<Vector3r>& points_start, const std::vector<Vector3r>& points_end, const std::vector<float>& color_rgba, float thickness, float arrow_size, float duration, bool is_persistent)
{
throw std::invalid_argument(common_utils::Utils::stringf(
"simPlotArrows is not supported on unity").c_str());
}

void WorldSimApi::simPlotStrings(const std::vector<std::string>& strings, const std::vector<Vector3r>& positions, float scale, const std::vector<float>& color_rgba, float duration)
{
throw std::invalid_argument(common_utils::Utils::stringf(
"simPlotStrings is not supported on unity").c_str());
}

void WorldSimApi::simPlotTransforms(const std::vector<Pose>& poses, float scale, float thickness, float duration, bool is_persistent)
{
throw std::invalid_argument(common_utils::Utils::stringf(
"simPlotTransforms is not supported on unity").c_str());
}

void WorldSimApi::simPlotTransformsWithNames(const std::vector<Pose>& poses, const std::vector<std::string>& names, float tf_scale, float tf_thickness, float text_scale, const std::vector<float>& text_color_rgba, float duration)
{
throw std::invalid_argument(common_utils::Utils::stringf(
"simPlotTransformsWithNames is not supported on unity").c_str());
}

std::vector<WorldSimApi::MeshPositionVertexBuffersResponse> WorldSimApi::getMeshPositionVertexBuffers() const
{
std::vector<MeshPositionVertexBuffersResponse> result;
throw std::invalid_argument(common_utils::Utils::stringf(
"getMeshPositionVertexBuffers is not supported on unity").c_str());
return result;
}

#pragma endregion
21 changes: 17 additions & 4 deletions Unity/AirLibWrapper/AirsimWrapper/Source/WorldSimApi.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,29 +8,42 @@ class WorldSimApi : public msr::airlib::WorldSimApiBase
{
public:
typedef msr::airlib::Pose Pose;
typedef msr::airlib::Vector3r Vector3r;
typedef msr::airlib::MeshPositionVertexBuffersResponse MeshPositionVertexBuffersResponse;

public:
WorldSimApi(SimModeBase* simmode, std::string vehicle_name);
virtual ~WorldSimApi();
virtual bool isPaused() const override;
virtual void reset() override;
virtual void pause(bool is_paused) override;
virtual void continueForTime(double seconds) override;
virtual void setTimeOfDay(bool is_enabled, const std::string& start_datetime, bool is_start_datetime_dst,
virtual void setTimeOfDay(bool is_enabled, const std::string& start_datetime, bool is_start_datetime_dst,
float celestial_clock_speed, float update_interval_secs, bool move_sun);

virtual void enableWeather(bool enable);
virtual void setWeatherParameter(WeatherParameter param, float val);
virtual void enableWeather(bool enable) override;
virtual void setWeatherParameter(WeatherParameter param, float val) override;

virtual bool setSegmentationObjectID(const std::string& mesh_name, int object_id, bool is_name_regex = false) override;
virtual int getSegmentationObjectID(const std::string& mesh_name) const override;
virtual void printLogMessage(const std::string& message,
const std::string& message_param = "", unsigned char severity = 0) override;

virtual std::unique_ptr<std::vector<std::string>> swapTextures(const std::string& tag, int tex_id = 0, int component_id = 0, int material_id = 0) override;
virtual std::vector<std::string> listSceneObjects(const std::string& name_regex) const override;
virtual Pose getObjectPose(const std::string& object_name) const override;
virtual bool setObjectPose(const std::string& object_name, const Pose& pose, bool teleport) override;

//----------- Plotting APIs ----------/
virtual void simFlushPersistentMarkers() override;
virtual void simPlotPoints(const std::vector<Vector3r>& points, const std::vector<float>& color_rgba, float size, float duration, bool is_persistent) override;
virtual void simPlotLineStrip(const std::vector<Vector3r>& points, const std::vector<float>& color_rgba, float thickness, float duration, bool is_persistent) override;
virtual void simPlotLineList(const std::vector<Vector3r>& points, const std::vector<float>& color_rgba, float thickness, float duration, bool is_persistent) override;
virtual void simPlotArrows(const std::vector<Vector3r>& points_start, const std::vector<Vector3r>& points_end, const std::vector<float>& color_rgba, float thickness, float arrow_size, float duration, bool is_persistent) override;
virtual void simPlotStrings(const std::vector<std::string>& strings, const std::vector<Vector3r>& positions, float scale, const std::vector<float>& color_rgba, float duration) override;
virtual void simPlotTransforms(const std::vector<Pose>& poses, float scale, float thickness, float duration, bool is_persistent) override;
virtual void simPlotTransformsWithNames(const std::vector<Pose>& poses, const std::vector<std::string>& names, float tf_scale, float tf_thickness, float text_scale, const std::vector<float>& text_color_rgba, float duration) override;
virtual std::vector<MeshPositionVertexBuffersResponse> getMeshPositionVertexBuffers() const override;

private:
SimModeBase * simmode_;
std::string vehicle_name_;
Expand Down
45 changes: 23 additions & 22 deletions Unity/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,38 +28,39 @@ This project is still in early development, expect some rough edges. We are work
* Additionally, there is a free environment `Windridge City` which you can download from [Unity Asset Store](https://assetstore.unity.com/packages/3d/environments/roadways/windridge-city-132222). And, of course, you can always create your own environment.

## Linux
#### Necessary Packages
The linux wrapper requires Boost filesystem, which you can install by running the following command:
#### Dependencies
```
sudo apt-get install libboost-all-dev
```
#### Download and Install Unity for Linux
<span style="color:red">Warning:</span> Unity Editor for Linux is still in Beta. Expect some rough edges.

[Unity Editor](https://forum.unity.com/threads/unity-on-linux-release-notes-and-known-issues.350256/#post-2556301)
* Download the editor by doing one of the following:
1. Navigate to the latest post on [this thread](https://forum.unity.com/threads/unity-on-linux-release-notes-and-known-issues.350256/#post-2556301) and click the download link
2. Open a terminal window and enter the following command:
```
wget https://beta.unity3d.com/download/dad990bf2728/UnitySetup-2018.2.7f1
```
* Install The editor
* **Download** Unity editor version `2019.1.0f2`
```shell
wget https://beta.unity3d.com/download/292b93d75a2c/UnitySetup-2019.1.0f2
```
Note: While the latest version of linux build of Unity can be found on the last post of [this thread](https://forum.unity.com/threads/unity-on-linux-release-notes-and-known-issues.350256/page-2#post-4458286), we recommend `2019.1.0f2`.

* **Install** the editor
```shell
chmod +x UnitySetup-2019.1.0f2
./UnitySetup-2019.1.0f2
```

#### Build Airsim
```
chmod +x UnitySetup-2018.2.7f1
./UnitySetup-2018.2.7f1
git clone https://github.com/Microsoft/AirSim.git;
cd AirSim;
./setup.sh;
./build.sh
```

#### Build Airsim in Linux
* Open a new terminal window on your linux machine
* Clone the repo: `git clone https://github.com/Microsoft/AirSim.git`, and go the AirSim directory by `cd AirSim`.
* Run `setup.sh ` and subsequently `build.sh` from the the terminal.

#### Generate AirsimWrapper Shared Library
* On your linux machine, navigate to your AirSim repository, and run the following commands in a terminal window:
```
cd Unity
./build.sh
```
```
cd AirSim/Unity
./build.sh
```

This will generate the necessary shared library and copy it to the UnityDemo Plugins folder.

## Usage
Expand Down