Open abhiramdapke opened 3 years ago
/dev/ttyACM0:57600
refers to USB connection, aka the Pixhawk will communicate to your TX2i via USB at a baud rate of 57600. However, based on your current setup you are trying to communicate to the Pixhawk via UART which requires /dev/ttyS0
or whatever your UART port is. Note that there are specific baud rates which are supported by the Pixhawk (so you can't just simply define them).
Thanks for the quick response. So, if I connect the pixhawk to the localhost via USB and on the other end, pixhawk is connected to the TX2i, do I have to use /dev/ttyACM0:57600? Also, how is MAVROS starting if the fcu connection is not proper?
Thanks for the quick response. So, if I connect the pixhawk to the localhost via USB and on the other end, pixhawk is connected to the TX2i, do I have to use /dev/ttyACM0:57600? Also, how is MAVROS starting if the fcu connection is not proper?
For the first question, i do not understand why do you want to connect two computers to the Pixhawk and to answer if it will work, it depends on where you are running mavros and whether the usb port of your localhost (PC) is actually defined as ACM0. Additionally, data will not be shared between two computers. For the second question, if you notice your log you are not getting any heartbeat communication from Pixhawk. Yes mavros did run because essentially the launch command you used is a script but you can see it is not connected to the Pixhawk.
Let me clear the air a bit. I am running MAVROS commands on the Tx2i. It is connected to a monitor. Whenever I use the localhost, I use an SSH connection to the Tx2i and run the commands on the Tx2i only. Regarding the USB port on the computer, I will figure out what the name of the port is. I wanted to ask how do I check the baud rate which in this case is 57600 as I am not sure whether that is correct? Also, just wanted to confirm that I don't need a connection between the localhost and the pixhawk right? as all the commands are going to be sent to the Tx2i and tx2i will in turn send them to pixhawk. One more question I had was if I need all the components like GPS, Rc, receiver connected to the pixhawk while making this connection to the Tx2i, or will it work if I have the pixhawk without these components just for testing? and will it recognize the MAVROS commands?
Thanks.
So basically in that setup you described above, what you should do is, run mavros with fcu_url as the serial port of the TX2i instead of usb port from localhost to pixhawk (assuming you are powering it via that although the serial port of the TX2i should give it power too). Yes, you do not need a connection between Pixhawk and localhost cause mavros is running on TX2i and commands are given by TX2i to Pixhawk (the localhost is merely just a client to your TX2i to show you what is going on wiht your TX2i). The baud rate is the baud rate that is set for Pixhawk, you can check it on Mission Planner (since you are using APM). To merely connect to Pixhawk via MAVROS, you do not need the peripherals. However, for flight you will need them. In SITL (cause APM does not support HITL), you do not need them to run your code.
Thanks a lot. That helped me a lot. The fcu connection is done now and the tx2i is communicating with the pixhawk. I ran the commands on https://ardupilot.org/dev/docs/ros-connecting.html and the fcu is responding to those, however, I am not sure what are the next steps. I read this page(http://wiki.ros.org/mavros#Utility_commands) completely but it doesn't give a good description of how to use the mavlink commands. Now, my aim is to run them onto the tx2i(connected to the pixhawk of the actual drone) but could you guide me on the safety measures I should take before doing that and how do I run the commands and check if they are working properly? The link also doesn't mention HOW TO USE these commands. Also, how do I run these commands on the Arducopter (for sitl/gazebo)? because when I try to simulate it on gazebo, it opens the MAVProxy terminal which would mean I need to type the Mavproxy commands but I want to write these commands.
@abhiramdapke I think it is best if you go through ROS tutorials (do this first) and also look at PX4 offboard mode example to see how to actually send take-off arming commands and etc from TX2i to Pixhawk.
Issue details
I have a pixhawk 2.1 and Tx2i with a carrier board and have connected them with the TX,RX, GND pins and I know that the pins are correct. When running the roslaunch mavros apm.launch fcu_url:=/dev/ttyACM0:57600 command, MAVROS starts. I am not sure if the /dev/ttyACMO:57600 is correct but it starts the MAVROS. After that when I try to run any MAVROS commands like rosrun mavros mavsafety arm, I get this error - request failed. check MAVROS logs. i tried running rostopic echo -n1 /diagnostics | tee /tmp/diag.yml, and the message says FCU connection not connected. I don't understand why the FCU conection is not connected. Is it because I don't have a GPS module, RC and receiver plugged to the pixhawk? or is it the pins issue because I am sure the pins(between Tx2i and pixhawk) are correct and the pixhawk is powered by a battery properly. Also, how do I connect to the mission planner on the localhost? Can it be done without USB?
I am not sure what is going wrong here. If I use any other roslaunch command like roslaunch mavros apm.launch fcu_url:=/dev/ttyACM0:14855, I get this error - [FATAL] [1606235473.482246655]: FCU: DeviceError:serial:set_option: Invalid argument.
So, how to get the FCU connection established? what is missing? How to run Mission planner on the localhost without USB? Is it required to run with MAVROS to check the flight route?
This is the log when MAVROS doesn't start i.e. roslaunch command doesn't run:
This is the log when MAVROS runs:
MAVROS version and platform
Mavros: Latest(command line download from Ardupilot docs) ROS: Melodic Ubuntu: 18.04
Autopilot type and version
ArduPilot
Version: 4.0.3
Diagnostics