Where communities thrive


  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
People
Repo info
Activity
  • 09:00
    vooon labeled #1625
  • 09:00
    vooon labeled #1625
  • 07:48
    mortenfyhn opened #1625
  • 06:58
    vooon commented #1624
  • 06:54
    vooon labeled #1624
  • 06:54
    vooon labeled #1624
  • Sep 21 23:41
    marcelino-pensa opened #1624
  • Sep 21 06:23
    hichamhendy commented #1425
  • Sep 20 16:14

    vooon on master

    sys_time.cpp: typo MountControl.msg: fix copy-paste Merge pull request #1623 from a… (compare)

  • Sep 20 16:14
    vooon closed #1623
  • Sep 20 16:14
    vooon labeled #1623
  • Sep 20 16:14
    vooon milestoned #1623
  • Sep 20 15:03
    amilcarlucas opened #1623
  • Sep 18 16:43
    dzywater commented #1369
  • Sep 14 17:43
    TSC21 commented #1369
  • Sep 14 17:42
    TSC21 commented #1369
  • Sep 14 17:40
    TSC21 commented #1369
  • Sep 14 17:40
    TSC21 commented #1369
  • Sep 14 17:27
    vooon commented #1369
  • Sep 14 17:26
    vooon commented #1369
Abhiram Dapke
@abhiramdapke

Mavros: 1.5
ROS: Melodic
Ubuntu: 18.04

[ Y ] ArduPilot

Hi guys,
I am trying to implement a GPS function since many days by passing multiple waypoints to the drone using mavros and would like to implement it with a real drone with a companion computer. Currently, I am trying to accomplish it in the simulation space(Gazebo). I am using mavros_msgs::globalpositiontarget msg to pass the waypoints and sensor_msgs::NatSatFix to get the location of the drone.

The subscriber callback for getting the global position is -

void globalPosition_cb(const sensor_msgs::NavSatFix::ConstPtr& msg) {
global_position = *msg;
gps_position_received = true;
ROS_INFO("Received global position: [%f, %f, %f]", global_position.latitude, global_position.longitude, global_position.altitude);
}
For this, the subscriber is -

ros::Subscriber global_pos_sub = waypoint_node.subscribe<sensor_msgs::NavSatFix>("mavros/global_position/global", 10, globalPosition_cb);
The function for the waypoint is -

void set_waypoint(float lat, float lon, float alt)
{
mavros_msgs::GlobalPositionTarget goal_position;
goal_position.coordinate_frame = goal_position.FRAME_GLOBAL_TERRAIN_ALT;
goal_position.type_mask = goal_position.IGNORE_VX | goal_position.IGNORE_VY | goal_position.IGNORE_VZ | goal_position.IGNORE_AFX | goal_position.IGNORE_AFY | goal_position.IGNORE_AFZ | goal_position.IGNORE_YAW | goal_position.IGNORE_YAW_RATE;
goal_position.latitude = lat;
goal_position.longitude = lon;
goal_position.altitude = alt;
global_pos_pub_gps.publish(goal_position);
}
For this, the Publisher is -

ros::Publisher global_pos_pub_gps = waypoint_node.advertise<mavros_msgs::GlobalPositionTarget>("/mavros/setpoint_raw/global",10);
A snippet of the script that I am using is like this -

struct waypoint
{
float lat;
float lon;
float alt;
};
ros::Rate rate(2.0);
wait4connect();
wait4start();

takeoff(5);
sleep(4);

std::vector<waypoint> waypointlist;
waypoint nextwp;
nextwp.lat = 0;
nextwp.lon = 0;
nextwp.alt = 5;
waypointlist.push_back(nextwp);

nextwp.lat = -35.3613525;
nextwp.lon = 149.1579742;
nextwp.alt = 5;
waypointlist.push_back(nextwp);

nextwp.lat = -35.3613530;
nextwp.lon = 149.1579735;
nextwp.alt = 5;
waypointlist.push_back(nextwp);

nextwp.lat = -35.3613535;
nextwp.lon = 149.1579730;
nextwp.alt = 5;
waypointlist.push_back(nextwp);

int i = 0;
//wait for position information
while(ros::ok() && !gps_position_received) 
{
ROS_INFO_ONCE("Waiting for GPS signal");
    ros::spinOnce();
    rate.sleep();

    ROS_INFO_ONCE("GPS position received");

if(i < waypointlist.size())
{
    set_waypoint(waypointlist[i].lat,waypointlist[i].lon,waypointlist[i].alt);
    ROS_INFO("GPS position sent: [%f %f %f]", waypointlist[i].lat, waypointlist[i].lon, waypointlist[i].alt);
    i++;
    sleep(4);
    /*while (waypoint_reached(waypointlist[i].lat, waypointlist[i].lon)!= 1)    
    {        
    if (waypoint_reached(waypointlist[i].lat, waypointlist[i].lon)== 1)
    {
        i++;
        break;
    }
    else
    {
        continue;        
    }}*/
    //sleep(5);    
}
else
{
    land();
} 

}
return 0;

}
For checking if the waypoint is reached, I am using Haversine's formula to get the distance between two GPS waypoints like this. It is taking the target location and subtracting that from the current location(which is derived from the global_Position_cb) -

bool waypoint_reached(float tlat, float tlon)
{
double pi = 3.14159265359;
double degToRad = pi/180.0;

//Haversine Formula - Calculate great-circle distance betweeen two points
float currentLat = global_position.latitude;
float currentLong = global_position.longitude;

double eLat = degToRad*(tlat - currentLat);
double eLong = degToRad*(tlon - currentLong);

double a = sin(eLat/2)*sin(eLat/2) + cos(degToRad*currentLat)*cos(degToRad*tlat)*sin(eLong/2)*sin(eLong/2);
double c = 2*atan2(sqrt(a),sqrt(1-a));
float dist = (float) (6371000 * c);

double tolerance = 0.3;

if (abs(dist) < tolerance)
{
  ROS_INFO_ONCE("Provided waypoint reached");
  return true;
}
else
{
   return false;
}

}
There are a multitude of issues I am facing -

when I run the above script, the drone takes-off at the provided altitude but before reaching that altitude, it starts navigating towards the waypoint provided by set_waypoint. so, it doesn't actually reach the given altitude i.e. the function doesn't get completed thoroughly but the program moves on to the next line. I am using a temporary sleep() so that it reaches the provided altitude but need a more concrete solution.

The same is happening with the set_waypoint function. On the terminal, I get ROS_INFO("GPS position sent: [%f %f %f]", waypointlist[i].lat, waypointlist[i].lon, waypointlist[i].alt) msg for all the 4 waypoints almost immediately so what happens is that the drone doesn't reach the provided waypoint and turns around towards the next one. Set_waypoint is not getting completed and the program is moving to the next line. I surmised this might be because of the while(rosok()) loop and the rate set for receiving msgs but couldn't figure out a workaround. That is why I wrote a waypoint_reached function to check if the waypoint is actually reached before the program moves ahead. Not sure if anything is wrong with the logic of the set_waypoint or the waypoint_reached function or implementation of both of them. When running this program with the waypoint_reached function uncommented, I only get GPS position sent: once and nothing happens after that as the drone is flying off to the waypoint.

Echoing the topic /mavros/global_position/global fluctuates the lat lon values and those values are not necessarily within the waypoints specified. I suppose the home position in gazebo is lat = -35.362 and lon = 149.161 because that's what I get when I echo this topic. Not sure how the gazebo sets its home position and whether it is possible to visualize the drone actually moving to multiple waypoints in the gazebo in WGS84. The reason I say this is because no matter what waypoint is provided to the set_waypoint, it goes in the direction of the waypoint indefinitely. I am not sure if the drone will stop after reaching that waypoint or just crash.

Echoing the topic /mavros/global_position/global shows an altitude of 608m but the drone rises to only 5m with the takeoff client. I found an issue on Github that mentions that the altitude is either in ASML or WGS84 which might cause an issue but didn't find a solution to fix it so that I can visualize the correct altitude in the gazebo during the simulation.

In the rqt graph, I am not sure is everything is connected where it needs to be. If you could confirm that, that would be great. Also, what is /rostopic_10114_161547 and /rostopic_10144_161547?

rosgraph.png
I am working on these for the past few weeks and not yet able to accomplish a working GPS function so any insights or guidance would be really helpful.
Mor
@Heymor

ROS: Melodic
Ubuntu: 18.04

I have a quick question regarding the usage of the tgt_system parameter.

I have a companion computer that is connected to another computer and the PX4, it acts as the bridge, like: PX4 --TELEM2-> companion computer --SERIAL-> 2nd computer

The companion computer sends both the mavlink messages coming from the PX4 and the mavlink messages its generating to the 2nd computer through serial, where mavros is running. I've set the tgt_system parameter to the PX4's system id, but mavros still uses the messages from the companion computer (for example, /mavros/imu/data has a publishing rate of 150Hz, which is from mavros using messages from the companion computer and the PX4.

Is there a way for mavros to ignore the companion computer? It has a totally different system_id from the companion computer.

Vladimir Ermakov
@vooon
@Heymor most of mavros v1 plugins don't filter messages
only ros2 version have that by default
perhaps you could use mavlink-router to separate streams
Mor
@Heymor
@vooon Hey - thank you for the info and for the help!
Nicolai Haastrup Knudsen
@Niknu

Hi there,

Is the data from the IMU on MAVROS topic with or withOUT correction of the drift?

Shoghairg
@Shoghairg
Hello. Is there a way to rename the frames when running mavros? so tf tree doesn't clash with multiple vehicles.
Vladimir Ermakov
@vooon
@Niknu as i remember it's close to raw data readings, if you need fused data then you'd better use local position
@Shoghairg should be possible, but you have to edit several parameters. Better look into plugin sources, documentation at ros wiki stale
Caleb Martin
@caleb272
Does anyone know if you can run mavros/mavlink over via UAVCAN on a can BUS ?
More specifically I want to use mavros on a RPI talking to a PX4 via the CAN bus and some other nodes on the network will be using UAVCAN
Gabriel Sher
@ghsher
Hi, is it possible to use the functionality of mavros in another node/package to translate custom messages from the rest of my ROS stack into standard MAVLink messages for communication over UDP/radio?
It feels like it should be but I'm struggling to find anything in the docs about using it this way (as opposed to having a mavros node, or changing our whole stack to use mavlink message formats throughout)
Vicidel
@Vicidel
Hello all, I have MAVROS node crashing multiple times. One possible source of the issue I found is that another node was calling /param/pull with a relatively high frequency. What is supported in MAVROS relative to multiple service calls (to the same server) at the same time?
Harshil Naik
@HarshilNaikk

Hello All, I am using a Pixhawk Cube Orange, and trying to connect it to an Intel NUC using a USB-to-TTL Connector (Tx to Rx, Rx to Tx and GND to GND).
I setup the correct firmware on the cube and calibrated all its sensors.
After this, I launch mavros on the companion computer using the px4.launch file, but I am not getting the Heartbeat detected message on the terminal.
(I have setup the correct parameters regarding the MAV_1 instance and the SER_2 baud rate is the same as that written in the launch file.) I have also given full sudo access to the USB0 port that is detected everytime I plug in the USB-to-TTL cable.

Thank you for any help in advance!

My launch file:

<launch>
<!-- vim: set ft=xml noet : -->
<!-- example launch script for PX4 based FCU's -->

<arg name="fcu_url" default="serial:///dev/ttyUSB0:921600" />
<arg name="gcs_url" default="@localhost" />
<arg name="tgt_system" default="1" />
<arg name="tgt_component" default="1" />
<arg name="log_output" default="screen" />
<arg name="fcu_protocol" default="v2.0" />
<arg name="respawn_mavros" default="false" />

<include file="$(find mavros)/launch/node.launch">
<arg name="pluginlists_yaml" value="$(find mavros)/launch/px4_pluginlists.yaml" />
<arg name="config_yaml" value="$(find mavros)/launch/px4_config.yaml" />

<arg name="fcu_url" value="$(arg fcu_url)" />
<arg name="gcs_url" value="$(arg gcs_url)" />
<arg name="tgt_system" value="$(arg tgt_system)" />
<arg name="tgt_component" value="$(arg tgt_component)" />
<arg name="log_output" value="$(arg log_output)" />
<arg name="fcu_protocol" value="$(arg fcu_protocol)" />
<arg name="respawn_mavros" default="$(arg respawn_mavros)" />
</include>
</launch>

Harshil Naik
@HarshilNaikk
@vooon @khancyr @TSC21
Abdulsamet TÜTÜNCÜ
@abdupa61

I think you need to run sim_vehicle.py first, then try to launch apm.launch... I hope this helps...

Thank You @atahabaki I solved it.

Hello All, I am using a Pixhawk Cube Orange, and trying to connect it to an Intel NUC using a USB-to-TTL Connector (Tx to Rx, Rx to Tx and GND to GND).
I setup the correct firmware on the cube and calibrated all its sensors.
After this, I launch mavros on the companion computer using the px4.launch file, but I am not getting the Heartbeat detected message on the terminal.
(I have setup the correct parameters regarding the MAV_1 instance and the SER_2 baud rate is the same as that written in the launch file.) I have also given full sudo access to the USB0 port that is detected everytime I plug in the USB-to-TTL cable.

Thank you for any help in advance!

My launch file:

<launch>
<!-- vim: set ft=xml noet : -->
<!-- example launch script for PX4 based FCU's -->

<arg name="fcu_url" default="serial:///dev/ttyUSB0:921600" />
<arg name="gcs_url" default="@localhost" />
<arg name="tgt_system" default="1" />
<arg name="tgt_component" default="1" />
<arg name="log_output" default="screen" />
<arg name="fcu_protocol" default="v2.0" />
<arg name="respawn_mavros" default="false" />

<include file="$(find mavros)/launch/node.launch">
<arg name="pluginlists_yaml" value="$(find mavros)/launch/px4_pluginlists.yaml" />
<arg name="config_yaml" value="$(find mavros)/launch/px4_config.yaml" />

<arg name="fcu_url" value="$(arg fcu_url)" />
<arg name="gcs_url" value="$(arg gcs_url)" />
<arg name="tgt_system" value="$(arg tgt_system)" />
<arg name="tgt_component" value="$(arg tgt_component)" />
<arg name="log_output" value="$(arg log_output)" />
<arg name="fcu_protocol" value="$(arg fcu_protocol)" />
<arg name="respawn_mavros" default="$(arg respawn_mavros)" />
</include>
</launch>

Hello All, I am using a Pixhawk Cube Orange, and trying to connect it to an Intel NUC using a USB-to-TTL Connector (Tx to Rx, Rx to Tx and GND to GND).
I setup the correct firmware on the cube and calibrated all its sensors.
After this, I launch mavros on the companion computer using the px4.launch file, but I am not getting the Heartbeat detected message on the terminal.
(I have setup the correct parameters regarding the MAV_1 instance and the SER_2 baud rate is the same as that written in the launch file.) I have also given full sudo access to the USB0 port that is detected everytime I plug in the USB-to-TTL cable.

Thank you for any help in advance!

My launch file:

<launch>
<!-- vim: set ft=xml noet : -->
<!-- example launch script for PX4 based FCU's -->

<arg name="fcu_url" default="serial:///dev/ttyUSB0:921600" />
<arg name="gcs_url" default="@localhost" />
<arg name="tgt_system" default="1" />
<arg name="tgt_component" default="1" />
<arg name="log_output" default="screen" />
<arg name="fcu_protocol" default="v2.0" />
<arg name="respawn_mavros" default="false" />

<include file="$(find mavros)/launch/node.launch">
<arg name="pluginlists_yaml" value="$(find mavros)/launch/px4_pluginlists.yaml" />
<arg name="config_yaml" value="$(find mavros)/launch/px4_config.yaml" />

<arg name="fcu_url" value="$(arg fcu_url)" />
<arg name="gcs_url" value="$(arg gcs_url)" />
<arg name="tgt_system" value="$(arg tgt_system)" />
<arg name="tgt_component" value="$(arg tgt_component)" />
<arg name="log_output" value="$(arg log_output)" />
<arg name="fcu_protocol" value="$(arg fcu_protocol)" />
<arg name="respawn_mavros" default="$(arg respawn_mavros)" />
</include>
</launch>

Take a look to this tutorial. https://github.com/DiegoHerrera1890/Pixhawk-connected-to-Jetson-Tx2-devkit

Abdulsamet TÜTÜNCÜ
@abdupa61
Hello guys I have a question. I am using px4 and trying to move frame's X and Y axis but I can not do that with using Twist () linear.x. With this func. my drone goes to global X and Y axis. But I wanna move my copter on its own X axis. How can I do that? I did not really get the difference between PositionTarget and Twist. Is the correct func. Position Target? If it is not what is the way that move drone with giving velocity (speed) ? I really need help quickly.
Abdulsamet TÜTÜNCÜ
@abdupa61

Hi,

I would like to use raw GPS velocity data from the flight controller in my companion computer. On the ROS page (http://wiki.ros.org/mavros) I see mavros publishes the following message:

~global_position/raw/gps_vel (geometry_msgs/TwistStamped)
    Velocity output from the GPS device.

This message has data fields twist.linear.x and twist.linear.y. To what axes to these x and y refer? Body frame or world frame? ENU or NED or ...?

(PS: first time on Gitter, I hope I'm using it correctly)

Did You solved that How we can move px4 on frame's X and Y axis? What is the correct way?

Jaime Machuca
@jmachuca77
Did you check what mav frame you are sending the command in?
Abdulsamet TÜTÜNCÜ
@abdupa61
Ok, Sir! I solved it. Thank You for answering.
MUHAMMEDZEYN
@MUHAMMEDZEYN
Hi,
did anyone use MAVROS for vtol configuration ?
if so how did you do the transitions can you tell me the commands that you used
kentoku24
@kentoku24
Hi,
I am struggling with sending/receiving custom message from ROS to PX4, does anyone know nice tutorial page for this?
jlandau10
@jlandau10

Hello i am trying to use Mavros to set a Cube Orange into auto mode on a loaded mission. Right now the system status only changes to 4 if i use the handheld controller, or the first time i try to run the mavros code AFTER having used the handheld controller. It seems theres a step or setting i'm missing but I can't figure it out.

Ros Melodic on Ubuntu 18.04

using px4.launch

DoneMan
@DoneMan
Hello all, I'm trying to fake a OBSTACLE_DISTANCE message using mavros topic: /mavros/obstacle/send.
The drone is not responding to this message being published even though I enabled bendy ruller on fcu
Does any one know how this should be done?
v-to
@v-to
@mkoos Hi, did you figure out anything with this boat? We have exactlyy the same problem
Abhiram Dapke
@abhiramdapke
Hello all,
I had a quick question. Is there any range for setting the stream rate for IMUs on a drone by using 'rosrun mavros mavsys rate --all 10'?? I found on many forums that it is between 10 to 30 hertz. Would it be possible to set it more than 30hz for the sake of a project?
Thanks.
Jaime Machuca
@jmachuca77
If you at wising Ardupilot I have been able to get up to 250hz but you have to use the. Per message stream rate and just increase it on the IMU messages. Also have to increase the scheduler rate
Abhiram Dapke
@abhiramdapke
@jmachuca77 Thanks for the quick response. I haven't made any changes in Ardupilot yet. Is there a simple way to do it? In other words, my question is: If I use 'rosrun mavros mavsys rate --all 80' or 100', would it solve the problem? would it cause any issue in the mavros node like high IMU res error etc? I know this stream rate is for all the messages that's why I am not sure if that is okay.
Jaime Machuca
@jmachuca77
@abhiramdapke rosservice call /mavros/set_stream_rate "stream_id: 0
message_rate: 0
on_off: false"
stream_id is the mavlink id of the message
This is only supported by Ardupilot, not PX4
Abhiram Dapke
@abhiramdapke
Thanks. I'll try it out. I am using Ardupilot only.
Souf
@soufi

Hi mav-people, hope you all keeping safe.
I've been playing with SITL and mavros for a little while on my virtual machine.
now i'm trying to connect a raspberrypi with a SITL (running on virtual machine). I use roslaunch with mavros to run the apm.launch file and I set the fcu_url with the correct ip (on idp) and correct port range : udp://192.168.0.22:14550@14551
but this doesn't work ... I have this error :
[FATAL] [1626267950.410009640]: FCU: DeviceError:udp:bind: Cannot assign requested address

When I try with fcu_url like this : udp://:14560@192.168.0.22:14550
roslaunch succefully launches, but it doesn't connect to any channel, therefore I have no events coming from the master node running on the raspberry ...

can anybody provide some guidance on this ?
thank you

Jaime Machuca
@jmachuca77
Sito doesn’t open that port by dafault you would have to add the output in mavproxy
1 reply
Jaime Machuca
@jmachuca77
The udp port
Souf
@soufi

Hi, @jmachuca77

it opens 14550 and 14551 on --out that's why I tested using that one (or did I miss something ?)

I couldn't connect the rasp directly with SITL, so I tried differently :

I'm running a mavros node created using the apm.launch file provided for ardupilot. ROS Master is running on a virtualbox VM (bridge mode, e.g the vm has its own ip addr in the network just like any other regular machine). It works flawlessly.

I have a code that connects a node and subscribe to topics under /mavros , like battery or other... When I run this code from the host machine, everything works smoothly.
When I run the same code from my raspberry pi (which is connected to the same network) the node is created, but I get no updates for the topics....
I followed the http://wiki.ros.org/ROS/NetworkSetup
I ran roswtf and the only thing I got is this :

WARNING The following nodes are unexpectedly connected:
 * unknown (http://192.168.0.41:41311/)->/rosout (/rosout)

192.168.0.41 is my rasp ip addr

I've searching for days now, and I can't figure out why I can't get update for my subscribed topics even though I'm able to get them with rostopics echo etc ....

any hint or idea is much appreciated
gamoreno
@gamoreno
Hi. I'm trying to use the mavros HilGPS to send HIL_GPS messages to AP. It works, but when the drone takes of, it fails because of EKF velocity variance. I think the issue is with the velocity, because HilGPS.vel is an uint16_t, which then gets multiplied by 100 in the mavros hil plugin to send it in cm/s. That means that it is not possible to send a velocity of let's say 50 cm/s using mavros HilGPS and the hil pluging. Am I misunderstanding something? Is there a workaround?
John Ericksen
@johncarl81
I posted a question here about using setpoint_position/local and local_position/pose, and I could use some help: https://discuss.ardupilot.org/t/mavros-setpoint-position-local-acceptance/74497
Seyyed Hossein Hasanpour
@Coderx7

Hello everyone.
I have been trying to learn more about fake GPS and how I can use/implement it in mavros for the last couple of days now, without any luck.
I want to use the generated GPS coordinates instead of the real GPS sensor. I'm currently working on an approach that uses visual cues to approximate GPS coordinate. For now, I just use static GPS coordinate in a test mavros application. I dont know how I'm supposed to publish them aside from mavros/global_position/global topic.
This is the sample app:

#include <ros/ros.h>
#include <sensor_msgs/NavSatFix.h>

//http://wiki.ros.org/mavros
int main(int argc, char **argv)
{
    ros::init(argc, argv, "offb_node_gps_publisher");
    ros::NodeHandle nh;
    ros::Publisher pub_global_gps = nh.advertise<sensor_msgs::NavSatFix>("mavros/global_position/global", 10);
    sensor_msgs::NavSatFix gps_target;
    //the setpoint publishing rate MUST be faster than 2Hz
    ros::Rate rate(20.0);

    int i = 0;
    while (ros::ok())
    {
        gps_target.header.stamp = ros::Time::now();
        gps_target.header.frame_id = "map";
        gps_target.header.seq = i++;
        //https://answers.ros.org/question/10310/calculate-navsatfix-covariance/
        gps_target.position_covariance_type = gps_target.COVARIANCE_TYPE_DIAGONAL_KNOWN;
        // Sample covariance taken from fake gps. we either should use Unknown, or 
        // COVARIANCE_TYPE_APPROXIMATED and comeup with a proper covariance?
        gps_target.position_covariance = {1, 0, 0, 0, 1, 0, 0, 0, 1};
        gps_target.status.status = sensor_msgs::NavSatStatus::STATUS_FIX;
        gps_target.status.service = sensor_msgs::NavSatStatus::SERVICE_GPS;
        gps_target.latitude = 20;
        gps_target.longitude = 20;
        gps_target.altitude = 10;
        pub_global_gps.publish(gps_target);

        ros::spinOnce();
        rate.sleep();
    }
    return 0;
}

I'm currently using gazebo for the simulation and noticed, when running gazebo, gps coordinates are being published on global_position/global topic as well(from gazebo i guess), nullifying my gpu coordinates. also I cant test everything and see whats missing and whats not.
Can anyone please tell me what I should do? is there any example for this?
Any help is greatly appreciated.