Created
May 27, 2020 12:35
-
-
Save mgruhler/df9d1fafb5d153d0d23c944c2aa339d6 to your computer and use it in GitHub Desktop.
test talker for https://answers.ros.org/question/353359
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python | |
import rospy | |
from test.msg import test | |
import random | |
_frame_id = "blub" | |
_traj_id = random.randint(0, 500) | |
_traj_step = random.randint(0, 500) | |
_joints_res_eff_cmd = [random.random() for x in xrange(7)] | |
_joints_pos = [random.random() for x in xrange(7)] | |
_joints_vel = [random.random() for x in xrange(7)] | |
_joints_acc = [random.random() for x in xrange(7)] | |
_wrench_ee = [0, 0, 0] | |
_twist_ee = [2, 5, 55, 8] | |
_ee_pos = [random.random() for x in xrange(7)] | |
_ee_quat = [random.random() for x in xrange(7)] | |
_joints_eff = [random.random() for x in xrange(7)] | |
_in_contact = (True if random.randint(0, 500) > 250 else False) | |
def talker(): | |
pub = rospy.Publisher('test', test, queue_size=10) | |
rospy.init_node('talker') | |
rate = rospy.Rate(1000) | |
test_msg = test() | |
test_msg.header.frame_id = _frame_id | |
while not rospy.is_shutdown(): | |
test_msg.joints_eff = _joints_res_eff_cmd | |
test_msg.joints_pos = _joints_pos | |
test_msg.joints_vel = _joints_vel | |
test_msg.joints_acc = _joints_acc | |
test_msg.wrench_ee = _wrench_ee | |
test_msg.twist_ee = _twist_ee | |
test_msg.ee_pos = _ee_pos | |
test_msg.ee_quat = _ee_quat | |
test_msg.in_contact = _in_contact | |
test_msg.joints_eff = _joints_eff | |
test_msg.header.stamp = rospy.Time.now() | |
test_msg.traj_step = _traj_step | |
test_msg.traj_id = _traj_id | |
pub.publish(test_msg) | |
rate.sleep() | |
if __name__ == '__main__': | |
try: | |
talker() | |
except rospy.ROSInterruptException: | |
pass |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment