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

Khiya's profile - activity

2023-02-02 03:27:56 -0500 received badge  Nice Question (source)
2014-01-28 17:26:42 -0500 marked best answer Subscriber callback function with multiple parameters

Hi folks, This is a follow-up to a question about callbacks found at http://answers.ros.org/question/39123/can-someone-explain-callbacks/?comment=39701#comment-39701

I'm using Python to implement a navigation interface between the ROS nav stack and my own motor controllers. I have created a Driver object that subscribes to the 'cmd_vel' topic and receives Twist messages from this topic. My callback function from the subscriber determines motor commands based on the info in each Twist message it receives.

A confusing problem I've found is that I need to hand both the Twist message and the 'self' object to my callback function , so that the callback has access to some global parameters associated with the Driver object. I cannot find a way to pass both pieces of information to the callback function when it's called within the Subscriber command.

Code:

class Driver:
    def __init__(self):
         # node initialized and constants described here

    def subscribe_cmd_vel(self):
          rospy.Subscriber("cmd_vel", Twist, self.callback(self))
          rospy.spin()
    def callback(self, msg):
            print "Linear x of Twist message: " + str(msg.linear.x)
            # do some calculations with contents of msg

if __name__ == "__main__"
    dr = Driver()
    dr.subscribe_cmd_vel()

I am consistently only passing the self object to my callback, not the Twist message. When this code hits the print line in the callback function, I get an error saying something like "The Driver object has no 'linear' field.". This means that my msg pointer is being pointed to the self object and my actual Twist message is being lost. Please tell me if you know what mistakes I've made here.

EDIT - SOLUTION =================

By removing the self parameter and parentheses from the callback invoked in the subscriber, both the message and the self object were correctly passed to the callback. I was overthinking the process of passing parameters and the significance of parentheses. Thanks to those who answered me below.

=================================

Many thanks,

Khiya

2014-01-28 17:22:43 -0500 marked best answer Slam gmapping tutorial troubleshooting

Hello, I'm following the map-building tutorial at http://www.ros.org/wiki/slam_gmapping... and I can get all the way through step 2 (hurray). Then when I enter:

 $ rosbag play aptLaserData.bag

which is the second part 1 of step 2, I get the error:

[ INFO] [1311128237.384522694]: Opening aptLaserData.bag

[FATAL] [1311128237.388682646]: Time is out of dual 32-bit range

My .bag file is indeed named aptLaserData.bag, but could you tell me what's causing the problem?

Thanks, Khiya

2014-01-28 17:22:23 -0500 marked best answer How can I publish hexadecimal values?

Hello,

I haven't been able to find this on the ROS wiki: If I would like to create a publisher for hexadecimal, what type of message would I use? Specifically, I would like to publish this list to the \commands topic:

0x00 0x01 0x1F 0x7F

. I would then write a subscriber to \commands that took the hex values and sent them one by one to a serial port, where my motor controller understood them as motor commands and acted accordingly. I don't think they would publish under int32, would they?

Thanks,

Khiya

2014-01-28 17:22:21 -0500 marked best answer rviz is agonizingly slow

Hello,

Are there any common reasons that would cause RVIZ to update very very slowly? I've been working with the Xbox Kinect and depth point clouds and every time I start rviz with the openni_camera node (ie, $roslaunch openni_camera openni_node.launch, $rosrun rviz rviz as suggested from the http://www.ros.org/wiki/openni_camera guide), everything on Ubuntu slows way down. The point cloud updates maybe once every 30 seconds. Is it just a problem of the amount of data being passed from the Kinect to rviz? Or could it be that my Asus EeeBox PC doesn't have enough umph to handle the data? Or is there some mysterious setting on rviz that only the enlightened know about which makes rviz more useful as a real-time observation tool for what your robot is up to?

I've run through the rviz documentation and aside from changing a few settings using the dynamic_reconfigure gui I can't find any solutions. Advice, anyone? Do any of you pro ROS users have optimal system setting suggestions?

Thanks,

Khiya

2014-01-28 17:22:19 -0500 marked best answer ROS path relocation error

Hello all,

I recently moved my main ros directory and now I cannot start executables like roslaunch, rosmake, or rosdep. I had made sure to edit my setup.sh file so I'm very confused about what's gone wrong. Details:

When I first installed Diamondback, roscd would take me to /opt/ros/diamondback/ros. Everything worked fine, but I foudn it just a bit annoying so I moved the whole diamondback directory to /home/khiya/ and changed the environment variables in setup.sh (located in the diamondback directory) accordingly. roscd now takes me straight to /home/khiya/diamondback/ros, but when I tried running any executables, such as roslaunch (kinda crucial, I know) I got this error:

     :~/diamondback/ros$ roscore
        Traceback (most recent call last):
          File "/home/khiya/diamondback/ros/bin/roscore", line 34, in <module>
            from ros import roslaunch
          File "/home/khiya/diamondback/ros/core/roslib/src/ros/__init__.py", line 56, in __getattr__
            raise ImportError("Cannot import module '%s': \n%s"%(name, str(e)))
        ImportError: Cannot import module 'roslaunch': 
        Cannot locate installation of package roslaunch: 
    /home/khiya/diamondback/ros/bin/rospack: error while loading shared libraries: 
librospack.so: cannot open shared object file: No such file or directory. 
ROS_ROOT[/home/khiya/diamondback/ros] 
ROS_PACKAGE_PATH[/home/khiya/sandbox/hrl_rfid:/home/khiya/ros_tutorials:
/home/khiya/diamondback/stacks]

(The last 5 lines are one continuous line, I just chopped it up for easier reading, in case that's important). The error seems to be saying that the directory /home/khiya/diamondback/ros/bin doesn't contain any of those important executables, but I can cd there and see that they're there. Do I need to tweak something in librospack.so?

Thanks very much,

Khiya

2014-01-28 17:22:19 -0500 marked best answer Is there a ROS wrapper for Pololu SMC-04B servomotor?

Hello all,

I'm putting a robot together (from scratch) and I've decided to make use of ROS's programming tools because it's excellent for mixing and matching several different sensors that can't necessarily be bought together from any robotics companies. My problem is that I have an excellent base with servomotor wheels already installed, but I can't find a ROS driver for the chip (Pololu SMC-04B). I'm even having trouble finding any documentation at all for these chips online.

So I need some advice:

  1. Does a wrapper for Pololu chips exist in ROS?

  2. Is it possible for me to write my own driver, say in Python, or perhaps C++, by modifying driver code from some other robotic navigation system. For example, could I find the navigation code for an iRobot Create and modify it somehow for my Pololu chips? (I have no idea how quite to do this, just general ideas, so pointers would be appreciated).

  3. If none of the above are feasible for a beginner like me, would it just be better to invest in something like an ArbotiX RoboController and just use the servomotor capabilities?

Thanks, and if I ought to explain anything more clearly, please let me know. -Khiya

2014-01-28 17:22:12 -0500 marked best answer How to restore a stack installed from debian

Hi, I accidentally completely deleted all the packages in my diamondback/stacks directory - the packages like [common] and [vision_opencv] and [openni_kinect] and all those important things. It was a tremendously stupid thing to do, I know, but there it is. Can anyone explain to me how to get back all those packages? I tried installing diamondback again in the hopes that it would reinstall the whole stack, but it didn't work. Then I tried things like "sudo apt-get install common" to try to install the packages back one by one, manually, but that didn't work either, so apparently I'm missing a lot of the fine details about installing packages. I really don't understand ROS or Ubuntu well enough yet to work my way back out of this - any help please? Thanks, Khiya

2013-06-27 23:26:14 -0500 received badge  Taxonomist
2013-05-29 13:38:01 -0500 received badge  Teacher (source)
2013-04-27 12:40:55 -0500 marked best answer Troubleshooting "Intro to tf" tutorial

Hello all,

I'm working through the tf tutorial at http://www.ros.org/wiki/tf/Tutorials/... , but when I get to Step #5, I get the following error:

/opt/ros/diamondback/stacks$ rosrun tf view_frames
Listening to /tf for 5.000000 seconds
Done Listening
Traceback (most recent call last):
  File "/opt/ros/diamondback/stacks/geometry/tf/scripts/view_frames", line 130, in <module>
    generate(dot_graph)
  File "/opt/ros/diamondback/stacks/geometry/tf/scripts/view_frames", line 85, in generate
    with open('frames.gv', 'w') as outfile:
IOError: [Errno 13] Permission denied: 'frames.gv'

Would someone be so kind as to tell me what this error means by "permission" (I have root priveleges but sudo rosrun tf view_frames just errored)? And how to go about obtaining that permission?

I'm working on a virtual machine with Ubuntu 10.05 and ROS Diamondback installed. My physical machine has Windows Vista, if that's important.

Thanks,

Khiya

2013-04-12 08:59:12 -0500 received badge  Notable Question (source)
2013-04-12 08:59:12 -0500 received badge  Famous Question (source)
2013-04-12 08:59:12 -0500 received badge  Popular Question (source)
2013-02-26 19:41:44 -0500 received badge  Famous Question (source)
2013-02-26 19:41:44 -0500 received badge  Notable Question (source)
2012-12-14 13:43:32 -0500 received badge  Notable Question (source)
2012-12-14 13:43:32 -0500 received badge  Famous Question (source)
2012-11-29 06:10:34 -0500 received badge  Notable Question (source)
2012-11-29 06:10:34 -0500 received badge  Popular Question (source)
2012-11-29 06:10:34 -0500 received badge  Famous Question (source)
2012-09-16 21:40:48 -0500 received badge  Notable Question (source)
2012-09-16 21:40:48 -0500 received badge  Famous Question (source)
2012-09-16 21:40:48 -0500 received badge  Popular Question (source)
2012-08-31 03:46:07 -0500 received badge  Famous Question (source)
2012-08-28 00:22:45 -0500 received badge  Famous Question (source)