Ask Your Question

Jacco van der Spek's profile - activity

2018-01-30 20:55:06 -0500 received badge  Famous Question (source)
2018-01-30 20:55:06 -0500 received badge  Notable Question (source)
2018-01-30 20:55:06 -0500 received badge  Popular Question (source)
2014-05-02 07:22:44 -0500 commented answer How should I best add a python node to a cpp package?

Ok I suppose you added it as a service in your CMakeList.txt? Furthermore you should also do message_generation in in add_dependencies. Then what you also need to do in hydro is add message_generation as a build_depend and as required component.

2014-05-02 03:29:29 -0500 commented answer How should I best add a python node to a cpp package?

If you're satisfied with the answer, you can accept it.

2014-05-01 01:23:09 -0500 received badge  Teacher (source)
2014-04-30 20:12:58 -0500 answered a question How should I best add a python node to a cpp package?

Both can be done. You should be able to just put the Python script in /scripts. Make sure that you advertise your service in the Python script and subscribe to it in your C++ main/class.

If you get catkin_make errrors check if your package.xml and CMakelist.txt both contain rospy as depend package.

2014-04-30 00:52:02 -0500 answered a question How to read a value from a ros message?

The message that is being send over the topic is of type Blob.

You need to receive the message type Blob by subscribing to the topic. Then in your code you can write something like

int x = blob_message.x;
int y = blob_message.y;

So in summary you need to receive the complete message.

2014-04-29 23:51:57 -0500 commented question How to read a value from a ros message?

Do you want to read the value in terminal or use it in your code?

2014-04-28 22:23:31 -0500 asked a question Python savefig to directory

I'm trying to save some plots I make using matplotlib.pyplot however the save location is completely wrong. I'm using a service to plot a couple of values. To be more clear my code:

def plot_results(req):
    t = np.arange(0., req.tau+req.dt, req.dt)
    print len(t)
    fig = plt.figure(1)
    plt.plot(t, req.x, 'b-', t, req.y, 'r-')
    plt.xlabel('time')
    plt.ylabel('x,y')
    plt.title('Plot of resulting x and y trajectory')
#    plt.show()
    path = '~/PyPlots/'
    if not os.path.isdir(path): os.makedirs(path)
    filename = 'plot%d.png' % req.cycle
    filename = os.path.join(path, filename)
    fig.savefig(filename)
    resp = plot_resultResponse()
    resp.succes = 1
    return resp

However the figures don't show up in the given directory. First I had an error that the directory didn't exist that's why I added the check and if it doesn't exist, the directory is created. After searching my filesystem it appears that the directory that is created is /proc/pid_of_server/cwd/~/PyPlots/ in which the plots can be found.

Am I doing something wrong or is this a bug in ROS? Personally I think it is the second because I just follow the python docs (not enough karma to link).

If there is a solution, please let me know.