-
Notifications
You must be signed in to change notification settings - Fork 35
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
mwp should have a remote control (dbus) interface #36
Comments
First pass ...
|
And here's the ruby example (as in #!/usr/bin/ruby
require 'dbus'
# Create bus and service object
bus = DBus::SessionBus.instance
service = bus.service("org.mwptools.mwp")
mwp = service.object("/org/mwptools/mwp")
# Test if it's up.
# Rather than abort, we could start an instance of mwp if appropriate
#
begin
pif = mwp["org.freedesktop.DBus.Peer"]
pif.Ping
rescue
abort "Service unavailable"
end
# Set the default interface
mwp.default_iface = "org.mwptools.mwp"
# Get the devices known to mwp
devs = mwp.GetDevices
devstr = devs[0].join(", ")
puts "Devices #{devstr}"
# See if we're connected to th FC, for the Connect* methods, the final
# item in the returned array is the connection status. For
# consistency, we can therefore test constat[-1]
constat = mwp.ConnectionStatus
if constat[-1]
puts "Connected to #{constat[1]}"
else
puts "Not connected, trying first device ... #{devs[0][0]}"
constat = mwp.ConnectDevice(devs[0][0])
puts "Connected state now #{constat[-1]}"
end
# If a mission file was given load it and upload to the FC
if ARGV[0] and File.exists?(ARGV[0])
npts = mwp.LoadMission ARGV[0]
puts "Loaded mission from #{ARGV[0]}, #{npts[0]} mission points"
if constat[-1]
nwpts = mwp.UploadMission true
puts "Uploaded #{nwpts[0]} waypoints to the FC"
end
end
# dump out the interface definitions
#puts mwp.introspect |
merged into master, closing |
So I've been attempting to utilize this, I have mwp housed on an ubuntu server and am trying to get the python script to work. I'm not sure if I am not using it right (still learning linux in general) but when I use the command: mwptools/samples/mwp-dbus.py test.mission I get the error: org.freedesktop.DBus.Error.NoServer: Failed to connect to socket /tmp/dbus-UGZwyWh6Ei: Connection refused I've played around a bit and have the xserver working, but I'm not sure why it doesn't give me the results of the script onto the shh terminal screen. What am I doing wrong? |
This problem happens on older dbus implementations due to the need to access the session dbus that's actually used by mwp. This is solved automagically on newer distros (e.g. Arch, Fedora 27). On ancient Ubuntu, you can use something like the following script to find the required session bus:
Otherwise, save the above to a file, e.g.
|
Note that the above |
I apologize if this is a dumb question, how do I find/choose an appropriate app to use? used ps -ef to get this list: UID PID PPID C STIME TTY TIME CMD I've tried a few things to choose an appropriate app, entered in a few: PID's and UID's, but I always get something along the lines of |
In order to remotely control mwp, a precondition is that mwp is running in an X session on the console. I don't any evidence that there is (a) an X server or (b) a user session. If the original question that started this thread was really not about mwp, but more generally "I need to be able to upload a mission to iNav on a headless server" then please clarify what you're asking (that would be a valid question, to which the answer is "it's a trivial bit of coding"). So what's the real requirement ? don't be shy about asking. |
So after a quick google search, I'd say I need to be able to upload a mission to iNav on a headless server, but I'll describe a little more about our situation and hopefully clear things up a little: We have a webapp and associated database, and a headless ubuntu VM provided by AWS (where we have MWP installed) and our hope was to be able to upload MWP mission scripts onto a locally connected drone from any PC with internet access. |
OK, soon there will be a mwp tool to upload a mission to an connected FC, it's will be called
If you don't give it a device name, it will auto-discover it. It doesn't need mwp to be running, or an X server, pure CLI tool. Does that do what you need? |
It does, I really appreciate the help. |
Continued in #38, somewhat experimental Conclusion 1 for your school project:
|
Currently, mwp's dbus server only does one thing, load a buffer of XML as a mission (for mwp-area-planner 'publish').
This capability should be expanded to (e.g.)
The text was updated successfully, but these errors were encountered: