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

bjoernolav's profile - activity

2022-08-16 01:43:28 -0500 commented question remapping service name works but remapping action name does not?

Allright, thanks!

2022-08-11 04:35:45 -0500 commented question remapping service name works but remapping action name does not?

Did you figure out anything with action name remapping? I'm struggelig to make this work myself, I've posted an issue on

2022-08-03 08:10:37 -0500 received badge  Famous Question (source)
2022-07-12 15:06:27 -0500 commented question rclpy.spin_until_future_complete() removes node from executor added by rclpy.spin()

Not really. I made it work using rclpy.spin_once() instead. It's probably better to use a MultiThreadedExecutor instead,

2022-07-12 15:06:12 -0500 commented question rclpy.spin_until_future_complete() removes node from executor added by rclpy.spin()

Not really. I made it work using rclpy.spin_once() instead. It's probably better to instead use a MultiThreadedExecutor

2022-06-27 17:02:41 -0500 received badge  Famous Question (source)
2022-06-27 17:02:41 -0500 received badge  Notable Question (source)
2022-06-27 17:02:41 -0500 received badge  Popular Question (source)
2022-05-23 03:40:09 -0500 received badge  Nice Question (source)
2022-05-23 03:39:58 -0500 received badge  Notable Question (source)
2022-04-03 06:45:36 -0500 received badge  Popular Question (source)
2022-04-01 11:50:30 -0500 asked a question Capture stdin using ros2 launch

Capture stdin using ros2 launch In ROS1, I've successfully used pdb to debug ROS nodes launched using roslaunch. Moving

2022-03-31 10:18:43 -0500 asked a question rclpy.spin_until_future_complete() removes node from executor added by rclpy.spin()

rclpy.spin_until_future_complete() removes node from executor added by rclpy.spin() I'm writing a ROS2 rclpy node (using

2022-03-29 07:45:59 -0500 commented question ros2 launch: Forward keystrokes to child node

Did you find any solution to this? I'm facing a similar problem.

2021-05-06 03:29:33 -0500 received badge  Famous Question (source)
2020-11-20 11:08:46 -0500 received badge  Famous Question (source)
2020-09-07 00:16:21 -0500 received badge  Notable Question (source)
2020-08-23 02:02:02 -0500 commented answer Newbie question on working with pcl_ros

Thanks a lot for your answer! It really helped understanding what was going on :)

2020-08-23 01:55:43 -0500 marked best answer Newbie question on working with pcl_ros

I'm used to ROS/python, but due to performance requirements I'm writing a node in C++ for filtering pointcloud data. Specifically, I'm inputting a sensor_msgs/PointCloud2 message using pcl_ros, checking if they originate from a "occupied" point in a occupancy grid and publishing "occupied" and "free" points on separate topics. It also transforms the points into the same frame as the occupancy grid.

All the work is being done in a callback function for the input topic. Initially, I wanted to make it optionally to transform the points, so therefore I attempted to make a separate pointer points_in referring to either the raw points or the transformed points. The code sort of works, but sometimes the points used in the filtering part seems to have very high values (etc. x=-27e41) - which made me think that I've done something stupid, e.g. letting the underlying data be manipulated by something in a way.

After some trial and error/tutorial copying I've made it work by replacing const PointCloud *points_in with const PointCloud::Ptr points_in (new PointCloud);. The problem is that I don't really understand what caused the problem - could anyone explain me what I did wrong, or point me in a direction? I realize that this may be a trivial thing that I probably should have learned in a tutorial somewhere, but I really appreciate any pointers!

Original callback function - not working:

void pointcloud_cb(const PointCloud::ConstPtr& msg) {
    ROS_INFO_STREAM("Received cloud " << *msg);
    ros::Time trans_begin = ros::Time::now();
    const PointCloud *points_in;
    // Transform points
    if (_transform_to_map_frame_id) {
        PointCloud transformed_points;
        std::string map_frame_id = "piren";//TODO: Check frame stuff //_occupancy_grid.getMapFrameId();
        ROS_INFO_STREAM("Looking for transform from " << msg->header.frame_id << " to " << map_frame_id);
        _tf_listener->waitForTransform(map_frame_id, msg->header.frame_id, pcl_conversions::fromPCL((*msg).header.stamp), ros::Duration(0.05));
        if (!pcl_ros::transformPointCloud<PointType>(map_frame_id, *msg, transformed_points, *_tf_listener)) {
            ROS_WARN_STREAM_THROTTLE(5.0,
                    "Failed to lookup transform, discarding points.");
        }
        points_in = &transformed_points;
    }
    else {
        points_in = &(*msg);
    }
    _points_transformed_pub.publish(*points_in);
    // Filter points
    ros::Time filter_begin = ros::Time::now();
    int occupied = 0;
    PointCloud::Ptr free_points (new PointCloud);
    PointCloud::Ptr occupied_points (new PointCloud);
    BOOST_FOREACH (const PointType& pt, points_in->points){
        //TODO: Check frame stuff: //if (_occupancy_grid.point_occupied<PointType>(points_in->header.frame_id, pt)) {
        if (_occupancy_grid.point_occupied<PointType>("piren_ENU", pt)) {
            // Point is occupied
            ++occupied;
            if (_publish_occupied){occupied_points->points.push_back(pt);}
        }
        else{
            //Point is free
            free_points->points.push_back(pt);
        }
    }
    ros::Time filter_end = ros::Time::now();
    // Headers
    free_points->height = 1;
    free_points->width = points_in->size() - occupied;
    free_points->header = points_in->header;
    _points_free_pub.publish(free_points);
    if (_publish_occupied){
        occupied_points->height = 1;
        occupied_points->width = occupied;
        occupied_points->header=points_in->header;
        _points_occupied_pub.publish(occupied_points);
    }
    ROS_INFO_STREAM("Received " << msg->size() << " points. " <<
            "trans_dur: " << filter_begin - trans_begin << "s, " <<
            "filt_dur: " << filter_end - filter_begin << "s, " <<
            "points occupied: " << occupied <<
            "(" << points_in->size() - occupied << " points free).");
}

New callback function - working:

void pointcloud_cb(const PointCloud::ConstPtr& msg) {
    ROS_INFO_STREAM("Received cloud " << *msg);
    ros::Time trans_begin = ros::Time::now();
    const PointCloud::Ptr points_in (new PointCloud);
    // Transform points
    if (_transform_to_map_frame_id) {
        std::string map_frame_id = "piren";//TODO: Check frame stuff //_occupancy_grid.getMapFrameId();
        ROS_INFO_STREAM("Looking for transform from " << msg->header.frame_id << " to " << map_frame_id);
        _tf_listener->waitForTransform(map_frame_id, msg->header.frame_id, pcl_conversions::fromPCL ...
(more)
2020-08-22 11:25:41 -0500 received badge  Notable Question (source)
2020-08-22 04:33:32 -0500 received badge  Popular Question (source)
2020-08-21 09:51:13 -0500 asked a question Newbie question on working with pcl_ros

Newbie question on working with pcl_ros I'm used to ROS/python, but due to performance requirements I'm writing a node i

2020-06-10 04:43:40 -0500 received badge  Student (source)
2020-04-29 10:45:29 -0500 edited answer Random segfaults for python rqt plugin

For reference in case other people are interested: The complete code for the working plugin. import os import rospy imp

2020-04-29 08:08:19 -0500 received badge  Popular Question (source)
2020-04-29 06:33:52 -0500 received badge  Editor (source)
2020-04-29 06:33:52 -0500 edited answer Random segfaults for python rqt plugin

For reference in case other people are interested: The complete plugin code with the corrections marked out by @dirk-tho

2020-04-29 06:32:25 -0500 answered a question Random segfaults for python rqt plugin

For reference in case other people are interested: The complete plugin code with the corrections marked out by @dirk-tho

2020-04-29 06:32:25 -0500 received badge  Rapid Responder (source)
2020-04-29 06:24:17 -0500 commented answer Random segfaults for python rqt plugin

Thank you very much for the answer! Using a slot for updating the QLineEdit widget, and emitting a signal in the ROS cal

2020-04-29 06:06:22 -0500 marked best answer Random segfaults for python rqt plugin

I've tried to write a couple of rqt plugins in order to make interaction with our ROS system easier. I'm not confident or familiar with QT (or C++) from beforehand, so I wrote the plugins with basis in the rqt-plugin tutorials.

One of the plugins is a used for controlling a simulation. This interacts with a node controlling a simulated clock using a service, and echoes the simulated clock to a QLineEdit. The plugin works well, but randomly exits with segfault. This seems to happen more often when my system has been running for a while. If I restart the plugin after it segfaults, it may segfault straight away, or run for an extended time period. After a restart, the plugin runs for a long time before I experience problems.

Some thought on what may cause this, without being able to fix it:

  • Python garbage collection: I understand that python may garbage collect QT objects that have gone out of scope in Python, while the objects are still referenced/used in C++. I've made all my QT objects attributes of the plugin class to tackle this.
  • The clock-topic is published at a high rate (100Hz). I figured that it may be a problem that the clock-callback got "stuck" if the plugin was occupied in a service call. I tried adding a lock to ignore received clock topics in such cases, without it seeming to have an effect.

I've run the plugin both by launching rqt and loading it (using python 2 and PyQt5), and running it standalone (using python 3 and PySide2). The problem occurs for both approaches.

I'm running Meldic Morenia on ubuntu 18.04 with kernel 5.3.0-45-generic. All inputs or suggestions are highly appreciated!

The plugin code:

import os
import rospy
import rospkg

from qt_gui.plugin import Plugin
from python_qt_binding import loadUi
from python_qt_binding.QtWidgets import QWidget
from threading import Lock

import std_srvs.srv as stdsrvs
from rosgraph_msgs.msg import Clock


class SimControl(Plugin):
    gui_lock = Lock()

    def __init__(self, context):
        super(SimControl, self).__init__(context)
        # Give QObjects reasonable names
        self.setObjectName('SimControl')

        # Process standalone plugin command-line arguments
        from argparse import ArgumentParser
        parser = ArgumentParser()
        # Add argument(s) to the parser.
        parser.add_argument("-q", "--quiet", action="store_true",
                            dest="quiet",
                            help="Put plugin in silent mode")
        args, unknowns = parser.parse_known_args(context.argv())
        if not args.quiet:
            print('arguments: ', args)
            print('unknowns: ', unknowns)

        # Create QWidget
        self._widget = QWidget()
        # Get path to UI file which should be in the "resource" folder of this package
        ui_file = os.path.join(rospkg.RosPack().get_path('ros_af_sim'),
                               'resource', 'sim_control.ui')
        # Extend the widget with all attributes and children from UI file
        loadUi(ui_file, self._widget)
        # Give QObjects reasonable names
        self._widget.setObjectName('SimControlUi')
        # Show _widget.windowTitle on left-top of each plugin (when
        # it's set in _widget). This is useful when you open multiple
        # plugins at once. Also if you open multiple instances of your
        # plugin at once, these lines add number to make it easy to
        # tell from pane to ...
(more)
2020-04-29 06:06:22 -0500 received badge  Scholar (source)
2020-04-29 03:48:55 -0500 received badge  Famous Question (source)
2020-04-28 02:48:27 -0500 received badge  Organizer (source)
2020-04-28 02:44:23 -0500 asked a question Random segfaults for python rqt plugin

Random segfaults for python rqt plugin I've tried to write a couple of rqt plugins in order to make interaction with our

2020-03-27 01:15:52 -0500 received badge  Famous Question (source)
2020-03-17 21:11:41 -0500 received badge  Notable Question (source)
2020-03-06 04:14:37 -0500 received badge  Popular Question (source)
2020-03-06 04:14:37 -0500 received badge  Enthusiast
2020-03-04 10:56:01 -0500 commented question Using NaN constants in message/service definitions

Yes, I see your point. I do, however, feels that it is a bit more explicit to let 0 be a valid value - and typically all

2020-03-04 08:07:40 -0500 edited question NaN as constant in message/service definition

NaN as constant in message/service definition As part of implementing a simulator, I have a service used for resetting t

2020-03-04 08:05:57 -0500 asked a question NaN as constant in message/service definition

NaN as constant in message/service definition As part of implementing a simulator, I have a service used for resetting t

2020-03-04 08:05:02 -0500 asked a question Using NaN constants in message/service definitions

Using NaN constants in message/service definitions As part of implementing a simulator, I have a service used for resett

2020-01-22 05:24:58 -0500 received badge  Notable Question (source)
2020-01-15 09:51:41 -0500 received badge  Popular Question (source)
2019-10-15 09:03:31 -0500 asked a question Rospy debug message is not written to nodes .log file

Rospy debug message is not written to nodes .log file I'm using ROS Melodic Morenia on Ubuntu 18.04 with kernel 5.0.0-29