0
$\begingroup$

Rosanswers logo

Hi all,

I have been following this question very closely.

This is how mine looks like:

def talker(armj_acc) :
    pub10 = rospy.Publisher('/armj_acc', obs_arm_JointAccelerations)
    msg2send10 = obs_arm_JointAccelerations()
    msg2send10.header.stamp.secs = time_now
    msg2send10.accelerations = armj_acc
    pub10.publish(msg2send10)
    

I have my own custom message, by the name obs_arm_JointAccelerations which contains

Header header 
float64[] accelerations

The variable armj_acc is actually a list whose values have been successfully calculated and passed into the function, which I print them on the screen. The calculation for the armj_acc is done via subscribing velocities from the /joint_states topic, every 4 seconds ((current velocity - previous velocity) /4).

The problem is, whenever I try to echo the topic, it gives me the following error:

(1) In the terminal where the topic is being echo-ed

WARNING: no messages received and simulated time is active. Is /clock being published?

(2) In the terminal where the code is run:

[ERROR] [WallTime: 1367266510.640556] [5269.097000] bad callback: <function callback at 0x2f6e1b8> Traceback (most recent call last): File "/opt/ros/fuerte/lib/python2.7/dist-packages/rospy/topics.py", line 678, in _invoke_callback cb(msg) File "/home/path/to/my/package/script/obs_armj_all.py", line 47, in callback talker(armj_names, armj_act_positions, armj_act_velocities, armj_effort_act, armj_effort_diff, armj_pos_rel_diff)#, armj_acc)#, armj_jerk) File "/home/path/to/my/package/script/obs_armj_all.py", line 185, in talker pub10.publish(msg2send10) File "/opt/ros/fuerte/lib/python2.7/dist-packages/rospy/topics.py", line 796, in publish raise ROSSerializationException(str(e)) ROSSerializationException: cannot convert argument to integer

Any ideas?

Thanks.


Originally posted by whiterose on ROS Answers with karma: 148 on 2013-04-29

Post score: 0

$\endgroup$

2 Answers 2

0
$\begingroup$

Rosanswers logo

If your posted code matches what you're running, it looks like you're publishing the wrong variable. You're trying to publish the armj_acc array directly, rather than the msg2send10 message. I'm also not sure that you're allowed to assign a time directly to the header field like you've shown.

Try this:

def talker(armj_acc) :
    pub10 = rospy.Publisher('/armj_acc', obs_arm_JointAccelerations)

    msg2send10 = obs_arm_JointAccelerations()
    msg2send10.header.stamp = rospy.Time.now()
    msg2send10.accelerations = armj_acc
    pub10.publish(msg2send10)

Originally posted by Jeremy Zoss with karma: 4976 on 2013-04-29

This answer was ACCEPTED on the original site

Post score: 1


Original comments

Comment by whiterose on 2013-04-29:
I edited that one, it is now: msg2send10.header.stamp.secs = time_now, where time_now = rospy.Time.now(), which is actually wrong. It is supposed to be: msg2send10.header.stamp.secs = time_now.secs... Thanks!

$\endgroup$
0
$\begingroup$

Rosanswers logo

Publishers take a little while to register themselves with the master. By creating a publisher and then publishing a message immediately, the publisher has likely not finished registering, so the message will be lost. Try sleeping a little bit before before publishing, or (if appropriate) publishing inside a loop.


Originally posted by Dan Lazewatsky with karma: 9115 on 2013-04-29

This answer was NOT ACCEPTED on the original site

Post score: 1

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.