Ask Your Question

rbaleksandar's profile - activity

2019-09-03 10:42:09 -0500 received badge  Famous Question (source)
2019-08-30 04:20:09 -0500 received badge  Notable Question (source)
2019-08-30 04:20:09 -0500 received badge  Famous Question (source)
2018-06-04 08:47:13 -0500 received badge  Famous Question (source)
2018-04-13 07:53:16 -0500 marked best answer Raspberry Pi 2, ROS and GPIO access

Hi!

I just created two nodes:

  • One is on my notebook to send status updates of a LED (the message is of type Bool)
  • The other is on my RPi2 and sets the GPIO 17 to high/low according to value in the Bool message received

Both platforms are running ROS Indigo (notebook has Debian Jessie and RPi2 has Raspbian Wheezy). I'm also using only Python (especially on the RPi2 this seems to be the much easier way to do things related to the GPIO).

My problem is the GPIO access requires superuser privileges, which rosrun doesn't seem to like (in fact rosrun obviously is not a known command when using sudo). My question is in what best way am I to handle this situation? Should ROS on such an embedded system actually be installed as root because of all the low level access to the hardware underneath or is it possible to execute rosrun in superuser temporarily just for that the time the specific node that requires such privileges is running?

2017-10-04 03:16:37 -0500 commented answer Display PointCloud2 in Rviz

It's been a while so I might be wrong but looking at the code in my answer you can see that I pass it as a parameter wit

2017-08-22 15:31:20 -0500 asked a question Running rosversion through Python subprocess.Popen() leads to encoding error

Running rosversion through Python subprocess.Popen() leads to encoding error Running the following line of Python code (

2017-08-22 15:15:12 -0500 commented question Timing to start simple action server and client

It's been a while. I have forgotten if I found a solution or not. Sorry. Apologies.

2017-07-13 12:56:13 -0500 received badge  Good Answer (source)
2017-06-08 15:46:14 -0500 received badge  Nice Question (source)
2017-06-06 07:17:49 -0500 received badge  Notable Question (source)
2017-04-19 21:35:46 -0500 received badge  Famous Question (source)
2017-04-19 17:52:38 -0500 marked best answer Unable to select model argument for urdf-tutorial package

Hi!

I'm looking into the tutorials on URDF (ROS Indigo), robot_state_publisher etc. In this tutorial it is stated that

roslaunch urdf_tutorial display.launch model:=urdf/01-myfirst.urdf

should start rviz (launch parameters stored inside display.launch) with the selected model. Sadly I'm getting the error that such file cannot be found:

rosuser:~$ roslaunch urdf_tutorial display.launch model:=urdf/01-myfirst.urdf
... logging to /home/rosuser/.ros/log/336d620e-8d02-11e5-b0c5-90fba64806be/roslaunch-latadmin-ros-7550.log
Checking log directory for disk usage. This may take awhile.
Press Ctrl-C to interrupt
Done checking log file disk usage. Usage is <1GB.

Traceback (most recent call last):
  File "/opt/ros/indigo/lib/python2.7/dist-packages/roslaunch/__init__.py", line 298, in main
    p.start()
  File "/opt/ros/indigo/lib/python2.7/dist-packages/roslaunch/parent.py", line 260, in start
    self._start_infrastructure()
  File "/opt/ros/indigo/lib/python2.7/dist-packages/roslaunch/parent.py", line 209, in _start_infrastructure
    self._load_config()
  File "/opt/ros/indigo/lib/python2.7/dist-packages/roslaunch/parent.py", line 124, in _load_config
    roslaunch_strs=self.roslaunch_strs, verbose=self.verbose)
  File "/opt/ros/indigo/lib/python2.7/dist-packages/roslaunch/config.py", line 451, in load_config_default
    loader.load(f, config, verbose=verbose)
  File "/opt/ros/indigo/lib/python2.7/dist-packages/roslaunch/xmlloader.py", line 730, in load
    self._load_launch(launch, ros_config, is_core=core, filename=filename, argv=argv, verbose=verbose)
  File "/opt/ros/indigo/lib/python2.7/dist-packages/roslaunch/xmlloader.py", line 702, in _load_launch
    self._recurse_load(ros_config, launch.childNodes, self.root_context, None, is_core, verbose)
  File "/opt/ros/indigo/lib/python2.7/dist-packages/roslaunch/xmlloader.py", line 646, in _recurse_load
    self._param_tag(tag, context, ros_config, verbose=verbose)
  File "/opt/ros/indigo/lib/python2.7/dist-packages/roslaunch/xmlloader.py", line 95, in call
    return f(*args, **kwds)
  File "/opt/ros/indigo/lib/python2.7/dist-packages/roslaunch/xmlloader.py", line 264, in _param_tag
    value = self.param_value(verbose, name, ptype, *vals)
  File "/opt/ros/indigo/lib/python2.7/dist-packages/roslaunch/loader.py", line 463, in param_value
    with open(textfile, 'r') as f:
IOError: [Errno 2] No such file or directory: u'urdf/01-myfirst.urdf'

I also read the lines below:

This launch file assumes that 01-myfirst.urdf is in the urdf subdirectory of the directory that you type the command in. Otherwise, you should say model:='$(find pkg-name)/urdf/01-myfirst.urdf' where pkg-name is the name of the package that the file is in (single quotes required)

I tried both with an installed version of the package and a fresh download of the package inside my catkin workspace but in both cases I'm getting the same error. I have checked and the urdf folder is there along with the specified file (last line of the following terminal output):

rosuser:/opt/ros/indigo/share/urdf_tutorial$ ls -R
.:
cmake  images  launch  package.xml  urdf  urdf.rviz  urdf.vcg

./cmake:
urdf_tutorialConfig-version.cmake  urdf_tutorialConfig.cmake

./images:
flexible.png  materials.png  multipleshapes.png  myfirst.png  origins.png  visual.png

./launch:
display.launch  gazebo.launch  xacrodisplay.launch

./urdf:
01-myfirst.urdf  02-multipleshapes.urdf  03-origins.urdf  04-materials.urdf  05-visual.urdf  06-flexible ...
(more)
2017-03-16 22:25:44 -0500 marked best answer Display PointCloud2 in Rviz

Hi!

I realize this question has been chewed a lot here but from all the answers I've read nothing seems to work. I'm using ROS Indigo on Ubuntu 14.04 LTS (32bit).

Before I start reading and publishing my own data I decided to check out how things actually work with one of these PCD files.

Here is my publisher:

#include <ros/ros.h>
#include <pcl_ros/point_cloud.h>
#include <pcl/point_types.h>
#include <pcl/io/pcd_io.h>
#include <string>

typedef pcl::PointCloud<pcl::PointXYZ> PointCloud;

using std::string;

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

  string pcdFile = "";
  nh.getParam("pcdFile", pcdFile);

  if(pcdFile == "") {
    ROS_ERROR_STREAM("Unable to find file \"" << pcdFile << "\"");
    nh.shutdown();
  }

  ros::Publisher pub = nh.advertise<PointCloud> ("cloud_publisher/cloud_from_file", 1);

  PointCloud::Ptr msg(new PointCloud);
  if (pcl::io::loadPCDFile<pcl::PointXYZ> (pcdFile, *msg) == -1)
  {
    ROS_ERROR_STREAM("Unable to read from file \"" << pcdFile << "\"");
    nh.shutdown();
    return -1;
  }

  ros::Rate r(10);

  while (nh.ok())
  {
    msg->header.frame_id = "/my_frame";
    //msg->header.stamp = ros::Time::now().toNSec();
    pub.publish(msg);
    ros::spinOnce();
    r.sleep();
  }

  return 0;
}

Basically I read a PCD file and send it on its way to the rest of the ROS network. I want to see the result in RViz. Now here is the thing - I get the ever so lovely error

No tf data. Actual error: Fixed Frame [map] does not exist

in my global status of Rviz. I also added a PointCloud2 item to RViz but the moment I selected the topic that my cloud_publisher is publishing roslaunch (I use a launch file to load the PCD file in my node) breaks with another known error the moment I set the topic of my PointCloud2 to cloud_publisher/cloud_from_file:

terminate called after throwing an instance of 'std::runtime_error'
what(): Time is out of dual 32-bit range [cloud_publisher-1] process has died [pid 2015, exit code -6, cmd /home/rosuser/catkin_ws/devel/lib/pcl_misc/cloud_publisher __name:=cloud_publisher __log:=/home/rosuser/.ros/log/32182a0e-3b92-11e5-9e58-001e0ba4cf00/cloud_publisher-1.log]. log file: /home/rosuser/.ros/log/32182a0e-3b92-11e5-9e58-001e0ba4cf00/cloud_publisher-1*.log all processes on machine have died, roslaunch will exit

I read that you have to either provide a transformation (using TF) from the map fixed frame to all others that you publish (in my case I have only my_frame) or simply set my_frame to be the global frame too. Well neither is working due to the crash of my node.

Can you please help me resolve this issue? It is not possible that displaying a single item (in my case a point cloud) in Rviz is that complicated.

Thanks!

EDIT: I just tried using rostopic echo /cloud_publisher/cloud_from_file and my publisher crashed again! It seems the issue is not because of Rviz (although the missing TF data is still bothering me...). Something fishy is going on with the topic itself...

EDIT2: I forgot to mention that I have also tried this solution. I also wrote the wrong architecture. I have a 32bit CPU.

EDIT3: I tried borrowing code from ... (more)

2017-03-16 22:25:44 -0500 received badge  Nice Answer (source)
2017-03-06 21:43:20 -0500 received badge  Good Answer (source)
2017-03-06 21:43:20 -0500 received badge  Enlightened (source)
2017-01-24 03:27:59 -0500 received badge  Famous Question (source)
2017-01-24 03:27:59 -0500 received badge  Notable Question (source)
2017-01-23 14:40:41 -0500 received badge  Famous Question (source)
2017-01-12 05:57:00 -0500 received badge  Notable Question (source)
2017-01-12 05:57:00 -0500 received badge  Famous Question (source)
2017-01-12 05:57:00 -0500 received badge  Popular Question (source)
2016-12-08 22:10:51 -0500 received badge  Notable Question (source)
2016-10-30 13:31:18 -0500 received badge  Good Answer (source)
2016-10-14 09:05:04 -0500 received badge  Popular Question (source)
2016-10-14 09:05:04 -0500 received badge  Notable Question (source)
2016-09-13 13:24:24 -0500 received badge  Popular Question (source)
2016-08-24 11:08:58 -0500 received badge  Nice Answer (source)
2016-07-08 13:38:14 -0500 received badge  Popular Question (source)
2016-06-28 09:45:51 -0500 commented answer Conversion from sensor_msgs::PointCloud2 to pcl::PointCloud<T>

Here is a project of mine. I'm actually going to convert this to a more generic package and perhaps even propose to include it in ROS since there are not out-of-the-box, easy-to-use packages.

2016-06-28 04:51:00 -0500 received badge  Necromancer (source)
2016-06-27 09:18:19 -0500 marked best answer Building rqt (plus all plugins) from source - qt_gui_main() can't find any plugins

Hi!

I have just finished building rqt from source for ROS Indigo on my Debian Jessie without any errors. However when I try to run rqt_graph for example I get:

qt_gui_main() found no plugin matching "rqt_graph.ros_graph.RosGraph"

Next thing I did was to open rqt. It opens fine however I can't see a single plugin inside the plugin menu even though I have rqt_graph, rqt_console etc. (full rqt_common_plugins metapackage was installed). The executables are there (that is why the terminal didn't throw an error at me that the command was not found when calling rqt_graph) but there seems to be missing something and I don't know what.

Any ideas what's going on here? All the source war pulled via wstool and rosdep (as described in the tutorial about installing ROS on Debian).

EDIT: Running rqt --list-plugins doesn't return anything at all.

2016-06-27 09:18:19 -0500 received badge  Nice Answer (source)
2016-06-27 06:55:19 -0500 answered a question How to cancel goals from within an action server?

As @Javier mentioned in the comments the cancellation of a goal is done automatically. In order to handle multiple action servers at once you have to create a minimalistic SimpleActionClient for each action server (except for the one that cancels all of the other servers). Such a client will have only one task namely sending an empty goal of type X to the server which processes the respective action. By doing so you are exploiting (in a perfectly decent manner) the automatic preemption of the SimpleActionServer so each of the other action servers will receive it, do nothing but also cancel the goal each is currently executing. I would suggest (I'm also about to test it with my own code) that you trigger a cancel request using all the action clients and send to all the respective action servers. The triggering itself needs to be done inside the callback of the action server that needs to cancel all other servers.

2016-06-27 06:25:29 -0500 commented answer Pausing or aborting movement to a goal

If the received goal is with a higher priority of the currently running goal, the currently running goal needs to be canceled and the new goal is executed.

2016-06-27 06:24:41 -0500 commented answer Pausing or aborting movement to a goal

Is it possible to cancel the goal inside the ActionServer itself without adding a client side to it. I'm adding priorities to my multiple action servers and whenever any of the callbacks is triggered the server has to check if a goal with a higher priority is currently being executed.

2016-06-27 05:16:50 -0500 asked a question Mutex with multiple types of topics as input

I'm currently looking into using the ROS mux (from topic_tools) for controlling an LED system on a mobile platform (similar to the PR2 but without the bulky robot on the top, just the base). Right now I have multiple services and normal topics that are handled by a node which controls the LEDs that are mounted at various locations on the platform. The problem is that there are no priorities. Priorities are essential here since each LED-related message is used to visualize some sort of situation that the user should/has to be aware of. For example minor errors (like object tracking failed in which situation the robot simply stops moving) are of lower priority compared to let's say the crash of a system-critical node (like velocity of the platform has reached a given limit in which case driving it around manually may become dangerous to either or both the user and the platform itself).

I would like to implement a priority-capable mutex (similar to the twist_mux and the cmd_vel_mux) however I would also like to keep the current state of the topic I have. This means that the outputs of the mutex will be of different type.

Here are some examples:

Force direction message (*.msg):

# Gives LED feedback of the direction and magnitude of the force that is applied to the platform by pulling it (can aslo be used
geometry_msgs/WrenchStamped force
std_msgs/ColorRGBA color

Blink action message (*.action):

# Gives LED feedback for a variety of scenarios
int32 blinks                    # Number of flashes (1 flash = 1 time on + 1 time off) - duration: long
int32 fast_blinks               # Number of flashes (1 flash = 1 time on + 1 time off) - duration: short (takes place from one long flash to another)

int32 start_led
int32 end_led

std_msgs/ColorRGBA color_outer
std_msgs/ColorRGBA color_inner

int32 num_inner_leds            # Number of LEDs for EACH inner stripe; it can be <= the half of all LEDs defined by start_led and end_led
---
int32 blinks_left               # Result (if == 0 then really successful); refers to the flashes with LONG duration only
---
int32 fast_blinks_left          # Feedback: number of flashes left until the next flash with long duration
int32 blinks_left               # Feedback: number of flashes left until the goal is completed; refers to the flashes with LONG duration only

Service message (*.srv):

# Turns on/off the LEDs
bool turn_on
std_msgs/ColorRGBA color    # RGB values [0-1] for all LEDs (when turning on)
---
bool success
string message

Obviously I will have to add a priority parameter to all messages (service request, standard topics and action goals) otherwise the mutex will have to decide on its own based on the type of the topic which one should be executed etc.

I'm struggling with the implementation namely how do you process multiple topics of a different type in a generic way? What I envision in my head is something like this:

  1. One of the many client nodes (each client node handles some sort of scenario that is linked indirectly to the LED system) detects the need to send a message that is ...
(more)
2016-06-27 04:31:08 -0500 received badge  Notable Question (source)
2016-06-24 17:30:57 -0500 received badge  Famous Question (source)
2016-06-15 07:20:47 -0500 commented answer Reusing nodes by renaming them

Thanks, will take a look.

2016-06-14 10:14:03 -0500 marked best answer Reusing nodes by renaming them

I'm currently working on a small project that involves the mux from the topic_tools package. The question isn't directly related to the topic mutex. The mutex was just a scenario that revealed the problem I'm having namely properly renaming nodes and reusing code by modifying only a launch file.

In order to illustrated what I'm talking about here is the Python code for a talker node:

talker.py

#!/usr/bin/env python
import rospy
from std_msgs.msg import String
import sys

def talker():
    rospy.init_node('talker')
    msg = 'default message'
    if rospy.has_param('msg'):                         # Never works due to missing namespace
      msg = rospy.get_param('msg', msg)
      rospy.loginfo('Found "msg" parameter with value "%s"' % msg)
    else:
      rospy.loginfo('No "msg" parameter found. Fallback to default "%s"' % msg)

    pub = rospy.Publisher('chatter', String, queue_size=1)      
    while not rospy.is_shutdown():
        str = "%s %s" % (msg, rospy.get_time())
        rospy.loginfo(str)
        pub.publish(String(str))
        rospy.sleep(1.0)

if __name__ == '__main__':
    try:
    talker()
    except rospy.ROSInterruptException:
        pass

Nodes have to have unique names otherwise naming conflicts occur. Same applies to topics. So for my mutex I decieded to reuse the talker node but with a different name and a different message:

talker_mux.launch

<launch>
  <remap from="chatter" to="chatter1"/>
  <node name="talker1" pkg="beginner_tutorials" type="talker.py" output="screen">
    <param name="msg" type="str" value="message1" />
  </node>

  <remap from="chatter" to="chatter2"/>
  <node name="talker2" pkg="beginner_tutorials" type="talker.py" output="screen">
    <param name="msg" type="str" value="message2" />
  </node>

  <remap from="chatter" to="chatter3"/>
  <node name="talker3" pkg="beginner_tutorials" type="talker.py" output="screen">
    <param name="msg" type="str" value="message3" />
  </node>

  <node name="talkerMux" pkg="topic_tools" type="mux" args="chatterMUX chatter1 chatter2 chatter3 mux:=talkerMux" />
</launch>

As you can see I start three instances of talker.py and give these accordingly the names talker1, talker2 and talker3 along with a different msg parameter containing some string.

The issue appeared when I ran the launch file and got three times:

No "msg" parameter found. Fallback to default "default message"

Upon calling rosparam list I discovered that the namespaces are the problem since instead of getting msg I get

/talker1/msg
/talker2/msg
/talker3/msg

Of course this is how it's supposed to be due to the fact that parameters have to be unique hence adding the namespace is required when running multiple nodes that have the same parameters.

Every once in a while when I have to deal with namespaces in ROS things get messy. This case is no different. That's why I would like to ask for a tip how to solve my problem - use the same node multiple times with different name and message WITHOUT creating multiple versions of that node by writing code. I thought about a way to retrieve the name of the node from the launch file but have no idea how to that without writing a huge blob of code...Is it even possible?

I can easily copy-paste my talker.py and ... (more)