rospy

Use data from multiple topics in ROS - Python

落爺英雄遲暮 提交于 2020-06-26 05:56:13
问题 I'm able to display data from two topics but I can't do use and compute data in real time from these two topics in ROS (written in Python code). Have you got any idea to stock this data and compute in real time ? Thanks ;) #!/usr/bin/env python import rospy import string from std_msgs.msg import String from std_msgs.msg import Float64MultiArray from std_msgs.msg import Float64 import numpy as np class ListenerVilma: def __init__(self): self.orientation = rospy.Subscriber('/orientation',

Use data from multiple topics in ROS - Python

混江龙づ霸主 提交于 2020-06-26 05:54:50
问题 I'm able to display data from two topics but I can't do use and compute data in real time from these two topics in ROS (written in Python code). Have you got any idea to stock this data and compute in real time ? Thanks ;) #!/usr/bin/env python import rospy import string from std_msgs.msg import String from std_msgs.msg import Float64MultiArray from std_msgs.msg import Float64 import numpy as np class ListenerVilma: def __init__(self): self.orientation = rospy.Subscriber('/orientation',

Is it possible to time synchronize two topics in ROS of same message type?

喜夏-厌秋 提交于 2019-12-31 04:30:09
问题 I try to map robot gripper position to the resistance exerted by the object held by the gripper. I subscribed the gripper position from one topic and resistance value from another topic, since I want to ensure that the gripper position corresponds to the exact resistance value at that position. Given that both are float messages, how can I synchronize them? self.sub1 = rospy.Subscriber("resistance", Float64, self.ard_callback) self.sub2 = rospy.Subscriber("gripperpos", Float64, self.grip

How to feed the data obtained from rospy.Subscriber data into a variable?

自作多情 提交于 2019-12-13 17:43:58
问题 I have written a sample Subscriber. I want to feed the data that I have obtained from the rospy.Subscriber into another variable, so that I can use it later in the program for processing. At the moment I could see that the Subscriber is functioning as I can see the subscribed values being printed when I use rospy.loginfo() function. Although I donot know how to store this data into another varible. I have tried assigning it directly to a variable by using assignment operator '=', but I get

Update the global variable in Rospy

淺唱寂寞╮ 提交于 2019-12-13 12:41:07
问题 i have the problem. I have two node, node 1 and node2, where node1 send a float number in node2 and node2 send a float number in node1. In the function callback, I want sum the information received with other value and update the variable. But the problem is that i don't succeed the information sent, because the terminal prints in output only first update(for node 1 i get 2.9, and node 2 2.0) These code for node1 and node2 Node1 !/usr/bin/env python import rospy import time from std_msgs.msg

Tcl_AsyncDelete Error. Unable to terminate Tk

断了今生、忘了曾经 提交于 2019-12-11 16:04:41
问题 I am using Tkinter in a ROS node to create a GUI and publish the scale values to another ROS Node. I have accomplished this. The problem comes when I try to close this GUI and rerun the node. The log message that I get is as follows: Exception RuntimeError: 'main thread is not in main loop' in <bound method DoubleVar.__del__ of <Tkinter.DoubleVar instance at 0x7f19ea0c3ab8>> ignored Tcl_AsyncDelete: async handler deleted by the wrong thread Aborted (core dumped) According to this, I think I

How to update matplotlib pyplot on every iteration

自作多情 提交于 2019-12-11 07:26:24
问题 I am using rospy to get data of my robot's position and plot this in real time. This is what I have: self.plot_pose() def plot_pose(self): plt.plot(self.pose[0], self.pose[1], 'o', color='green') plt.plot([self.pose[0], self.pose[0] - 0.5*np.cos(self.pose[2])], [self.pose[1], self.pose[1] + 0.5*np.sin(self.pose[2])], 'k-', color='red', lw=2) plt.show(block=False) plt.pause(0.0001) Unfortunately this doesn't erase the plot but overlays everything. So I tried using plt.clf() plt.cla() the first

Drone's motion is unstable with ROS topics

我的梦境 提交于 2019-12-09 08:34:26
Drone's motion is not stable with rostopics...what can I do ? import rospy import time #import library untuk mengirim command dan menerima data navigasi dari quadcopter from geometry_msgs.msg import Twist from std_msgs.msg import String from std_msgs.msg import Empty from ardrone_autonomy.msg import Navdata #import class status untuk menentukan status ddari quadcopter from drone_status import DroneStatus COMMAND_PERIOD = 1000 class AutonomousFlight(): def __init__(self): self.status = "" rospy.init_node('forward', anonymous=False) self.rate = rospy.Rate(10) self.pubTakeoff = rospy.Publisher(

Python script won't exec from php when specific library is used

*爱你&永不变心* 提交于 2019-12-08 13:18:34
问题 Im trying to execute a Python script to get and set the parameter server in ROS. When I run any other simple python script that for example prints "Hello", I get back the value in PHP. But when I run this code: #!/usr/bin/env python import roslib import rospy import sys import re import string get = rospy.get_param("param") print get I get an empty echo. However this code works fine in the terminal! All I'm doing in PHP is: $output = exec("python path/script.py") echo $output; I tried shell

Drone's motion is unstable with ROS topics

那年仲夏 提交于 2019-12-08 03:32:57
问题 Drone's motion is not stable with rostopics...what can I do ? import rospy import time #import library untuk mengirim command dan menerima data navigasi dari quadcopter from geometry_msgs.msg import Twist from std_msgs.msg import String from std_msgs.msg import Empty from ardrone_autonomy.msg import Navdata #import class status untuk menentukan status ddari quadcopter from drone_status import DroneStatus COMMAND_PERIOD = 1000 class AutonomousFlight(): def __init__(self): self.status = ""