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

Issue with multiple vehicles multirotor api #560

Closed
spencerh-b opened this issue Oct 23, 2017 · 16 comments
Closed

Issue with multiple vehicles multirotor api #560

spencerh-b opened this issue Oct 23, 2017 · 16 comments

Comments

@spencerh-b
Copy link

spencerh-b commented Oct 23, 2017

I have place 9 drones with in my environment and I have debugged through the Unreal project as well as my api, I understand how the vehicles are differentiated with in the vehicles_ vector, which is passed onto a bodies vector... ect. I as well have a vauge understanding of how an MultirotorRpcLibClient is created but I am a little confused still on how the Client attains control over a pawn in unreal. However, through all this debbuging I am still unable to control different vehicles through an api, Is it possible to access all vehicles from a single api? I have noticed that all of my vehicles don't have a config name and none of them are the "is_fpv_vehicle" when looking through their pointers with in the vehicals_ vector. I did try to change the "is_fpv_vehical" default to true with in the wrapper, but that didnt seem to change anything. Even when changing the settings.json file I don't get a changed vehicle_config_name. Are the is_fpv_vehical and vehical_config_name_ settings something I can change in Unreal? Boiled down as simple as possible here are my questions and concerns.

Concern 1: No way to change vehicle_config_name and is_fpv_vehicle.

Question 1: How can I control multiple drones individually?

Question 2: Can I control multiple drones individually from 1 api?

Note : Using simpleflight

@spencerh-b spencerh-b changed the title Easiest way to access vehicles_ vector for multirotor api? Easiest way to access multiple vehicles multirotor api? Oct 24, 2017
@spencerh-b spencerh-b changed the title Easiest way to access multiple vehicles multirotor api? Issue with multiple vehicles multirotor api Oct 24, 2017
@spencerh-b
Copy link
Author

I managed to figure it out for better or worse by changing the files
SimModeWorldMultiRotor.h/.cpp by making all the drones set up on a different port which was apparently not being changed via the .json file.

@saihv
Copy link
Contributor

saihv commented Dec 9, 2017

Does control work fine with those modifications? (with PythonClient or DroneShell). I have been looking into making similar modifications until a fix is released.

@spencerh-b
Copy link
Author

spencerh-b commented Dec 9, 2017

@saihv Yeah it really only takes a couple lines of code. Specifically, the bottom function in SimModeWorldMultiRotor.cpp incrementing the port by utilizing the size of the vehicles vector.

@saihv
Copy link
Contributor

saihv commented Dec 9, 2017

Weird. I tried the exact same thing, and the API port is changing, but the python client doesn't connect to any other port apart from 41451.

@saihv
Copy link
Contributor

saihv commented Dec 9, 2017

My code is at #664 (comment)

@spencerh-b
Copy link
Author

spencerh-b commented Dec 9, 2017

@saihv Ohhhh I forgot I as well added into the python client. My apologies. Here is a copy of my AirSimClient
AirSimClient.py.zip

@saihv
Copy link
Contributor

saihv commented Dec 9, 2017

Thanks for the link. Is this the only change you made (adding port number to the call)? Because I have the same change, yet it doesn't work.

def __init__(self, ip, port):
        self.client = msgpackrpc.Client(msgpackrpc.Address(ip, port), timeout = 3600)

@spencerh-b
Copy link
Author

spencerh-b commented Dec 9, 2017

@saihv I added a port variable into at least two functions I believe (also the multirotorClient) and then you have to input it when you initialize the drone in your api

@spencerh-b
Copy link
Author

spencerh-b commented Dec 9, 2017

`class Airsim_Swarm:

def __init__(self):

    #################

    #Number of Swarm Agents

    self.num_clients = 3

    self.num_cameras = 2

    #############

    '''
    Create list of client drones
    '''
    self.clients = []
    for i in range(0, self.num_clients):
        self.clients.append(MultirotorClient(41451+i))
        self.clients[i].confirmConnection()
        self.clients[i].enableApiControl(True)
        self.clients[i].armDisarm(True)`

@saihv
Copy link
Contributor

saihv commented Dec 9, 2017

I am doing pretty much the same thing. As soon as I try to connect on 41452 or any other ports, Looks like it has nothing to do with ports. Basically if I connect to any of the other elements in the vehicles vector and not the first, I get

WARNING:tornado.general:Connect error on fd 440: WSAECONNREFUSED

Thanks for the help anyway. I will recheck my code to see if I'm missing something. Looks like the API endpoints are not actually being initialized for some reason.

@spencerh-b
Copy link
Author

@saihv I have never seen an error like that, try using 41453 to check if that port is maybe being used by a different process

@saihv
Copy link
Contributor

saihv commented Dec 9, 2017

Looks like it's not even because of the port number. Are you using the latest version? Or an older commit?

@spencerh-b
Copy link
Author

@saihv Older commit because I am on ubuntu 14.04 otherwise it wont build a62163c

@saihv
Copy link
Contributor

saihv commented Dec 24, 2017

Weirdly, I still have the same issue with that commit. Irrespective of the port numbers, only the first vehicle responds to the API control request, none of the others do. I think I have the same modification as yours in SimModeWorldMultiRotor.cpp, and I was able to verify that all vehicles have a different port assigned by watching the vehicles variable.

vehicle_params_.push_back(std::move(vehicle_params));

std::shared_ptr<MultiRotorConnector> vehicle = std::make_shared<MultiRotorConnector>(
        wrapper, vehicle_params_.back().get(), enable_rpc, api_server_address,
        41454 + vehicle_params_.size() - 1, manual_pose_controller);

@saihv
Copy link
Contributor

saihv commented Dec 24, 2017

I think I figured out what's wrong: don't you also need to do vehicle->startApiServer() for each of the vehicles? Which means your fpv_vehicle_connector should be an array instead of just one

@spencerh-b
Copy link
Author

Sorry for the late response I took a little vacation time. Interesting I have been able to have this running and I'm not really sure what the issue is. I have also been able to get this running with python, but it seems as though a fix that utilizes the .json file is necessary for total reliability

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants