We have a need for spawning multiple vehicles. Please let me know if you have a proper way to implement spawning.
I made a change to MultiRotorAPI to accept "Spawn" call from a MultiRotorConnector.
I actually was able to call the spawn function, but UE4 errors and crashes as soon as I spawn a multirotor with this->GetWorld()->SpawnActor
I am calling the spawn function inside SimModeWorldMultiRotor.cpp.
void ASimModeWorldMultiRotor::spawnVehicle(UWorld* world)
{
FVector loc(300, 250, 300);
FRotator rot(0, 0, 0);
auto bp_class = UAirBlueprintLib::LoadClass("Class'/AirSim/Blueprints/BP_FlyingPawn.BP_FlyingPawn_C'");
FActorSpawnParameters pawn_spawn_params;
pawn_spawn_params.SpawnCollisionHandlingOverride =
ESpawnActorCollisionHandlingMethod::AdjustIfPossibleButAlwaysSpawn;
TMultiRotorPawn* spawned_pawn = world->SpawnActor<TMultiRotorPawn>(
bp_class, loc, rot, pawn_spawn_params); **<<-- EXCEPTION THIS LINE**
ERROR INFO
We are currently working on this. There are bunch of design changes coming along with this feature in couple of weeks...
Thank you for the answer. I ended up hooking blueprint function called via c++. So now it spawns well. Looking forward to seeing the feature release.
@stephen-jang, please are you able to control two rotors in one environment.
{
"SettingsVersion": 1.0,
"SimMode": "Multirotor",
"DefaultVehicleConfig": "PX4"
"PX4_1": {
"FirmwareName": "PX4",
"SitlIp": "127.0.0.1",
"SitlPort": 14556,
"UdpIp": "127.0.0.1",
"UdpPort": 14560,
"UseSerial": true,
"SerialPort":"COM3",
"ApiServerPort": 41451
},
"PX4_2": {
"FirmwareName": "PX4",
"SitlIp": "127.0.0.1",
"SitlPort": 14557,
"UdpIp": "127.0.0.1",
"UdpPort": 14561,
"UseSerial": true,
"SerialPort":"COM5",
"ApiServerPort": 41452
}
}
it always only connect one
@Isaac45 As far as I know, their multi-agent doc is old. Basically you don't have to set VehicleConfigName inside Airsim/settings.
If you've pulled their latest branch, by just creating two vehicles on unreal environment will create 2 multirotor connectors which you can access with 2 different ports. Port numbers get incremented automatically. So just drag and drop 2 or more vehicles inside unreal editor.
Look at line from line111 carefully inside setupVehiclesAndCamera. You will notice that Airsim finds currently available pawns in unreal and connecting each of them with for loop.
yes please I'm using the same file, but it does not work for me.
Can you please check my settings.json file may be I'm making a mistake in
that.
{
"SettingsVersion": 1.0,
"SimMode": "Multirotor",
"DefaultVehicleConfig": "PX4_1"
"PX4_1": {
"FirmwareName": "PX4",
"SitlIp": "127.0.0.1",
"SitlPort": 14556,
"UdpIp": "127.0.0.1",
"UdpPort": 14560,
"UseSerial": true,
"SerialPort":"COM3",
"ApiServerPort": 41451
},
"PX4_2": {
"FirmwareName": "PX4",
"SitlIp": "127.0.0.1",
"SitlPort": 14557,
"UdpIp": "127.0.0.1",
"UdpPort": 14561,
"UseSerial": true,
"SerialPort":"COM5",
"ApiServerPort": 41452
}
}
On Tue, May 8, 2018 at 10:27 PM, stephen-jang notifications@github.com
wrote:
@Isaac45 https://github.com/Isaac45 As far as I know, their multi-agent
doc is old. Basically you don't have to set VehicleConfigName inside
Airsim/settings.If you've pulled their latest branch, by just creating two vehicles on
unreal environment will create 2 multirotor connectors which you can access
with 2 different ports. Port numbers get incremented automatically.https://github.com/Microsoft/AirSim/blob/master/Unreal/
Plugins/AirSim/Source/Multirotor/SimModeWorldMultiRotor.cppLook at line 111 carefully inside setupVehiclesAndCamera. You will notice
that Airsim finds currently available pawns in unreal and connecting each
of them with for loop.—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
https://github.com/Microsoft/AirSim/issues/1008#issuecomment-387421173,
or mute the thread
https://github.com/notifications/unsubscribe-auth/AVRUWZ8thVZr2Z-9EBVkZx5RzYamugoOks5twatOgaJpZM4TiPXS
.
@stephen-jang, this is the challenge #978
@stephen-jang
I followed your instructions but failed to control multi UAVs. (only one is able to be controlled)
It seems that setting up the "settings.json" to give different ApiServerPort numbers to multi UAVs is ineffective.
Even though I give another port number (e.g., 41452) through settings.json, the server is only listening to 41451, which is the default one.
The server port number "41451" is hard coded and the current source code supports only one port number. There is no automatic increase for it. Thus, for me, the only way to use another port number was to modify the source code directly to another one (e.g., 41452). But it is neither fancy nor supporting multi UAVs.
Please correct me if I am wrong.
@Isaac45 @galgyeony As I mentioned before, their doc for (settings.json) is outdated. Thus, ineffective.
Currently, You should have 2 or more pawns inside unreal before running anything. Port # was automatically incremented before. I believe they are in the process of getting their new multi-agent system.
Your createVehicle inside SimModeWorldMultiRotor should have this line:
std::shared_ptr<MultiRotorConnector> vehicle = std::make_shared<MultiRotorConnector>(
wrapper, vehicle_params_.back().get(), getSettings().enable_rpc, getSettings().api_server_address,
vehicle_params_.back()->getParams().api_server_port + vehicle_params_.size() - 1, manual_pose_controller
);
@stephen-jang
Based on your code and the sample python API script (i.e., swarmControl.py), now I am able to control 2 drones simultaneously.
However, an error message "API call timed out, entering hover mode" is frequently displayed on screen and I lose control for that drone.
For instance, if I execute a command "0 takeoff", then the drone with index 0 takes off. However, just after the takeoff, the error message is displayed and no more control for the drone 0, (e.g., "0 land" does not work).
Interestingly, if I execute another command "1 takeoff", the drone 1 takes off well. Then, if I execute "0 land" again, the drone 0 now lands well. In short, the drone 0 and drone 1 cannot be in the "land" state simultaneously.
Thank you very much for your help and comments.
@galgyeony swarmControl.py was written with not much testings. I grabbed that code from "https://github.com/saihv" But I know that communicating through port 41451, 41452, or more works. That I've tested with different setups. Try testing them a little to make sure they communicate in different ports.
@stephen-jang Yes, you're right. It mostly works using different ports like 41451, 41452 or more. But there are some problems. One example is that if there are two vehicles (0 and 1) and both already have taken off, then both ones cannot land. Only one is allowed to land.
@galgyeony I believe PR #1374 addresses the takeoff / landing issue.
Most helpful comment
We are currently working on this. There are bunch of design changes coming along with this feature in couple of weeks...