Questions tagged [rospy]
The rospy tag has no usage guidance.
478 questions
2
votes
3
answers
112
views
message_filters doesn't call the callback function
I'm trying to use the message_filters in order to subscribe to two topics. Here's my code
...
2
votes
2
answers
104
views
does rospy support rosparam update callbacks?
Using rospy/ROS1, I would like a callback when a certain parameter on the ROS1 parameter ...
1
vote
1
answer
186
views
How to subscribe for a single message from a topic (receive once and then stop)
I would like to get a single message from a topic. Is there a built-in, simple, elegant way to do this? Currently, I am creating a subscriber, and using a ...
1
vote
1
answer
43
views
is rospy.Publisher.publish() thread safe?
Want to publish() in main and also in child thread on one rospy.Publisher(),is this safe?
Originally posted by dyan on ROS Answers with karma: 7 on 2017-03-17
Post score: 0
1
vote
2
answers
275
views
How do you implement a rospy KeyboardInterrupt without killing the node?
I want to run a process in a while loop that prints to screen, and exit the while loop by pressing a key or 'Ctrl+C'. But I don't want the same key press to also kill the ros node - I just want to ...
1
vote
1
answer
270
views
Transform a pose to another frame with tf2 in Python
I have a pose stamped given in camera frame. Now I want to transform the pose to get its coordinates in the base_link frame.
Originally posted by fivef on ROS Answers with karma: 2756 on 2015-12-10
...
1
vote
2
answers
25
views
(How) can a rospy node be reinitialized after ctrl+c?
TL:DR Is there a correct way to use rospy in the interactive shell? Seems stuck in shutdown after ctrl+c
Since interacting with ros from python is much more powerful than interacting via the command ...
1
vote
0
answers
50
views
Why is ROS1 Message Generation Slow in Python?
I hit a performance issue when trying to use a custom message type in ROS 1 Noetic in Python. My custom message was defined like this:
...
1
vote
0
answers
18
views
Collision Checking using Moveit (python wrapper) for a set of Joint Positions
I have a set of robot joint positions which I found by sweeping through the allowed joint positions with a fixed delta. This gives me about a set of ~2 million joint positions. Now, I want to check ...
1
vote
0
answers
162
views
Using .pyc files instead .py with roslaunch [closed]
I am working on a docker and using ROS 1 noetic as of now.
For certain reasons I do not want to distribute .py files as end user do not need to understand what is inside there. So I am using .pyc ...
1
vote
1
answer
53
views
ROS1 Custom messages generates strange memory graph pattern when using multiple string types
In ROS1 Noetic, I have the following custom message named Test.msg:
int32 did
string a
string b
And I have another custom message TestList.mgs:
Test[] testList
In ...
1
vote
1
answer
64
views
Should I unregister from Publishers/Subscribers when I terminate a ROS node by exiting the script?
Hi everyone.
So my question is pretty much what the title is. Is it good practice or even necessary to unregister from ROS publishers or subscribers I used inside my ROS node before terminating the ...
1
vote
1
answer
29
views
Accessing rviz view (Camera + Marker) in rospy
I want to get the rviz view, which is showing me visualization marker on the top of camera view in a single image. Please see below the rviz view:
I tried to view the image topic but it doesn't ...
1
vote
2
answers
63
views
Passing arguments to callback in Python
Hi!
I have a problem passing arguments to a callback function when Subscribing a ROStopic. The code below is what I do have now. But I only received error messages when I tried to pass arguments to ...
0
votes
1
answer
38
views
ROS node testing (publish/subscribe)
I am struggling with an example integration test for a ROS node (in Python). I have a node that somehow processes input data and outputs some messages based on this:
...
0
votes
1
answer
625
views
How to add a header with timestamp to numpy_msg?
I am using the rospy with numpy tutorial to create a publisher and subscriber that send numpy arrays to listener that uses an ApproximateTimeSynchronizer. However, I receive an error when I try to ...
0
votes
2
answers
100
views
Pycharm 'No module named rospy'
Pycharm IDE doesn't seem to recognize ROS modules (It underlines them and doesn't autocomplete), even though when I run the script, the interpreter does recognize them.
I should add that I am opening ...
0
votes
2
answers
11
views
Cancel rospy action with Ctrl+C
Hi to everyone,
i'm using a class in which some methods call actions as SimpleActionClient.
I create a node in the same executable i create the class instance and leave if the signal handling.
When i ...
0
votes
1
answer
33
views
Python Import not being recognized
Hi guys,
I'm currently working through a textbook call Programming Robots with ROS. There is a chapter that goes over a simple movement code for a turtlebot simulator. The code is pasted below.
...
0
votes
1
answer
139
views
How do I reset a rospy Timer?
How do I reset a rospy Timer? I want to have a Python node that sends out a message like cmd_vel as a step function to test a controller, but I also want to use ...
0
votes
0
answers
6
views
Call rosservice clear with rospy
I am currently using
clear_bg = rospy.ServiceProxy('/clear', std_srvs.srv.Empty)
clear_bg()
Which is said to be working on previous posts. However this is not working for me. Why?
0
votes
0
answers
16
views
Node initialization blocks with rospy for UR5e Robot Arm
I am having trouble to remotely control the UR5e robot arm using code. I am using ROS Noetic and trying to run test_move.py present in Universal Robots' repository ...
0
votes
0
answers
22
views
Python Multi-Robot ROS 1 environment: defining multiple robots in class form (each with their own ROS node) and accessing their class objects?
I'm interested in building a multi-robot learning environment using a simulator such as Gym for the environment and ROS 1 for handling communication between robots.
I'd like to set up my environment ...
0
votes
1
answer
73
views
where is the beginner_tutorials.srv file in the add_two_ints tutorial?
I am learning ros noetic on the page (https://wiki.ros.org/rospy_tutorials/Tutorials/WritingServiceClient)In the scripts/add_two_ints_server.py file within the beginner_tutorials package, there is a ...
0
votes
1
answer
829
views
rospy.init_node() stuck in loop
I had a problem with initializing a ROS node in python in a larger project. The following minimum reproducible example has the same issue:
...
0
votes
1
answer
27
views
Possible wrong ussage of transformPoint method from tf
ROS VERSION: Melodic
OS VERSION: Ubuntu 18.04
package tf version: 1.12.1
I'm trying to create a node that processes a PolygonStamped object and transform each point of it to a especified frame_id in ...
0
votes
0
answers
27
views
How to publish images of a file.bag on a topic with python?
I'm a beginner with ROS, so i thank you in advance for your answers.
I have a file.bag (Video) available and I would like to publish the various frames on a specific topic at defined moments of time ...
0
votes
0
answers
25
views
Issues with asynchronously handling a Subscriber callback
I am trying to create a listener that sends a message through a Discord webhook to my Discord server. The issue that I am encountering at the moment is that I do not know how to create an asynchronous ...
0
votes
1
answer
163
views
Custom ROS Service Cannot be Imported
I have created a simple custom ROS service for ROS Noetic. My import line is:
from fishbot_ros.srv import chess_service, chess_serviceResponse
The file structure ...
0
votes
1
answer
27
views
Rospy getNumSubscribers()
In rospy do you have a getNumSubscribers() function for the Publisher?
Originally posted by schizzz8 on ROS Answers with karma: 183 on 2023-06-03
Post score: 0
0
votes
1
answer
1k
views
"ERROR: Unable to communicate with master!" and "Unable to Register with master node"
Hello,
I have two computers on a local network. First of them has Ubuntu 18.04 as OS, ROS Melodic installed and connected to the network with an Ethernet cable. The other one has Windows 10 as OS, ...
0
votes
1
answer
12
views
rospy and Subscriber/Publisher garbage collection
Do I need to store a reference to rospy subscribers and publishers to avoid these objects to be garbage collected?
...
0
votes
1
answer
5
views
How to get consecutive images with 3 seconds delay
Hello,
I am trying to read two consecutive images from my rostopic using rospy.Subscriber to compare the orientation between these pictures but using the code below, I found out two images I get are ...
0
votes
1
answer
32
views
Raising Exceptions in Subscriber Callbacks
ROS distribution: noetic, rospy
I want to raise specific exceptions depending on the data received from the rostopic. However, raising exceptions in the subscriber callback (user_callback) returns a ...
0
votes
1
answer
217
views
Using rospy.sleep inside a callback
My understanding is that rospy.sleep() will return control to ROS so that it can schedule any other processes that need a turn, and also waith the designated time before it "returns". I put ...
0
votes
1
answer
18
views
Is it possible to publish msg in rospy.on_shutdown
I want to publish message while roscore is closing. I tried to use rospy.on_shutdown but it didn't work. In wiki it says "Messages are not guaranteed to be published." for on_shutdown. I am ...
0
votes
1
answer
81
views
How to generate 'format: "32FC1; compressedDepth png"' Image in python from float array?
I think there's an answer that involves converting C++ code (https://github.com/ros-perception/image_transport_plugins/blob/noetic-devel/compressed_depth_image_transport/src/codec.cpp) to python- does ...
0
votes
1
answer
13
views
[ERROR] : Called wait_for_result when no goal exists
This is terminal output:
...
0
votes
1
answer
10
views
Making rosnode_cleanup() not wait for y/n from user
I arrived at rosnode_cleanup() after looking at #q9521 and #q285530.
I need to use rosnode.rosnode_cleanup() in my Python script, but it is blocking because it ...
0
votes
1
answer
491
views
Wait for subscriber callback to receive message - best practice
Hello, I am wondering what is the best practice in python to wait for a subscribed topic to start publishing, before using its messages in the spin method. An simplified example of what I am doing ...
0
votes
1
answer
45
views
Image Subscriber Lags (despite queue_size=1 and buff_size=2**30)
Hi,
I have been working on a Python class that will allow me to spawn an object in gazebo, take an image of the object, and then delete that object, for a given number of objects that I provide. I am ...
0
votes
1
answer
18
views
Does ROS have anything similar to a "global variable"?
I created a node that subscribes data from 3 other nodes (2 nodes publish data in 30Hz while 1 node publishes in about 10Hz). The node I created uses a transformation matrix(4x4) from the slower node (...
0
votes
1
answer
368
views
Reading from topic once using rospy.wait_for_message()
Hi,
I want to read a message from a topic once, thus I tried to use wait_for_message() like this:
...
0
votes
1
answer
64
views
Recursively get message field names in ROS2
We have the handy rosidl_runtime_py.message_to_csv() method for converting a message to CSV, but is there a similar function that will recursively get the field ...
0
votes
1
answer
124
views
vscode: rospy import error
The env I am using is ROS Noetic and VS Code along with Pylance.
launching rospy nodes is working fine
importing rospy gives a squiggle error in VSCode.
Also, python syntax is not being highlighted ...
0
votes
1
answer
2
views
Is there a way to subscribe to different topics at the same time in rospy?
I am subscribing to various topics and I wish to print them into a .csv log file, but I am not able to print any one of them outside their own callback function.
You can see the code at Click for Code ...
0
votes
1
answer
20
views
TypeError: cannot marshal <type 'numpy.uint8'> objects
I am unable to set parameters to the param server using the following code:
hsv = cv2.cvtColor(image,
cv2.COLOR_BGR2HSV)
rospy.set_param("lower_h", hsv[:, :,
0].min()) rospy.set_param("...
0
votes
1
answer
44
views
How to correctly return an array of ints from service?
I have the following code:
RouteRemainder.srv:
---
int64[] route_remainder
routes_manager,py:
...
0
votes
1
answer
58
views
How to correctly translate a pose along an axis?
I have a pose of my robot base_link in the map frame. I'd like to translate this 0.2 m along ...
0
votes
1
answer
67
views
How to remove lag in marker publishing?
I am publishing markers in a subscriber callback so that whenever new data is received on a topic a marker is created. Markers are published and displayed well at first but after a while markers are ...