ROS Resources: Documentation | Support | Discussion Forum | Index | Service Status | ros @ Robotics Stack Exchange
Ask Your Question

EdwardNur's profile - activity

2023-06-12 10:52:58 -0500 marked best answer Cannot compile a msg file

I want to compile a ros2 msg file and my packages.xml looks like this:

<?xml version="1.0"?>
<?xml-model href="http://download.ros.org/schema/package_format3.xsd" schematypens="http://www.w3.org/2001/XMLSchema"?>
<package format="3">
  <name>rtabmap_ros</name>
  <version>0.0.0</version>
  <description>TODO: Package description</description>
  <maintainer email="abyl.ikhsanov@gmail.com">abyl</maintainer>
  <license>TODO: License declaration</license>

  <buildtool_depend>ament_cmake</buildtool_depend>
  <buildtool_depend>rosidl_default_generators</buildtool_depend>

  <depend>rclcpp</depend>
  <depend>builtin_interfaces</depend>
  <depend>rosidl_default_runtime</depend>
  <depemd>std_msgs</depemd>

  <test_depend>ament_lint_auto</test_depend>
  <test_depend>ament_lint_common</test_depend>

  <export>
    <build_type>ament_cmake</build_type>
  </export>
</package>

And part of my CMakeLists:

find_package(ament_cmake REQUIRED)
find_package(rclcpp)
find_package(cv_bridge)
find_package(sensor_msgs)
find_package(builtin_interfaces REQUIRED)
find_package(rosidl_default_generators REQUIRED)

set(msg_files
    "msg/Info.msg")

rosidl_generate_interfaces(${PROJECT_NAME}
  ${msg_files}
  DEPENDENCIES builtin_interfaces std_msgs geometry_msgs
  ADD_LINTER_TESTS
)

But in the end I am getting this error:

 Error processing 'int32 refId' of 'rtabmap_ros/Info': 'the field name
  'refId' is not valid'

Where the Info.msg is:

Header header

int32 refId
int32 loopClosureId
int32 proximityDetectionId

Also, I have tried to look for the pcl_ros in ROS2 but did not find anything. Any idea how people deal with it in ROS2?

2023-06-01 14:44:35 -0500 marked best answer Cannot create a rclcpp::spin function

Hi all,

I am having a trouble in publishing and subscribing the node at the same time. More specifically, I am having an issue to pass the shared_ptr to the rclcpp::spin function. Here is my function inside my class:

void OdomNode::update()
{
    //std::shared_ptr<rclcpp::Node> _for_spin = std::make_shared<rclcpp::Node>(*this);
    while(rclcpp::ok())
    {
        this->loop();
        this->_loop_rate.sleep();
        rclcpp::spin(*this);
    }
}

As you can see, the object itself inherits from rclcpp::Node class and this is a node instance. I have tried to use the first (uncommented) choice but it would not compile saying that the variable is private in this context (not sure what private there exactly). I have also tried to pass shared_from_this but during the runtime it crashes saying that it is a bad_weak_ptr.

2023-05-02 15:33:51 -0500 marked best answer what(): bad_weak_ptr

I have a constructor which looks like this:

OdomNode::OdomNode() : Node("odometry_node","odometry_node_ns", rclcpp::NodeOptions()), _rate(30), _ticks_meter(1), _left_pos{0},
                       _right_pos{0}, _enc_left{0}, _enc_right{0}, _lmult{0},
                       _rmult{0}, _prev_rencoder{0}, _prev_lencoder{0},
                       _d_left{0}, _d_right{0}, q{std::make_shared<tf2::Quaternion>()},
                       _base_frame_id{"base_footprint"}, _odom_frame_id{"odom"},
                       _odom_ts{std::make_shared<geometry_msgs::msg::TransformStamped>()}, _loop_rate{30},
                       _then{}, _odom_pub{}, _odom_tb{std::make_shared<tf2_ros::StaticTransformBroadcaster>(shared_from_this())}
{
    _then = this->now();
    rclcpp::QoS qos(rclcpp::KeepLast(7));
    _odom_pub = this->create_publisher<nav_msgs::msg::Odometry>("odom", qos);
    //_odom_tb = odom_tf2_broadcaster(this->);
    _rate = this->declare_parameter("rate", 30);
    _ticks_meter = this->declare_parameter("ticks_meter", 1400000);
    _base_frame_id = this->declare_parameter("base_frame", "base_footprint");

}

And I also have the loop function of that class:

 void OdomNode::update()
{
    while(rclcpp::ok())
    {
        this->loop();
        this->_loop_rate.sleep();
        rclcpp::spin(shared_from_this());
    }

Whenever I run I get an error that I have a bad_weak_ptr. I have tried to declare and initialzie the shared_ptr in my update function:

   void OdomNode::update()
    {
        std::shared_ptr<rclcpp::Node> _for_spin = std::make_shared<rclcpp::Node>(this);
        while(rclcpp::ok())
        {
            this->loop();
            this->_loop_rate.sleep();
            rclcpp::spin(_for_spin);
        }

But I get an error:

/usr/include/c++/7/ext/new_allocator.h:136:4: error: no matching function for call to ‘rclcpp::Node::Node(odom_node::OdomNode*)’
  { ::new((void *)__p) _Up(std::forward<_Args>(__args)...); }

}
2023-04-21 02:32:14 -0500 received badge  Famous Question (source)
2023-04-19 11:03:09 -0500 marked best answer Wrong constructor in ROS2

I am trying to create a constructor for my odom node but for some reason I keep getting the strange error:

 error: no matching function for call to ‘rclcpp::TimeSource::TimeSource(<brace-enclosed initializer list>)’
 odom_pub{}, _odom_tb{std::make_shared<tf2_ros::StaticTransformBroadcaster>(shared_from_this())}

The thing is that I am not even trying to pass the rclcpp::TimeSource but my compiler thinks so. I think i managed to follow the variable declaration = variable initialization order, so for example in my header:

class OdomNode : public rclcpp::Node
{

private:
    int _rate, _ticks_meter, _left_pos, _right_pos, _enc_left, _enc_right, _lmult, _rmult;
    int _prev_rencoder, _prev_lencoder;
    double _d_left, _d_right;
    std::shared_ptr<tf2::Quaternion> q;
    std::string _base_frame_id, _odom_frame_id;

    //Node
    rclcpp::TimeSource _ts;
    rclcpp::Clock::SharedPtr _clock;
    std::shared_ptr<geometry_msgs::msg::TransformStamped> _odom_ts;
    rclcpp::Rate _loop_rate;
    rclcpp::Time _then;

    // Subs and publishers:
    //rclcpp::Subscriber _left_sub;
    std::shared_ptr<rclcpp::Publisher<nav_msgs::msg::Odometry>> _odom_pub;
    std::shared_ptr<tf2_ros::StaticTransformBroadcaster> _odom_tb;

    // Known vars:
    double _x{0};
    double _y{0};
    double _th{0};
    std::vector<double> _q_imu{0,0,0,1};
    std::shared_ptr<std_msgs::msg::Float64> _state_left, _state_right;

And my cpp file:

OdomNode::OdomNode() : Node("odometry_node","odometry_node_ns", rclcpp::NodeOptions()), _rate(30), _ticks_meter(1), _left_pos{0},
                       _right_pos{0}, _enc_left{0}, _enc_right{0}, _lmult{0},
                       _rmult{0}, _prev_rencoder{0}, _prev_lencoder{0},
                       _d_left{0}, _d_right{0}, q{std::make_shared<tf2::Quaternion>()},
                       _base_frame_id{"base_footprint"}, _odom_frame_id{"odom"},
                       _ts{this}, _clock{std::make_shared<rclcpp::Clock>(RCL_ROS_TIME)},
                       _odom_ts{std::make_shared<geometry_msgs::msg::TransformStamped>()}, _loop_rate{30},
                       _then{}, _odom_pub{}, _odom_tb{std::make_shared<tf2_ros::StaticTransformBroadcaster>(shared_from_this())}
{}
2022-10-12 04:52:31 -0500 marked best answer Does stereo_proc undistort images?

I have tried to use the image_pipeline stereo_image_proc to get the rectified images. The question is, when stereo_image_proc produces image_rect images, should they be undistorted? Have a look at my screenshot:

image description

I have given the distortion matrix to the topic and I have tried to undistort the images myself and quite happy with it.

2022-10-12 04:43:16 -0500 marked best answer All spaces are occupied using RTABmap stereo

Hi,

I am trying to map the area using the stereo camera and after looking at produced map, all the cells are black, meaning occupied. I have tried to figure out for 2 days but still struggling to understand the reason.

Will it be possibe for someone to have a look at my database? I clearly doing something wrong. Also, as soon as I start RTABmap, the framerate drops to 20 hz from 30 hz and the images lag.

My RTAB database: https://drive.google.com/file/d/1sSgH...

2022-10-12 04:35:37 -0500 marked best answer Why does RTABmap subscribing to my other TF?

I have noticed some problem. When I launch RTABmap, it subscribes to my noisy_odom TF and also subscribes to filtered_odom TF and I think it makes my map being messy and sometimes I get this warning:

Rtabmap.cpp:2072::process() Rejected loop closure 1 -> 177: Not enough inliers 0/5 (matches=1) between 1 and 177

Which I guess means that RTABmap also does the visual odom which I do not want as it messes my map (even though I did not start that node).

So here is my RQT_GRAPH: image description

And in SVG format: https://drive.google.com/open?id=1yPJ...

My RTAB database if needed: https://drive.google.com/file/d/1WcAd...

And finally this is how I launch my RTABmap (note that on my remote robot I launch rtabmap/stere_sync and it sends rgbd_image topic):

<launch>
    <arg name="use_zed"         default="true"  doc="Set to false when using Intel Realsense D435"/>
    <arg name="localization"    default="false" doc="Localization mode for navigation"/>
    <arg name="database_path"   default="rtabmap.db"/>
    <arg name="rviz"            default="true"/>
    <arg name="rtabmapviz"      default="true" />
    <arg name="rate"            default="1.0"/>

    <arg name="gui_cfg"                 default="~/.ros/rtabmap_gui.ini" />

    <arg     if="$(arg localization)" name="rtabmap_args"  default=""/>
    <arg unless="$(arg localization)" name="rtabmap_args"  default="--delete_db_on_start"/>
    <arg     if="$(arg localization)" name="rviz_config"   default="$(find rtabmap_ros)/config/navigation.rviz"/>
    <arg unless="$(arg localization)" name="rviz_config"   default="$(find rtabmap_ros)/config/mapping.rviz"/>


    <arg name="input_odom"       default="/odom"/>
    <arg     if="$(arg use_zed)" name="input_image"        default="/stereo_camera/left/image_rect_color"/>
    <arg     if="$(arg use_zed)" name="input_depth"        default="/stereo_camera/depth/depth_registered"/>
    <arg     if="$(arg use_zed)" name="input_camera_info"  default="/stereo_camera/left/camera_info"/>

    <arg name="rgb_topic"               default="/rgb/image_rect_color" />
    <arg name="depth_topic"             default="/depth/depth_registered" />
    <arg name="camera_info_topic"       default="/rgb/camera_info" />
    <arg name="rgbd_topic"       default="/rgbd_image" />


    <!-- Rtabmap params -->
    <arg name="subscribe_rgbd" default="true"/>
    <arg name="stereo" default="false"/>
    <arg name="approx_sync" default="true"/>

    <!-- rgbd_sync params -->
    <arg name="compressed"              default="true"/>
    <arg name="rgb_image_transport"     default="compressed"/>
    <arg name="approx_rgbd_sync"        default="true"/>
    <arg name="rgbd_sync"               default="true"/>
    <!-- These arguments should not be modified directly, see referred topics without "_relay" suffix above -->
    <arg if="$(arg compressed)"     name="rgb_topic_relay"           default="$(arg rgb_topic)_relay"/>
    <arg unless="$(arg compressed)" name="rgb_topic_relay"           default="$(arg rgb_topic)"/>
    <arg if="$(arg compressed)"     name="depth_topic_relay"         default="$(arg depth_topic)_relay"/>
    <arg unless="$(arg compressed)" name="depth_topic_relay"         default="$(arg depth_topic)"/>
    <arg if="$(arg rgbd_sync)"      name="rgbd_topic_relay"          default="$(arg rgbd_topic)"/>
    <arg unless="$(arg rgbd_sync)"  name="rgbd_topic_relay"          default="$(arg rgbd_topic)_relay"/>

    <!-- launch rgbd_sync -->
    <node if="$(arg compressed)" name="republish_rgb" type="republish" pkg="image_transport" args="compressed in:=$(arg rgb_topic) raw out:=$(arg rgb_topic_relay)" />
    <node if="$(arg compressed)" name="republish_depth" type="republish" pkg="image_transport" args="compressedDepth in:=$(arg depth_topic) raw out:=$(arg depth_topic_relay)" />
    <node pkg="nodelet" type="nodelet" name="rgbd_sync" args="standalone rtabmap_ros/rgbd_sync" output="screen">
        <remap from="rgb/image"       to="$(arg rgb_topic_relay)"/>
        <remap from="depth/image"     to="$(arg depth_topic_relay)"/>
        <remap from="rgb/camera_info" to="$(arg camera_info_topic)"/>
        <remap from="rgbd_image"      to="$(arg rgbd_topic_relay)"/>
        <param name="approx_sync"     type="bool"   value="$(arg approx_rgbd_sync)"/>
        <param name="queue_size"      type="int"    value="100"/>
        <param name="depth_scale"     type="double" value="1 ...
(more)
2022-10-12 04:35:33 -0500 marked best answer What is the difference between velocity and effort?

I am writing a hardware interface for my 4 wheel differential robot and I came up with this tutorial: https://github.com/ros-controls/ros_c...

I understood everything except I am confused with the effort variable. Is that the PWM to the motor from 0 to 100%? If yes, why does the interface need veloicty variable?

Does it mean that the controller handles PID? By reading the velocity and effort from the motor it finds the optimal effort to send to obtain a specific cmd_vel?

2022-09-01 05:37:55 -0500 received badge  Notable Question (source)
2022-09-01 05:37:55 -0500 received badge  Famous Question (source)
2022-09-01 05:37:55 -0500 received badge  Popular Question (source)
2022-05-16 18:46:31 -0500 received badge  Famous Question (source)
2021-12-19 14:57:36 -0500 received badge  Famous Question (source)
2021-12-03 02:40:38 -0500 received badge  Popular Question (source)
2021-12-03 02:40:38 -0500 received badge  Famous Question (source)
2021-12-03 02:40:38 -0500 received badge  Notable Question (source)
2021-11-20 04:48:04 -0500 received badge  Famous Question (source)
2021-07-26 10:06:29 -0500 received badge  Nice Question (source)
2021-05-05 08:16:42 -0500 received badge  Famous Question (source)
2021-05-05 08:16:42 -0500 received badge  Notable Question (source)
2021-04-12 08:27:07 -0500 received badge  Popular Question (source)
2021-02-24 04:26:55 -0500 received badge  Famous Question (source)
2021-02-19 18:44:19 -0500 received badge  Famous Question (source)
2021-01-14 04:37:28 -0500 received badge  Notable Question (source)
2021-01-14 04:37:28 -0500 received badge  Famous Question (source)
2020-12-18 13:40:18 -0500 marked best answer Localising using RTABmap without LiDAR

Hi,

I have created a map using the depth camera (mono depth camera) and 2d Lidar. When I do the localisation, I will not have my LiDAR, so is it still possible to localise with only the depth camera? As bag-of-words should be saved anyway.

Also, I have tried to localize the robot using the depth camera but for some reason, rtabmap waits for the scan topic to be updated even though I have set subscribe_scan to False. Here is my database: https://drive.google.com/open?id=1uNq...

May be you can suggest me something? Also (if relevant), during the SLAM, I was getting these warnings and erros:

[ WARN] (2019-07-18 15:18:44.199) OptimizerG2O.cpp:698::optimize() Computing marginals: vertex 584 has negative hessian index (-1). Cannot compute last pose covariance.
[ WARN] (2019-07-18 15:18:44.216) OptimizerG2O.cpp:698::optimize() Computing marginals: vertex 454 has negative hessian index (-1). Cannot compute last pose covariance.
[pcl::IterativeClosestPoint::computeTransformation] Not enough correspondences found. Relax your threshold parameters.
2020-12-18 13:33:26 -0500 marked best answer RTABmap corrupted database

Everytime when I perfrom SLAM with RTABMAP, I get a map with some warning like:

Memory.cpp:1746::forget() Less signatures transferred (3) than added (4)! The working memory cannot decrease in size

But when I start the localization part (on a 2nd time), the database gets corrupted and I get this error everytime:

VWDictionary.cpp:616::addWordRef() Not found word

How can I fix it?

2020-12-18 13:33:19 -0500 marked best answer RTABmap deletes half of my map

Hi,

When I am doing SLAM using RTABmap, at half point, I got half of my map and rtabmap deleted some of my map for some reason, why is that? I have uplodade the database here: https://drive.google.com/file/d/15oVJ...

Also, how can I set an initial point during the localization? As rtabmap does not localize sometimes and if I click on 2dposeestimate button, nothing happens.

The last question is, how can I reduce the resolution of my map?

2020-12-18 13:31:50 -0500 received badge  Famous Question (source)
2020-12-18 13:30:31 -0500 marked best answer Unreliable UART communication in C++

I have written a small code in C++ that reads the data in serial port and sometimes writes to the serial port when the callback is being called. I am using this library in C++ for the serial communication:

http://wjwwood.io/serial/doc/1.1.0/in...

The problem I have is that sometimes the serial port stops writing to the data (does not happen often but happens) and also I need to write twice to the serial port in order for the data to be changed in the serial. For debugging purposes, I have added outputs that shows the data that has been read and the data that has been written.

Here is my code:

void UART::run()
    {

        while(ros::ok())
        {
            _letter = _serial.read();
            if (_serial.available() > 0)
            {
                _line.clear();
                _line = _serial.readline(65536, "!");
                _words.clear();
                std::istringstream f(_line);
                std::string s;
                while (getline(f,s,'\t'))
                {
                    _words.push_back(s);
                }
                this->fillVars();
                _msg.velocity = _velocity;
                _msg.position = _position;
                _pub.publish(_msg);
                ros::spinOnce();
            }
            _serial.flush();
        }
    }

    void UART::fillVars()
    {
        if (_words[0] == "u")
        {
            _ultrasonic = std::stoi(_words[1]);
        }
        else if (_words[0] == "s")
        {
            std::cout << "reading " << _words[1] << std::endl;
        }

    }


    void UART::callback(const std_msgs::Int32::ConstPtr& speed)
    {
        // Convert m/s and serial write
        _effort = speed->data - 32;
        std::string toWrite = std::to_string(_effort);
        size_t temp = _serial.write(toWrite);
        std::cout << "Writing :" << toWrite << std::endl;
    }

The code always runs in the run() function and pauses when the callback happens.

The only data in the serial for now is: !s 23 where 23 is any integer and I am simply writing to change the integer when callback is being called.

So what can be wrong with my code? Why do I need to call the callback twice in order to change the data in the serial and why does sometime the writing does not happen (my assumption is that the while loop gets stuck)? Is it due to the subscriber issue? Cannot figure out

2020-12-18 13:28:06 -0500 marked best answer Using PCL and Laser as obstacle_layer (RTABmap obstacles_detection)

How can I use both Laser and PCL from obstacles_detection node to view the obstacles in the local costmap?

If i put the local_costmap like this:

 plugins:
   - {name: obstacle_layer, type: "costmap_2d::ObstacleLayer"}


  observation_sources: point_cloud_sensor

  # assuming receiving a cloud from rtabmap_ros/obstacles_detection node
  point_cloud_sensor: {
    sensor_frame: base_footprint,
    data_type: PointCloud2,
    topic: /planner_cloud,
    expected_update_rate: 0.5,
    marking: true,
    clearing: true,
    min_obstacle_height: -99999.0,
    max_obstacle_height: 99999.0}

I get the laser obstacles but not get the PCL obstacles. If I remove that plugin, I do not get the laser obstacles but get the PCL obstacles.

2020-12-18 13:25:57 -0500 marked best answer RTABmap localization error

I recently got this error while localizing with RTABmap:

Memory.cpp:739::update() The working memory is empty and the memory is not incremental (Mem/IncrementalMemory=False), no loop closure can be detected! Please set Mem/IncrementalMemory=true to increase the memory with new images or decrease the STM size (which is 1 including the new one added).
[ WARN] (2019-07-11 17:17:24.941) Rtabmap.cpp:3369::getPaths() path.size()=0!? nearestId=0 ids=1, aborting...
[FATAL] (2019-07-11 17:17:24.947) Rtabmap.cpp:2743::process() Condition (_memory->getSignature(id) != 0) not met! [id=1]

What is the reason behind it and how can I avoid it?

2020-12-18 13:25:30 -0500 received badge  Famous Question (source)
2020-12-18 12:55:42 -0500 marked best answer How can I use radar for the obstacle detection?

How can I use the radar in my local_costmap_params to detect the obstacles? I am displaying data in mm in topic /radar.

2020-11-23 10:31:37 -0500 received badge  Famous Question (source)
2020-11-15 06:35:49 -0500 received badge  Famous Question (source)
2020-11-13 06:45:41 -0500 received badge  Notable Question (source)
2020-11-13 06:45:41 -0500 received badge  Famous Question (source)
2020-10-27 03:29:16 -0500 received badge  Critic (source)
2020-10-22 02:10:40 -0500 commented answer Global planner ignores footprint

Also I am commenting here last time for any future people that will come up with the similar problem: Do the sanity che

2020-10-22 02:08:23 -0500 commented answer Global planner ignores footprint

@JackB Yes that is exactly the reason why you keep answering to these question, surely it is my improper usage of the pl

2020-10-16 10:24:30 -0500 received badge  Notable Question (source)
2020-10-15 11:45:21 -0500 commented answer Global planner ignores footprint

@JackB Did I tell something about ROS? ROS is not the global planner, I believe you should educate yourself :) I just me

2020-10-15 11:44:09 -0500 received badge  Popular Question (source)
2020-10-15 09:26:54 -0500 commented answer Global planner ignores footprint

I just read the answer. What a shitty planner then this global planner in ROS, unbelievable and no documentation that st

2020-10-15 09:13:37 -0500 commented question Global planner ignores footprint

@JackB Look at my footprint (green rectangle) and look the path. There is no way that this big robot can squeeze inbetwe