VOXL ESC FPV queries
-
@Jetson-Nano , I see what you mean about the use case. I believe we have considered a similar use case before, let me check how we did it.
Will get back to you soon.
Alex
-
Hi @Jetson-Nano ,
I asked around and we currently do not have an official way to do this. In some tests what we have done is read the RC values from mavlink server and pick a RC channel (a switch), so that when the switch is flipped, you send our the command using
voxl-send-neopixel-cmd.c
. Please note that you cannot run the python test script while PX4 is running (which is your use case).So basically, what is missing is some "glue" that will tie together the RC channel logic with sending out the LED command. Using PX4 for this may be too complicated and it can be done in a simple script. This can be your own app.
I can provide an example of achieving this relatively easily using python:
- using a python script that calls
px4-listener
to get RC data packet into python, you can get all the RC channels and decide what channel you want to use for the LED. I don't have the exact script, but i am pasting another script i recently wrote for logging barometer data in the similar way - when you decide that an led command needs to be sent out, you can do a system call / subprocess call to
voxl-send-neopixel-cmd
to turn the led on / off. This helper tool already has support to just turn the while led on or off. Note that this command will send a message via MPA pipe to PX4 process, which will forward the data packet to the PX4 ESC driver, and the message will go out via UART to the ESC (so that you understand the data flow)
So your final python script might look something like this (outline):
make sure PX4 is running- loop and periodically read RC channels (lets say at 5-10hz)
- if there is transition on a RC channel that is mapped to a switch, call
voxl-send-neopixel-cmd
In order to modify the barometer reading script for RC data, you can just first print out what the
px4-listener
returns and then parse the RC channel values.Please let me know if this will work for you, If you need more specific example, I can help but it will take a bit more time (i just wanted to propose a path forward to you).
script for logging barometer data:
import subprocess import time import numpy as np import argparse # install plotly using pip3 install plotly --upgrade parser = argparse.ArgumentParser(description='Barometer Test Script') parser.add_argument('-n','--num-samples', type=int, required=False, default=1000) args = parser.parse_args() max_sample_count = args.num_samples def get_px4_baro(): cmd = 'px4-listener sensor_baro' p = subprocess.Popen(cmd, shell=True, stdout=subprocess.PIPE, stderr=subprocess.STDOUT) timestamp = None pressure = None temperature = None for line in p.stdout.readlines(): l=str(line) #print(l) if 'timestamp' in l: ll = l.split(':')[1].split()[0] timestamp = float(ll) if 'pressure' in l: ll = l.split(':')[-1][:-3] pressure = float(ll) if 'temperature' in l: ll = l.split(':')[-1][:-3] temperature = float(ll) retval = p.wait() return (timestamp,pressure,temperature) tlast = 0 ts = [] ps = [] temps = [] sample_count = 0 while (sample_count < max_sample_count): (timestamp, pressure, temperature) = get_px4_baro() #make sure we got new data if timestamp != tlast: sample_count += 1 ts.append(timestamp) ps.append(pressure) temps.append(temperature) print(f'({sample_count})[{timestamp}] P: {pressure}, T: {temperature}') tlast=timestamp time.sleep(0.01) print('Finished collecting data') print('Generating plots..') try: import plotly.graph_objects as go from plotly.subplots import make_subplots except: print('WARNING: In order to plot the results, install the Python "plotly" module: pip3 install plotly --upgrade') sys.exit(0) fig = make_subplots(rows=3, cols=1, start_cell="top-left") ts_plot = np.array(ts) ts_plot -= ts_plot[0] ts_plot *= 0.000001 #convert from us to s # calculate approximate height from start dh = np.array(ps) dh -= dh[0] # subtract the first value dh /= 12.0 # about 12 Pascals per meter at standard pressure and temperature fig.add_trace(go.Scatter(x=ts_plot, y=np.array(ps), name='Pressure (Pa)'), row=1, col=1) fig.add_trace(go.Scatter(x=ts_plot, y=np.array(temps), name='Temperature (deg C)'), row=2, col=1) fig.add_trace(go.Scatter(x=ts_plot, y=dh, name='Approx Height (m)'), row=3, col=1) fig.update_layout(title_text='Barometer Test Results') fig.update_xaxes(title_text='Time (s)',row=1, col=1) fig.update_yaxes(title_text='Pressure (Pa)',row=1, col=1) fig.update_xaxes(title_text='Time (s)',row=2, col=1) fig.update_yaxes(title_text='Temperature (deg C)',row=2, col=1) fig.update_xaxes(title_text='Time (s)',row=3, col=1) fig.update_yaxes(title_text='Approx Height (m)',row=3, col=1) fig.update_xaxes(matches='x') fig.write_html('barometer_test_results.html',include_plotlyjs='cdn') #fig.show() #the figure will not show on VOXL because there is no display / browser print('done')
- using a python script that calls
-
Thanks @Alex-Kushleyev for reverting back, I will test it out. It might some time but I will get back to you.
I had an additional query, where will the python file be running, inside any server or docker. Theoretically this should work, and if it works i want the python file to start when the system is booted.
-
@Alex-Kushleyev I am using flight core v2 as external FC. Due to which i am getting error message when i run the command
px4-listener
.Can you help me out here. how to get the data when we use external FC.
-
@Jetson-Nano Try out
voxl-inspect-mavlink
, if you hit tab a couple times it should populate with the various pipes you can read from -
thanks @tom for reverting back. I had already tried it and I was not able to see any RC channel data. listener function was not working.
The issue is I am not able to see the RC channel changes. Can you help me out how am I supposed to get the RC changes. -
Hi @Jetson-Nano, sorry i originally did not realize that you are running PX4 outside VOXL2. In this case
px4-listener
approach will not work.However, in the case of PX4 running on flight core (v1 or v2), there is still communication between Flight Core and VOXL2.
voxl-mavlink-server
should be communicating with the Flight Core via UART and passing messages back and forth. Depending whether the forwarding of RC topic is enabled or not,voxl-mavlink-server
would receive those messages (if enabled) and in that case they would be accessible on VOXL2.@tom , can you please elaborate on how to double check if the RC message is set up to forward to
voxl-mavlink-server
from Flight Core (if not, how to enable it) and how to actually read that message?Thanks!
Alex
-
@Alex-Kushleyev @Jetson-Nano You'll want to make sure that in
/etc/modalai/voxl-mavlink-server.conf
thaten_external_uart_ap
is set totrue
Once you restart the service you should be able to run
voxl-inspect-mavlink mavlink_offboard
to view the generated messages from FC -
@tom @Alex-Kushleyev thanks guys. I will check it and get back to you with the result.
-
@Alex-Kushleyev @tom
Guys I checked what you guys mentioned.
Theen_external_uart_ap
is set to True, but when I run the commandvoxl-inspect-mavlink mavlink_offboard
, the terminal is showingwaiting for pipe to connect
and not showing anything else.Adding to the previous point there is no mavlink_offboard showing up.
-
@Jetson-Nano , is
voxl-mavlink-server
actually running? you can check usingvoxl-inspect-services
.Also, are you sure that your Flight Core V2 is connected to
/dev/ttyHS1
, which would be implied by usingautopilot_uart_bus: 1
. How exactly are you connecting it to VOXL2?Alex
-
@Alex-Kushleyev
yes thevoxl-mavlink-server
is running, I had checked it.I am following this documentation for FC connections.
-
@Jetson-Nano , can you please clarify which connector on VOXL2 is your Flight Core connected to (for uart communication) and whether you have any indication that the communication is established? Have you previously been able to connect to VOXL2 from QGC and access the Flight Core V2 while it has been connected to VOXL2?
Alex
-
@Alex-Kushleyev I currently use, VOXL2 USB 3.0 Expansion Adapter connected to VOXL2. From the UART7 port of the Expansion Adapter I have connected to 6-PIN Telemetry1 Port in Flight Core V2.
My connection is similar to this,
As you mentioned earlier, I'm establishing connection through port
/dev/ttyHS1
. When I run thecat
command to read the messages from this port, I get garbled data as below,.
I'm not exactly clear when you mean if I have tried connecting to VOXL2 from QGC and access the Flight Core V2. Few things I have tried is,
-
Connecting to FlightCore V2 by connecting to Wifi of VOXL2. I also have a Wifi setup on VOXL2, which also acts as my Telemetry line. From QGC I connect to this local network to access FC data and PX4 parameters on Flight Core V2.
-
I have tried and tested few mavlink message commads which communicate with PX4 directly for C2C.
-
-
@tom As per your response on shifting to
voxl-inspect-mavlink mavlink_offboard
, I see that even in mavlink server documentation from ModalAI that service pipeline is not listed. Is it that something that has to be explicitly be enabled somewhere?
Even as per the documentation, I dont see this service pipeline listed. -
@Jetson-Nano I could have the naming wrong. If you inspect
mavlink_onboard
what kind of data do you see? -
@tom This is the output I get,
-
@Jetson-Nano Since you don't have voxl-px4 running I think that data is likely coming from your external flight controller
-
@tom yes, the message is coming from external flight controller, Flight core v2. Now can you share how to double check if the RC message is set up to forward to voxl-mavlink-server from Flight Core (if not, how to enable it) and how to actually read that message?
-
@Jetson-Nano Probably should also look at the pipe for messages from the flight controller to the GCS (Labeled mavlink_to_gcs in the above diagram but you'll have to double check that name). Generally the flight controller is configured with two mavlink streams. One is the onboard stream that has high rate messages and is intended for local use (e.g. on VOXL or VOXL 2) and the other is more the default settings for communication with a GCS. You can configure what each of these streams contain in PX4. You can add streams, change stream rates, etc. all via PX4 configuration. Please refer to the PX4 documentation for details on how to do this.