mavROS, SITL ArduPlane: commands in GUIDED mode are rejected - python

A simple python script publishes commands to the mavros node which is connected to an arduplane SITL instance.
Succesfully publishing to change mode from AUTO to GUIDED (so no connection or other issues). After changing, the plane is loitering.
Publishing to the services ~cmd/command or ~cmd/command_int the commands are rejected (return code 3).
Publishing to the topic ~setpoint_raw/global has no effect whatsoever.
The published command is a simple 16 MAV_CMD_NAV_WAYPOINT
The question is: is there any way that I can use any of the topics/services of mavros in order to simply stream waypoints (pairs of global coordinates) for the UAV to follow (in GUIDED or in any other mode).
I think that clearing and continuously uploading a mission in AUTO is not exactly an option since it would delay significantly.
Please note that the solution is intendeed for a fixed wing (aka Plane).
Versions:
ROS: Kinetic
ArduPilot: 3.8.0beta5
The issue has also been raised in mavros and Ardupilot hubs.

Did you try to do that using GCS and it failed too?
I also suggest to try dronekit . It is in python and simple to implement and send commands for the vehicle.

Related

Icecast stream switching sources without the clients stopping playback

Good morning :)
I have some questions regarding an icecast-setup.
We have my own (Nextcloud)-Server sitting in our church. This works perfectly fine and since here in Germany the community services got forbidden already once during all this Covid19-stuff, we want to have a stream-setup. I managed to set up an icecast-instance on our server and we use my old laptop with Rocket Broadcaster and a Steinberg CI2 to provide the source for the stream. That works all as intended. We already used it once because we stopped public services for two weeks after one of our member got tested positive after he went abroad for a week.
Our operator on the PA doesn't want to have another display there, which would disturb him from listening the sermon.
My project regarding this: I have a RPi4 and a Behringer U-Phoria UMC202HD. The input atm is a standard mic, that is connected to the Interface.
The Pi is configured with darkice and uses its own icecast installation, while I am testing everything at home. Since I started the streaming project, after the service we switched Rocket Broadcaster to use VLC and a folder of old service recordings (mastered and in MP3-format) to provide a source to listen while we are at work or on travels. This option gets used pretty regularly and I want to keep it going.
My plan is to have a little box with a LED levelmeter, where the input level is shown. That should be done with a little python script. Also I want to add two buttons, where presets for the two setups get loaded. Button 1: kill the current source and start the darkice livestream. Button 2: kill the current source and start the playback of old recordings. Both options should have visual feedback for the operator. The raspberry has to work in headless mode without need for a VNC or SSH-connection for the normal usage.
My problem: I tried:
sudo killall darkice && /home/pi/darkice.sh
This code will get changed, because I probably have to use ices for the mp3-playback. So basically it kills darkice, starts the ices playback (for now only restarts the stream in a blink) and vice versa.
The bash-file exists and gets executed at reboot via cronjob. That works well. When I execute the above mentioned killall command, icecast continues the broadcast almost instantly, but the stream stops on the clients. Everyone needs to restart it.
Do I have an option to change the setup, so that I am able to switch between the two options without the need for everyone to restart?
My plan was to create a bash-script, where I do this all inside and execute it via GPIO-input and pythoncode.
Thanks in advance!

Watch module /sys/module/uvcvideo/refcnt for changes (to trigger action on webcam use)

I would like to switch an On Air sign at my work-from-home office when my webcam is on.
Detecting whether the webcam is on can easily be done via
cat /sys/module/uvcvideo/refcnt
if it outputs 0 no app is using the webcam, otherwise it is.
I already have a Wifi plug which can be switched using a HTTP GET request.
My only question is: Do I have to poll the output of the above command regularly, or can I get notified in some Bash, Python or PHP script from the kernel?
The idea would be to not generate unnessary system load by polling - or doesn't that matter?
I already tried inotifywait but it does not seem to notice changes on the above pseudo file.
Based on jasonharpers answer I implemented it as a daemon that uses polling
https://github.com/amenk/OnAirDaemon

Python, DroneKit, Pixhawk and ArduPilot Mission Planner: how to send text messages via the built-in telemetry to a ground station

I am working on a student project involving a drone which runs on the Pixhawk platform but has a 'companion computer' in the form of a Raspberry Pi. The Pi runs its own Python software and uses DroneKit (and therefore MAVLink?) to communicate with the Pixhawk via USB - giving it commands, transferring data and so on. Additionally, we have a 'ground station' laptop running ArduPilot Mission Planner which can view and interact with the aircraft remotely and also view it's telemetry. I noticed a 'Messages' tab which essentially acts like a remote console, showing 'logged' messages from the Pixhawk - this is what the question is referring to.
For debugging and information purposes, I would like to be able to add to this from Python on the Pi. I assumed this would be easily achievable through DroneKit but it does not seem trivial - send_mavlink and message_factory looked hopeful but I have found nobody else trying to do this specifically.
How can I easily redirect my 'console messages' from Python to the ground station? I realise there are alternative methods but going through the Pixhawk's existing telemetry system seems a much better option.
Thanks
One thing you can do is to create a bridge (proxy) between Pixhawk and GCS with your RPi, similar to this question.
Then in the middle of that you can send your own text messages with:
gcs_conn.mav.statustext_send(mavutil.mavlink.MAV_SEVERITY_INFO, "your message here")
Be careful not blocking too much the telemetry transmission, otherwise you could have intermittent connection to the drone from your GCS.

Trigger an cognex camera by script

I have got a Cognex Advantage 100 camera connected to my PC via ethernet.
After pressing F5 in the inSight Explorer to trigger the camera I can use the captured image in a Python script.
Can I make the Python script trigger the image capture itself?
I'm not very familiar with the Advantage series, but I am quite familiar with the other In-Sight cameras. I'm going to assume the Advantage is similar to other In-Sight cameras.
You should be able to achieve a trigger from python by opening a telnet connection to the camera (on port 23), logging in (default username: admin, password: ), and sending the command 'SE8'. The camera trigger mode must be set to External, Manual or Network. If the command is successful, it will respond with a '1'. I'd suggest trying this with a telnet client before trying it in python. Suggested telnet clients: Putty or Hercules.
More information can be found in the In-Sight Explorer help file. From the contents, go to 'Communications Reference -> Native Mode Communications'.
Possibly you could simulate a key press. This answer here and this answer here, might help you do that.
Apart from that, your camera software doesn't allow you to interact with it via python, but it does supply it own method of programming the camera here. Try that instead, it seems to be the indented way of doing this.

How can I detect when a flash drive is plugged in under Linux?

How can I detect when a flash drive is plugged in? I'm using a bare Debian installation, without any GUI and want to be notified in my Python script when a new flash drive appears... I know that D-BUS distributes such information, but i dont want to use D-BUS. Is there a more bare access to that information? Shouldn't that be available under /proc or /sys? How can I "connect" to that source?
Bye
falstaff
All mayor Linux distros include udev, that allows you to write custom scripts on hardware events.
You can read uevents from kernel via a Netlink socket and look for events where "ACTION" is "add" (you can also watch if a partition from a device was mounted or unmounted, or if a device is being removed). That's as close to the source of events as one can get in user space. As far as I know, this is how udev detects inserted removable media.
But probably using D-Bus/HAL API via Python bingings will be much easier (no uevents data parsing, etc). Not sure why you are opposed to this. Since you are using Python, I suspect that resources are not really the issue.
If you are targetting an embedded device, then you can run mdev instead of udev.
Then you can write mdev rules that are quite simple and triggers a script.
Of course you are not directly monitoring from your script, mdev is doing it, but you can launch any command. You can probably do the same thing with udev, but it always looked quite complicated to me.
When an USB device is plugged in syslog writes messages concerning this to /var/log/messages. The "dmesg" command shows this log. You can check near the end of the log to see which channel the device was attached to, it is usually /dev/sd(letter)(number) depending on the partitions and number of serial disks plugged into the system.
/proc/partitions shows all the partitions known to the kernel.
I did this using zenity in a script and udev with rule on rhel6 with:
KERNEL=="sd[b-d]", DRIVERS=="usb", ACTION=="add", RUN+="/path/to/script"

Categories

Resources