зеркало из https://github.com/microsoft/AirSim.git
Remove usage of "using namespace std;"
This commit is contained in:
Родитель
d28514c2dd
Коммит
6043143516
|
@ -7,7 +7,6 @@
|
|||
#include "vehicles/multirotor/firmwares/mavlink/MavLinkMultirotorApi.hpp"
|
||||
#include "common/Settings.hpp"
|
||||
|
||||
using namespace std;
|
||||
using namespace msr::airlib;
|
||||
|
||||
/*
|
||||
|
@ -21,7 +20,7 @@ int main(int argc, const char* argv[])
|
|||
if (argc != 2) {
|
||||
std::cout << "Usage: " << argv[0] << " is_simulation" << std::endl;
|
||||
std::cout << "\t where is_simulation = 0 or 1" << std::endl;
|
||||
cout << "Start the DroneServer using the 'PX4' settings in ~/Documents/AirSim/settings.json." << endl;
|
||||
std::cout << "Start the DroneServer using the 'PX4' settings in ~/Documents/AirSim/settings.json." << std::endl;
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
|
|
@ -24,7 +24,6 @@ namespace msr
|
|||
namespace airlib
|
||||
{
|
||||
|
||||
using namespace std;
|
||||
using namespace common_utils;
|
||||
|
||||
struct CommandContext
|
||||
|
@ -403,7 +402,7 @@ namespace airlib
|
|||
}
|
||||
}
|
||||
if (path.size() == 0) {
|
||||
std::cout << "incomplete path, please provide at least 3 numbers defining a 3d point" << endl;
|
||||
std::cout << "incomplete path, please provide at least 3 numbers defining a 3d point" << std::endl;
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -1294,7 +1293,7 @@ See RecordPose for information about log file format")
|
|||
auto image = context->client.simGetImage("0", imageType);
|
||||
|
||||
if (image.size() == 0) {
|
||||
std::cout << "error getting image, check sim for error messages" << endl;
|
||||
std::cout << "error getting image, check sim for error messages" << std::endl;
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -1322,12 +1321,12 @@ See RecordPose for information about log file format")
|
|||
std::string imageName = Utils::stringf("%s_%s%d.png", baseName.c_str(), typeName, image_index_++);
|
||||
std::string file_path_name = FileSystem::combine(path, imageName);
|
||||
|
||||
ofstream file;
|
||||
std::ofstream file;
|
||||
FileSystem::createBinaryFile(file_path_name, file);
|
||||
file.write(reinterpret_cast<const char*>(image.data()), image.size());
|
||||
file.close();
|
||||
|
||||
std::cout << "Image saved to: " << file_path_name << " (" << image.size() << " bytes)" << endl;
|
||||
std::cout << "Image saved to: " << file_path_name << " (" << image.size() << " bytes)" << std::endl;
|
||||
|
||||
context->sleep_for(pause_time / 1000);
|
||||
}
|
||||
|
@ -1359,7 +1358,7 @@ See RecordPose for information about log file format")
|
|||
imageType = ImageCaptureBase::ImageType::DisparityNormalized;
|
||||
}
|
||||
else {
|
||||
cout << "Error: Invalid image type '" << type << "', expecting either 'depth', 'scene' or 'segmentation'" << endl;
|
||||
std::cout << "Error: Invalid image type '" << type << "', expecting either 'depth', 'scene' or 'segmentation'" << std::endl;
|
||||
return true;
|
||||
}
|
||||
|
||||
|
|
|
@ -3,9 +3,11 @@
|
|||
Please read [general API doc](apis.md) first if you haven't already. This document describes C++ examples and other C++ specific details.
|
||||
|
||||
## Quick Start
|
||||
|
||||
Fastest way to get started is to open AirSim.sln in Visual Studio 2019. You will see [Hello Car](https://github.com/Microsoft/AirSim/tree/master/HelloCar/) and [Hello Drone](https://github.com/Microsoft/AirSim/tree/master/HelloDrone/) examples in the solution. These examples will show you the include paths and lib paths you will need to setup in your VC++ projects. If you are using Linux then you will specify these paths either in your [cmake file](https://github.com/Microsoft/AirSim/tree/master/cmake//HelloCar/CMakeLists.txt) or on compiler command line.
|
||||
|
||||
#### Include and Lib Folders
|
||||
|
||||
* Include folders: `$(ProjectDir)..\AirLib\deps\rpclib\include;include;$(ProjectDir)..\AirLib\deps\eigen3;$(ProjectDir)..\AirLib\include`
|
||||
* Dependencies: `rpc.lib`
|
||||
* Lib folders: `$(ProjectDir)\..\AirLib\deps\MavLinkCom\lib\$(Platform)\$(Configuration);$(ProjectDir)\..\AirLib\deps\rpclib\lib\$(Platform)\$(Configuration);$(ProjectDir)\..\AirLib\lib\$(Platform)\$(Configuration)`
|
||||
|
@ -22,7 +24,7 @@ Here's how to use AirSim APIs using C++ to control simulated car (see also [Pyth
|
|||
#include <iostream>
|
||||
#include "vehicles/car/api/CarRpcLibClient.hpp"
|
||||
|
||||
int main()
|
||||
int main()
|
||||
{
|
||||
msr::airlib::CarRpcLibClient client;
|
||||
client.enableApiControl(true); //this disables manual control
|
||||
|
@ -60,25 +62,24 @@ Here's how to use AirSim APIs using C++ to control simulated quadrotor (see also
|
|||
#include <iostream>
|
||||
#include "vehicles/multirotor/api/MultirotorRpcLibClient.hpp"
|
||||
|
||||
int main()
|
||||
int main()
|
||||
{
|
||||
using namespace std;
|
||||
msr::airlib::MultirotorRpcLibClient client;
|
||||
|
||||
cout << "Press Enter to enable API control" << endl; cin.get();
|
||||
std::cout << "Press Enter to enable API control\n"; std::cin.get();
|
||||
client.enableApiControl(true);
|
||||
|
||||
cout << "Press Enter to arm the drone" << endl; cin.get();
|
||||
std::cout << "Press Enter to arm the drone\n"; std::cin.get();
|
||||
client.armDisarm(true);
|
||||
|
||||
cout << "Press Enter to takeoff" << endl; cin.get();
|
||||
std::cout << "Press Enter to takeoff\n"; std::cin.get();
|
||||
client.takeoffAsync(5)->waitOnLastTask();
|
||||
|
||||
cout << "Press Enter to move 5 meters in x direction with 1 m/s velocity" << endl; cin.get();
|
||||
std::cout << "Press Enter to move 5 meters in x direction with 1 m/s velocity\n"; std::cin.get();
|
||||
auto position = client.getMultirotorState().getPosition(); // from current location
|
||||
client.moveToPositionAsync(position.x() + 5, position.y(), position.z(), 1)->waitOnLastTask();
|
||||
|
||||
cout << "Press Enter to land" << endl; cin.get();
|
||||
std::cout << "Press Enter to land\n"; std::cin.get();
|
||||
client.landAsync()->waitOnLastTask();
|
||||
|
||||
return 0;
|
||||
|
@ -86,8 +87,8 @@ int main()
|
|||
```
|
||||
|
||||
## See Also
|
||||
|
||||
* [Examples](https://github.com/microsoft/AirSim/tree/master/Examples) of how to use internal infrastructure in AirSim in your other projects
|
||||
* [DroneShell](https://github.com/microsoft/AirSim/tree/master/DroneShell) app shows how to make simple interface using C++ APIs to control drones
|
||||
* [HelloSpawnedDrones](https://github.com/microsoft/AirSim/tree/master/HelloSpawnedDrones) app shows how to make additional vehicles on the fly
|
||||
* [Python APIs](apis.md)
|
||||
|
||||
|
|
Загрузка…
Ссылка в новой задаче