chip updates: getting started with ROS [updates]
Okay so before we even get to things like NetworkTables and controlling actuation and etc. What we want to do is start by connecting things like the peripherals to the Jetson TX1 using ROS. That means connecting the Xbox Controller and the IMU.
So preferably, we want to connect the Xbox controller over Bluetooth (we'll do this second because apparently this is hard?). And we want to connect the IMU over USB (which is easy) but we want to publish data using MAVROS. So here we go.
step one: MAVROS
We're using the following guide: https://dev.px4.io/v1.9.0/en/ros/mavros_installation.html
This guide should tell us how to install MAVROS and also how to get it all setup. We've followed the instructions here to install MAVROS now we need to get it setup.
Now we're at the all-important step of "https://ardupilot.org/dev/docs/ros-connecting.html" connecting the ardupilot to MAVROS.
It looks like all we need to do is this... let's try it. So it didn't find the FCU. I don't think we need APSync.
It looks like we have the wrong serial port - we just need to figure out what that is. I think we also need to connect the FCU to a computer to figure out the BAUD Rate.
WHAT WE'VE DONE TO ARDUPILOT SO FAR:
WITH NOTHING PLUGGED INTO THE PIXHAWK
Connected to Q Ground Control placed on Level Surface
Ran Accelerometer Calibration
REST of sensors cals need to wait until installation
PLUG IN THE FS-iA6B receiver into the PPM input port of pixhawk through PPM output port
Turn on the FS-i6s Transmitter and switch it to PPM mode/S-BUS
Plug into QGround Control + Wait for Connection
Turn off all trims and subtrims
Run RADIO CALIBRATION’
MOUNT THE FC AND THE GPS TO THE BOARD
Running Compass Calibration
Take the COMPASS_CAL_FIT parameter to RELAXED
The craft is large and we have THREE compasses, this should help us pass calibration
Then we go into the SENSORS MENU
Select ALL THREE COMPASSES, primary, secondary, and third (2 and 3 are internal compasses)
Run the calibration as per the instructions, randomly rotate the ardupilot, in relaxed mode ALL THREE COMPASSES SHOULD CALIBRATE
Then REBOOT THE VEHICLE
We can do this when it isn’t on the vehicle because it is simply trying to get the offsets between the compass, the autopilot, etc.
We may need to rerun this in BOSTON/the location of use of the craft but likely not ...
WE DONT NEED SUPER PRECISE COMPASS CALIBRATION BECAUSE WE AREN’T FLYING, WE REALLY JUST NEED THE GPS FOR AUTONAV & COMPASS TELLS US HEADING
ALSO the craft is HUGE → so imprecise compass calibration will be offset by this fact
Now, we're going to connect to the QGroundControl app and set things like the baud rate.
So I think, over USB we are using Serial1, so I've set that to 921600 baud rate. I need to find the serial port of the Ardupilot now and insert the baud rate as a parameter and see what happens.
It is entirely possible that if we type "roslaunch mavros apm.launch" the ROS node will automatically detect the FCU. Let's try that.
So it FOUND the Ardupilot but two issues: (1) ROS can't access the USB port, and (2) the baud-rate is still 57600. Let's fix both of these.
/dev/ttyACM0 is the port!
SO ISSUE ONE: BAUD RATE
I think the baud rate is an issue because I was supposed to change Serial2 NOT Serial1! Oops. Let's just go fix that. We're using QGroundControl to do this btw! Should've just listened to the website!
Let's see if it is in fact Serial2 and that fixes the baud rate problem.
So that did not fix the baud-rate problem. So maybe the USB is limited to 57600, not that this should be too much of a problem yet. For now, we're going to move on to...
SECOND ISSUE: can't access port?
No matter, just type following. "sudo chmod 777 /dev/ttyACM0" and that should allow read/write access. Now we type "sudo usermod -aG dialout username"
Where "username" is robotics-core because that's the name of the user in this case. And that makes this change permanent.
Now... if we ROSLAUNCH (ayyy it works).
step two: getting actual IMU DATA
The IMU is not publishing data right? If we look at this https://ardupilot.org/dev/docs/ros-data-from-ap.html we can see exactly which topics to echo/subscribe to see the data.
Let's "rostopic echo /mavros/imu/data"--> and we get nothing. Hmmmm.
So it's saying there's NO FCU CONNECTION. Let's try with a different URL.
fcu_url:=/dev/ttyACM0[:921600] --> so this says there's no such file or device. So that didn't work.
APSync's only job is to create a WiFi access point that allows you to connect to the ardupilot from the wifi access point. The access point is created on the jetson/etc. We don't NEED that right now and that's defiantly not the issue here.
So the nodes clearly launched because the node automatically finds the FCU. I also want to know why the baud rate is still 57600 -- this may be the issue?
So the nodes are all active but they're not publishing anything.
Okay so when we ran some diagnostics, it doesn't even seem its connected which means I think we have the wrong serial port. So when I unplug the ardupilot ACM still shows up... so it isn't that. We're using a combo of dmesg and lsusb to figure this out. Stand-by.
I'm confused because the ACM0 port is supposed to be. What we're going to do is install QGroundControl on the Jetson to see if we can find the serial port and baud rate.
^ Well that didn't work because QGroundControl won't run on a Jetson TX1.
So now we might need to go back to hardwiring it to the right serial port like this: https://github.com/NVIDIA-AI-IOT/redtail/wiki/Dev-board-UART-and-Pixhawk-connection
Let's try this in the TELEM2 PORT.
For Pixhawk 2.1: We're going to try using this
Because of this, we will need to power the Pixhawk from the usb as well or from the included power module.
So this results in two things... one that we know the serial port is /dev/ttyTHS2 and that the baud rate (since we set SERIAL2) is 921600 so...
roslaunch mavros apm.launch fcu_url:="/dev/ttyTHS2:921600"
Now we should be able to rostopic echo!
Same error as before... hm. Now I'm truly not sure what's going on here. It clearly is recognizing the Ardupilot but getting no data from it.
Things to Check:
These are the two things we did NOT check but likely should.
Let's start this from the beginning. We're just going to re-flash the firmware.
Flashing the ArduRover v4.0.0 Firmware. Now we're getting a green flashy-light on the GPS. That's a good sign I think. We're going to LEAVE the laptop plugged in, change the serial baud rate in ROS, and see what happens.
WE ALSO WENT TO THE BRD_SER2_RTSCTS and DISABLED IT.
Leaving the laptop plugged in, let's see if we can get data from Mavros.
AYY we're getting data! Now we want to see what this message RTT too high for time sync means. Apparently all we need to do is go set the apm_config.yaml in the mavros folder, search for “timesync” and set timesync_rate to 0.0!
And presto, that fixed that too!
Now all I want to do is up the rate we read from the IMU - it seems a little slow on the ROS topic echo to me. I also am going to now unplug from my computer and see if I can still get data when I power this thing from the Jetson.
Okay so... plugging it into the Jetson the GPS is still green. Now let's launch ROS. YES DATA!
Now we just need to fix the IMU publishing rate. It says we need to look at the SR2_XXXX params.
Founddddd the problem. Everything is streaming at 1Hz. Yay. Let's fix that and bump it to like a healthy 30Hz or something. We just need to figure out which one of these things we care about and only bump that one. https://ardupilot.org/rover/docs/parameters.html#sr2-parameters
Yea that didn't give us much. Let's just make everything 10Hz. We have the bandwidth. "Let's make this silicone work." We don't need ADSB so we will leave that 0. This is okay since this device is really only being used as a sensor.
We re-booted the vehicle and now let's check the IMU messages. MUCH BETTER. It's streaming IMU data at 10 Hz! That's good news.
While we're at it, we can set /dev/ttyTHS2:921600 as the default serial port in the Ardupilot YAML config because that is hardwired and can't change.
step three: Joystick on ROS
Ah yes, through all of that we may have forgotten we also need to setup a joystick. An Xbox controller to be precise. We need to get it connected to the Jetson, and then get it publishing over ROS. First, let's install the ROS Node: http://wiki.ros.org/joy
Joy is a great node for reading joystick data. The page says it can use the Xbox Wireless Controller for both Windows and Linux! I think they're talking about the 360, but we're going to try with the Xbox One controller.
sudo apt install ros-melodic-joy
That was easy! Now for the hard part, get the controller to connect to Linux. Yes. Apparently this is the hard part somehow, so we're going to watch a video.
This is the controller we have: https://www.amazon.com/gp/product/B01LPZM7VI/ref=ppx_yo_dt_b_search_asin_title?ie=UTF8&psc=1
It is compatible with Xbox One S, X and Windows meaning I think it will work with the above tutorial. Now let's get this thing connected.
HAHA THE LIGHT GOES SOLID. Okay let's try the joy node. We'll follow this: http://wiki.ros.org/joy/Tutorials/ConfiguringALinuxJoystick
Andddd.... the joystick is wirelessly connected AND we are getting data. That was quick. I want to restart and see if the joystick thing still works. We did a permissions change. We're going to shut-down. And then turn everything back on.
Okay good news, we turn on and the Xbox controller light goes solid. Now let's launch ROS. HAHA it works! Pretty good day, both the things we did worked.