Ask Your Question

Rika's profile - activity

2021-11-22 08:03:18 -0600 received badge  Famous Question (source)
2021-10-12 04:27:22 -0600 received badge  Notable Question (source)
2021-09-20 05:54:12 -0600 received badge  Notable Question (source)
2021-09-20 05:54:12 -0600 received badge  Popular Question (source)
2021-09-20 05:54:12 -0600 received badge  Famous Question (source)
2021-08-10 22:04:21 -0600 commented question Sending hil_gps msg with mavros

Did you guys manage to do this?

2021-08-10 01:45:58 -0600 marked best answer Tried to advertise on topic [/mavros/setpoint_position/global] with md5sum [07...] and datatype [mavros_msgs/GlobalPositionTarget], but the topic is already advertised as md5sum [cc...] and datatype [geographic_msgs/GeoPoseStamped]

Hi everyone, I have been trying to set a GPS position by setting mavros/setpoint_position/global, but faced with this error message:

 [ERROR] [1628412556.927932932]: Tried to advertise on topic [/mavros/setpoint_position/global] with md5sum [076ded0190b9e045f9c55264659ef102] and datatype [mavros_msgs/GlobalPositionTarget], but the topic is already advertised as md5sum [cc409c8ed6064d8a846fa207bf3fba6b] and datatype [geographic_msgs/GeoPoseStamped]
[ INFO] [1628412557.179607573]: Connected to PX4!

What is wrong here?
Based on the documentation which seems to be wrong bye the way, I had to use mavros_msgs/GlobalPositionTarget but doing so, results in failure of the application in runtime and instead I'm instructed to use geographic_msgs/GeoPoseStamped instead. now that I use this, when I subscribe to mavros/global_position/global I get the stated error.

in case it matters, this is my node that sets the gps position:

#include <limits>
#include <ros/ros.h>
#include <sensor_msgs/NavSatFix.h>
#include <geographic_msgs/GeoPoseStamped.h>
#include <mavros_msgs/GlobalPositionTarget.h>

//http://wiki.ros.org/mavros
int main(int argc, char **argv)
{
    ros::init(argc, argv, "offb_node22");
    ros::NodeHandle nh;

    //set gps 
    //setpoint_position/global
    ros::Publisher pub_global_gps = nh.advertise<geographic_msgs::GeoPoseStamped>("mavros/setpoint_position/global", 10);
    geographic_msgs::GeoPoseStamped gps_target;

    //the setpoint publishing rate MUST be faster than 2Hz
    ros::Rate rate(20.0);

    // wait for GPS connection
    while(ros::ok()) 
    {
        gps_target.header.stamp = ros::Time::now();
        gps_target.header.frame_id = "base_link";

        gps_target.pose.position.altitude = 10;
        gps_target.pose.position.latitude = 10;
        gps_target.pose.position.longitude = 10;

        pub_global_gps.publish(gps_target);

        ros::spinOnce();
        rate.sleep();
    }
    return 0;
}
2021-08-09 00:50:30 -0600 commented answer how to use the sensor_msgs/NavSatStatus ?

Thanks a lot, it fixed my confusion as well.

2021-08-08 14:54:41 -0600 received badge  Popular Question (source)
2021-08-08 05:28:38 -0600 edited question How can I disable GPS in ros/mavros and sent the points myself?

How can I disable GPS in ros/mavros and sent the points myself? Hello everyone, hope you are doing great. I created a s

2021-08-08 05:21:54 -0600 asked a question How can I disable GPS in ros/mavros and sent the points myself?

How can I disable GPS in ros/mavros and sent the points myself? Hello everyone, hope you are doing great. I created a s

2021-08-08 04:37:38 -0600 asked a question Tried to advertise on topic [/mavros/setpoint_position/global] with md5sum [07...] and datatype [mavros_msgs/GlobalPositionTarget], but the topic is already advertised as md5sum [cc...] and datatype [geographic_msgs/GeoPoseStamped]

Tried to advertise on topic [/mavros/setpoint_position/global] with md5sum [07...] and datatype [mavros_msgs/GlobalPosit

2021-08-07 21:42:03 -0600 edited question Why does my quadrotor becomes unstable after turning?

Why does my quadrotor becomes unstable after turning? Hello everyone, hope you are all having a great time. I'm trying

2021-08-07 21:36:14 -0600 asked a question Why does my quadrotor becomes unstable after turning?

Why does my quadrotor becomes unstable after turning? Hello everyone, hope you are all having a great time. I'm trying

2021-08-07 07:13:53 -0600 commented answer How can we create a fake gps publisher node in ROS2 ?

Hi, thanks a lot for this but do you happen to know if this also works in ROS1?

2021-08-02 01:24:32 -0600 received badge  Organizer (source)
2021-08-01 23:29:55 -0600 edited question ninja: error: 'devel/lib/libgflags.so', needed by 'devel/lib/libgflags_catkin.so', missing and no known rule to make it

ninja: error: 'devel/lib/libgflags.so', needed by 'devel/lib/libgflags_catkin.so', missing and no known rule to make it

2021-08-01 23:28:27 -0600 asked a question ninja: error: 'devel/lib/libgflags.so', needed by 'devel/lib/libgflags_catkin.so', missing and no known rule to make it

ninja: error: 'devel/lib/libgflags.so', needed by 'devel/lib/libgflags_catkin.so', missing and no known rule to make it

2021-08-01 01:28:15 -0600 received badge  Notable Question (source)
2021-07-09 13:22:39 -0600 received badge  Notable Question (source)
2021-07-08 09:22:21 -0600 received badge  Notable Question (source)
2021-07-07 23:48:42 -0600 received badge  Nice Question (source)
2021-07-07 08:15:30 -0600 received badge  Popular Question (source)
2021-07-07 05:09:16 -0600 received badge  Notable Question (source)
2021-07-07 04:19:53 -0600 edited answer tf2 tutorial: follower turtle makes circles, doesn't follow leader

OK I found where my problem had stemmed from. The code here is OK as others kindly pointed out in the comments. what was

2021-07-07 04:08:16 -0600 commented answer Why should tf2_ros::TransformBroadcaster be defined as static?

Thanks a lot. really appreciate your kind and thorough explanation :) yes, I'll update my previous comment there as wel

2021-07-07 04:06:35 -0600 marked best answer Why should tf2_ros::TransformBroadcaster be defined as static?

Hello everyone, this is a followup question to this one.
To cut a long story short, I found out (the hardway!) that if I do not use a static/single instance of broadcaster, the turtles will act erratically, going in circles.
If I only use a static instance, it works just fine. I read the tutorials about tf2, but there is no explanation about this.
Why is that? Could someone kindly explain whats happening here?
Thanks a lot in advance

2021-07-07 01:08:02 -0600 marked best answer tf2 tutorial: follower turtle makes circles, doesn't follow leader

Hello all. I was following the TF2 tutorial and reached the listener part. I have implemented the code accordingly but I noticed my outcome is very different than the one shipped with :

sudo apt-get install ros-$ROS_DISTRO-turtle-tf2 ros-$ROS_DISTRO-tf2-tools ros-$ROS_DISTRO-tf

Before I continue more, here is what I have written so far:

#include <iostream>
#include <string>
#include <functional>

#include <ros/ros.h>
#include <tf2_ros/transform_listener.h>
#include <turtlesim/Spawn.h>
#include <geometry_msgs/Twist.h>
#include <geometry_msgs/TransformStamped.h>

int main(int argc, char **argv)
{
    ros::init(argc, argv, "tf2_demo_listener_node");
    ros::NodeHandle n;

    ros::service::waitForService("spawn");
    ros::ServiceClient spawner = n.serviceClient<turtlesim::Spawn>("spawn");
    turtlesim::Spawn turtle;

    turtle.request.x = 2;
    turtle.request.y = 2;
    turtle.request.theta = 0;
    turtle.request.name = "turtle2";

    spawner.call(turtle);

    ros::Publisher publisher = n.advertise<geometry_msgs::Twist>("turtle2/cmd_vel", 10);

    tf2_ros::Buffer buffer;
    tf2_ros::TransformListener listener(buffer);
    ros::Rate rate(10.0);

    while (n.ok())
    {
        geometry_msgs::TransformStamped transform_stamped;
        try
        {
            transform_stamped = buffer.lookupTransform("turtle2", "turtle1", 
                                               ros::Time(0),
                                               ros::Duration(0.1));           
        }
        catch (const std::exception &e)
        {
            ROS_WARN(e.what());
            ros::Duration(0.2).sleep();
            continue;
        }

        geometry_msgs::Twist vel_msg;

        //Note
        // here we are converting the cartesian coordinate (x,y) to polar coordinates(r,theta):
        // for theta we have arctan(y,x) which would be atan2(y,x) (its in radian) and
        // for r we have sqrt(x^2 + y^2)

        auto theta_radian = atan2(transform_stamped.transform.translation.y, 
                                  transform_stamped.transform.translation.x);
        auto r = sqrt(pow(transform_stamped.transform.translation.x, 2) +  
                      pow(transform_stamped.transform.translation.y, 2));

        vel_msg.angular.z = 4.0 * theta_radian; //4.0 1.0
        vel_msg.linear.x = 0.5 * r;
        publisher.publish(vel_msg);

        rate.sleep();

    }
    return 0;
}

Now if I run this this is the pattern I get :

image description

and ultimately it ends up spinning next to the turtle1 like this:

image description

Now if I run the roslaunch turtle_tf2 turtle_tf2_demo.launch it performs neatly and nicely follows the turtle1 everywhere until it reaches to it: image description

now my question is, what is it that I'm doing wrong that does not yield the very same result? seemingly the codes are the same(although implemented in different languages (c++ vs python), however the effect is very different.

What am I missing here?

2021-07-07 00:41:32 -0600 asked a question Why should tf2_ros::TransformBroadcaster be defined as static?

Why should tf2_ros::TransformBroadcaster be defined as static? Hello everyone, this is a followup question to this one.

2021-07-07 00:22:11 -0600 commented question tf2 tutorial: follower turtle makes circles, doesn't follow leader

Thank you both very much. yes you were right the problem was somewhere else. I posted an answer below. but I'd also appr

2021-07-07 00:20:05 -0600 edited answer tf2 tutorial: follower turtle makes circles, doesn't follow leader

OK I found where my problem had stemmed from. The code here is OK as others kindly pointed out in the comments. what was

2021-07-07 00:17:51 -0600 received badge  Rapid Responder (source)
2021-07-07 00:17:51 -0600 answered a question tf2 tutorial: follower turtle makes circles, doesn't follow leader

OK I found where my problem had stemmed from. The code here is OK as others kindly pointed out in the comments. what was

2021-07-06 22:10:25 -0600 received badge  Popular Question (source)
2021-07-06 04:13:13 -0600 edited question tf2 tutorial: follower turtle makes circles, doesn't follow leader

Why do I see lots of cicular movements when one robot needs to follow the other one? Hello all. I was following the TF2

2021-07-06 04:12:20 -0600 asked a question tf2 tutorial: follower turtle makes circles, doesn't follow leader

Why do I see lots of cicular movements when one robot needs to follow the other one? Hello all. I was following the TF2

2021-07-06 03:58:21 -0600 received badge  Famous Question (source)
2021-07-05 23:37:45 -0600 edited answer tf::TransformListener results in Lookup would require extrapolation into the future. Requested time 'x' but the latest data is at time 'y', when looking up transform from frame [odom] to frame [base_footprint]

Thanks to Photon, after consulting the official documentation (Learning about tf and time (C++)) I found where my proble

2021-07-05 23:34:16 -0600 received badge  Notable Question (source)
2021-07-04 17:43:10 -0600 marked best answer tf::TransformListener results in Lookup would require extrapolation into the future. Requested time 'x' but the latest data is at time 'y', when looking up transform from frame [odom] to frame [base_footprint]

Hello everyone. I have been tyring to meddle with tf::TransformListiner and see how it works. but every time I try to run my example, I get :

Lookup would require extrapolation into the future.  Requested time 2873.875000000 but the latest data is at time 2873.867000000, when looking up transform from frame [odom] to frame [base_footprint]

I tried to set the "/amcl/transform_tolerance" to some other values (ranging from 1/10 seconds to 0.01) to no avail. This seems to have been caused by running both gazebo turtlebot3 simulation alongside rviz2 on my system (in a vmware workstation) and seems its struggling because my CPU cant handle such load and thus it introduced a small latency and messed up everything.

apart from using a more powerful PC which at the moment is not possible, what should I do ? I have read about FilterMessages`, but honestly don't know which one to use and how, since I'm not directly dealing with topics here.

note : I'm using C++ by the way in case it matters.

Any help is greatly appreciated and thank you all very much in advance.