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

Jon Mace's profile - activity

2019-03-08 10:42:09 -0500 received badge  Good Answer (source)
2016-08-04 02:32:11 -0500 received badge  Good Answer (source)
2013-12-03 06:46:30 -0500 received badge  Good Answer (source)
2012-08-06 13:50:46 -0500 commented question pr2 gazebo headless not working

It doesn't seem that there are any messages published on /tf

2012-08-04 22:33:01 -0500 answered a question rosrun cannot find specified node file

I've had this problem before, it's bizarre and I'm not sure what causes the problem, but I do think that I know how to solve it. For me at least, the problem was specific to the file; other files in the package could run fine. My solution was to re-create the node file, and copy-paste the contents. You will (hopefully) find that it now works.

2012-07-31 14:29:40 -0500 received badge  Nice Answer (source)
2012-07-30 19:31:16 -0500 answered a question Turtlebot- Random Wandering with Collision Avoidance

This answer is a bit of a copy-paste. The task you describe is the first assignment in Brown's CS148 Introduction to Robotics course. Here's a solution that isn't exactly pretty but presumably, at some point, did work... :P

#!/usr/bin/env python
import roslib; roslib.load_manifest('enclosure_escape')
import rospy
import random
from geometry_msgs.msg import Twist
from turtlebot_node.msg import TurtlebotSensorState

# global variables
bump = False

action_duration = 0.25
movement_speed = 0.15
turn_speed = 0.5
min_turn_duration = 3.5
max_turn_duration = 10.5

# listen (adapted from line_follower
def processSensing(TurtlebotSensorState):
     global bump
     bump = TurtlebotSensorState.bumps_wheeldrops
     #newInfo = True


def hello_create():
     pub = rospy.Publisher('/turtlebot_node/cmd_vel', Twist)
     rospy.Subscriber('/turtlebot_node/sensor_state', TurtlebotSensorState, processSensing)
     rospy.init_node('hello_create')
     #listen
     global bump
     twist = Twist()
     while not rospy.is_shutdown():
         if bump==1:
             str = "right bumper, turning left %s"%rospy.get_time()
             rospy.loginfo(str)
             turn(pub, random_duration(), turn_speed)
         elif bump==2:
             str = "left bumper, turning right %s"%rospy.get_time()
             rospy.loginfo(str)
             turn(pub, random_duration(), -turn_speed)
         elif bump==3:
             str = "both bumpers, turning left %s"%rospy.get_time()
             rospy.loginfo(str)
             turn(pub, random_duration(), turn_speed)
         else:
             str = "moving straight ahead %s"%rospy.get_time()
             rospy.loginfo(str)
             twist.linear.x = movement_speed; twist.linear.y = 0; twist.linear.z = 0
             twist.angular.x = 0; twist.angular.y = 0; twist.angular.z = 0
             bump = False
         pub.publish(twist)
         rospy.sleep(action_duration)

def random_duration():
    # Calculates a random amount of time for the Roomba to turn for
    duration = min_turn_duration + random.random() * (max_turn_duration - min_turn_duration)
    str = "Random duration: %s"%duration
    rospy.loginfo(str)
    return duration

def turn(pub, duration, weight):
    twist = Twist()

    # First, back up slightly from the wall
    twist.linear.x = -movement_speed; twist.linear.y = 0; twist.linear.z = 0
    twist.angular.x = 0; twist.angular.y = 0; twist.angular.z = 0
    pub.publish(twist)
    rospy.sleep(action_duration)

    # Now, keep turning until the end of the specified duration
    currentTime = rospy.get_time();
    stopTime = rospy.get_time() + duration;
    while (rospy.get_time() < stopTime):
         str = "turning %s"%rospy.get_time()
         rospy.loginfo(str)
         twist.linear.x = 0.0; twist.linear.y = 0; twist.linear.z = 0
         twist.angular.x = 0; twist.angular.y = 0; twist.angular.z = weight
         pub.publish(twist)
         rospy.sleep(action_duration)


if __name__ == '__main__':
     try:
         hello_create()
     except rospy.ROSInterruptException: pass
2012-07-29 09:07:39 -0500 received badge  Good Answer (source)
2012-07-28 12:24:26 -0500 received badge  Nice Answer (source)
2012-07-27 13:29:30 -0500 answered a question "thin clients" communicating with ROS

Rosbridge is a perfect solution. You can write a client that connects to rosbridge using any language that has a websocket library. Websocket is a poor choice of name for the protocol because it implies use by web browsers only. Sure, it was designed for web browsers, but the protocol itself is just a layer on top of TCP and provides a number of useful properties.

As for the rosbridge ROS node - we have just released rosbridge v2.0 beta, which is the 'industrial strength' rosbridge. It has a much more robust server implementation and a more well defined protocol. We haven't yet officially released v2.0 on ROS.org so the information on the ROS wiki is still for v1.0. The most up to date resource is rosbridge.org (for both v1.0 and v2.0 of rosbridge). The source code repository for v2.0 is here.

To give you the gist of how rosbridge works, you can check out some example rosbridge commands on this page.

To actually write a client that connects to rosbridge, all you need is a websockets library. For example, the following python client connects and calls a ROS service. In the example we use the ws4py websocket client library.

from json import dumps
from ws4py.client.threadedclient import WebSocketClient

class GetLoggersClient(WebSocketClient):

     def get_loggers(self):
         msg = {'op': 'call_service', 'service': '/rosout/get_loggers'}
         self.send(dumps(msg))

     def opened(self):
         print "Connection opened..."
         self.get_loggers()

     def closed(self, code, reason=None):
         print code, reason

     def received_message(self, m):
         print "received", m

if __name__=="__main__":
     try:
         ws = GetLoggersClient('ws://127.0.0.1:9090/')
         ws.connect()
     except KeyboardInterrupt:
         ws.close()
2012-07-26 05:33:12 -0500 received badge  Nice Answer (source)
2012-07-25 08:25:48 -0500 answered a question Subscriber callback function with multiple parameters

Lorenz's answer is correct; whenever you use brackets, it tries to call the function immediately, which isn't what you are trying to do.

In terms of arguments to the function, you don't need to bother passing in the 'self' argument, it is automatically done for you. self.callback is a bound method - it already contains a reference to the scope that it is bound to (saved in the __self__ variable). So you never need to provide the self argument, regardless of where you call the method.

As an aside,

If you do want to do partial functions, you can do so using functools.partial. Here's an example:

from functools import partial

def jon(a, b):
    print "a is", a
    print "b is", b

partialjon = partial(jon, "part of the partial function...")

partialjon("not.")

>> a is part of the partial function...
>> b is not.

http://docs.python.org/library/functools.html#functools.partial

2012-07-24 15:40:27 -0500 answered a question rosbridge how to subscribe from multi rostopic

Actually, my first answer was incorrect, and I have edited it for correctness.

2012-07-24 11:45:20 -0500 answered a question rosbridge how to subscribe from multi rostopic

You can reuse callbacks for multiple subscription requests and as the handler for incoming messages.

subscription_ok_callback = function(rsp) {
    alert("subscribed to /sensorPacket");
}

connection.callService("/rosjs/subscribe", '["/a", 0]', subscription_ok_callback);
connection.callService("/rosjs/subscribe", '["/b", 0]', subscription_ok_callback);

message_received_callback = function(msg) {
    alert("received a message: " + msg);
}

connection.addHandler("/a", message_received_callback);
connection.addHandler("/b", message_received_callback);
2012-07-20 10:16:07 -0500 received badge  Nice Answer (source)
2012-07-20 10:02:54 -0500 answered a question rosbridge connection closed

Could you test using the head version of rosbridge (svn url: http://brown-ros-pkg.googlecode.com/svn/trunk/experimental/rosbridge/). It's possible that you're experiencing a bug that has since been fixed but hasn't propagated to the latest version yet.

As for the "closed 10" error - the current version of rosbridge isn't very good at displaying meaningful errors. We're currently working on a more robust version of rosbridge which deals with this kind of thing much more gracefully. For now though, it may say "closed 10" even though you are actually connected.

2012-07-20 00:00:16 -0500 answered a question rosbridge connection closed

A possible problem is that ws://hostname:9090 is unlikely to be your machine name. Use ws://localhost:9090 or ws://<your ip="">:9090 (eg. ws://192.168.0.1:9090)

If that doesn't help, could you tell me what browser you're using? There are a variety of websocket client implementations out there; some older browsers use variants of the protocol that may be outdated and therefore not compatible with rosbridge. If you find that you are using an old or obscure browser, can you try testing your code on the latest chromium or firefox and see if that helps?

Thanks, Jon

2012-07-19 15:15:31 -0500 received badge  Enlightened (source)
2012-07-17 13:54:21 -0500 received badge  Good Answer (source)
2012-07-16 22:22:26 -0500 received badge  Nice Answer (source)
2012-07-16 11:54:08 -0500 answered a question JSON format for geometry_msgs/PoseStamped

The structure of geometry_msgs/PoseStamped is documented here: http://ros.org/doc/api/geometry_msgs/html/msg/PoseStamped.html

A PoseStamped message in JSON would therefore look as follows:

{ 
    header: { 
        seq: <int>, 
        stamp:  {
            secs: <int>,
            nsecs: <int>
        },
        frame_id: <string>
    },
    pose: {
        position: {
            x: <float>,
            y: <float>,
            z: <float>
        },
        orientation: {
            x: <float>,
            y: <float>,
            z: <float>,
            w: <float>
        }
    }
}

The entire JSON message that you would send to rosbridge to publish the message would be:

{
    receiver: "/topic",
    type: "geometry_msgs/PoseStamped",
    msg: { ...as above... }
}

Cheers, Jon

2012-07-16 11:48:10 -0500 answered a question JSON format for geometry_msgs/PoseStamped

The format for just the PoseStamped message will be:

{

header: { seq: <int>, stamp: { secs: <int>, nsecs: <int> } frame_id: <string> }

2012-07-11 09:10:24 -0500 received badge  Nice Answer (source)
2012-07-10 13:00:01 -0500 answered a question rosjs_remotelabwidgets contents

Hi BeuBeu,

The remote lab project has a number of cool widgets to do with robot visualization and control. However, some of these are written in a manner that makes them difficult to reuse. There is a current effort (within the last few weeks) at Bosch and Willow to begin to modularise many of the web components that we have til now written. We are not writing new widgets per se, but they are being split up so it should make it a lot easier for people to, for example, throw on a PR2 visualization onto their web page.

With regards to the robots that they work for - that's on a per-widget basis. Some of the widgets, such as the simple joystick widget, merely publish to a particular topic. Other widgets are clearly PR2 specific, such as the PR2 visualization. This will only work if it's receiving PR2 info on the /tf topic.

The best places to keep up to date are the following:

  • rosbridge.org: We are working on a new, industrial-strength rosbridge, that will be released with first-class support from Willow. rosbridge.org is a good place to keep up to date for news regarding the release schedule and protocol enhancements

  • https://github.com/rosjs/rosjs: This is where the heavyweight ros.js and javascript widgets will be mostly hosted.

  • rosbridge conf. call: There is a weekly conference call for interested parties. If you wish to contribute to the effort, then you're very welcome to join!

  • ROSDojo: Many of the Brown ROS web interfaces can be found in the experimental/ROSDojo project in the brown-ros-pkg

There will be a few announcements towards the end of the summer relating to rosbridge, rosjs, and javascript widgets.

Cheers,

Jon

2012-07-10 12:50:06 -0500 received badge  Teacher (source)
2012-07-10 12:48:20 -0500 received badge  Editor (source)
2012-07-10 12:47:49 -0500 answered a question rostime module not found

Hi Shuo,

This problem is caused by a change in ROS between electric and fuerte. The rostime module was moved from roslib to rospy. Thus, when importing roslib.rostime, we now get an ImportError

We have implemented a fix for this and it has been checked into the experimental version of rosbridge. As you mentioned in your post, you can check this out using

svn co http://brown-ros-pkg.googlecode.com/svn/trunk/experimental/rosbridge rosbridge

With regard to your svn error, I think you might be trying to SVN checkout into a folder that is already under SVN version control. Please try checking out experimental rosbridge into a fresh folder.

Finally, since you will probably have multiple rosbridge packages on your ROS package path, do a quick check to make sure that the experimental rosbridge is the first rosbridge that ROS finds. (Just roscd rosbridge and make sure that takes you to the folder that you just created)

This should fix your problem.

Cheers, Jon

2011-12-08 04:44:58 -0500 received badge  Supporter (source)