ROS Answers: Open Source Q&A Forum - RSS feed source question and answer forum written in Python and DjangoenROS Answers is licensed under Creative Commons Attribution 3.0Tue, 29 May 2018 09:56:34 -0500How to subscribe for a single message from a topic (receive once and then stop) 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 `threading.Event` object to signal when it receives a message, and automatically unregister itself. It works, but it seems unwieldy for a task that I presume to be fairly common. class SomeClass: def __init__(self): = None self.get_data_subscriber = None self.get_data_event = threading.Event() def get_data_callback(self, data): = data self.get_data_subscriber.unregister() self.get_data_subscriber = None self.get_data_event.set() def run(self): rospy.init_node('myNodeName', anonymous=True) self.get_data_subscriber = rospy.Subscriber('/sometopic', SomeType, self.get_data_callback) while True: self.get_data_event.wait(0.1) # sleep 100ms or wakeup sooner if event was set # wait() didn't have a return value until python 2.7, so for compatibility, don't rely on the return val. # is_set() method was added in python 2.6, so for compatibility, use isSet() instead. if self.get_current_pose_event.isSet(): self.get_current_pose_event.clear() break if rospy.is_shutdown(): return rospy.loginfo("data is: {}".format(data)) return if __name__ == "__main__": foo = SomeClass() rahveeTue, 29 May 2018 09:56:34 -0500 a (Gazebo) service parallelly from multiple nodes/ Remapping a (Gazebo) service to a particular namespace have a multi robot setting (with different namespaces which work totally independent of each other, in the same empty_world) in Gazebo. I have to reset the manipulated objects after a certain time interval. I have different ROS nodes controlling the robots and the resetting objects. So I want to use gazebo/set_model_state service parallelly in all the nodes. Spawning one robot works fine as it is the only node using the service. But as soon as I launch the second node it gives me the following error from the first simulation and the second simulation starts running fine. > rospy.service.ServiceException: > service [/gazebo/set_model_state] > returned no response I'm aware that the service call executes commands in a serial manner. But I would like to call the service parallelly from all the nodes at the same time. Is this possible? I suppose this can be done if I can somehow "remap" the service like I do for the topics. That way I can specifically call the service belonging to the robot of that particular namespace. Or if I somehow clone the existing service into multiple unique services each node can call these unique nodes parallelly. But I'm not sure how this can be done. Any suggestions?nfTue, 17 Apr 2018 08:41:24 -0500 how to actuate individual joints that do not form a chain?, I'm working on a project at my university in which we are designing and simulating an industrial robot system. We have created a URDF file that contains the robot system, as well as the platform it sits on. There are also two movable caterpillar tracks on this platform, which we need to be able to control programmatically. We've created a MoveIt configuration for the robotic arm that the robot system consists of, which works properly. To give you a bit of an image (literally) of how the system and the tracks look like: ![overview](/upfiles/15155368113219135.png) ### Question: My problem arises when I want to control the two movable tracks, which each consist of just a single joint. The relevant parts of the robot's URDF are included below; for brevity, I left out the rest. I want to be able to control the individual joints `track2_joint` and `track3_joint` from Python, but I have not yet been able to find out how... ### My attempts I've tried to make a planning group with just `track2_joint` in it without selecting a kinematics solver, hoping that I would be able to use `group.set_joint_value_target` in order to get easy control over the track. The MoveIt Setup Assistant allowed me to do so, so I tried it out in some code, here's the relevant snippet: robot = moveit_commander.RobotCommander() joint = robot.get_joint('track2_joint') moveGroup = moveit_commander.MoveGroupCommander('Track2') currentJointValues = moveGroup.get_current_joint_values() print("Min bound: " + str(joint.min_bound())) print("Value: " + str(currentJointValues)) print("Max bound: " + str(joint.max_bound())) currentJointValues[0] += pi * 1/3 moveGroup.set_joint_value_target(currentJointValues) moveGroup.plan() This seemed to work fine. The print statements printed the correct values and `plan` caused the correct rotation to be shown in RViz. But when I replaced `plan()` with `go()`, I got the following message in the console in which I launched the test: `[ INFO] [1515523071.981027951]: ABORTED: Solution found but controller failed during execution` The following appeared in the console in which I launched the planning execution launch file: [ INFO] [1515523071.563018404]: Combined planning and execution request received for MoveGroup action. Forwarding to planning and execution pipeline. [ INFO] [1515523071.563289980]: Planning attempt 1 of at most 1 Debug: Starting goal sampling thread Debug: Waiting for space information to be set up before the sampling thread can begin computation... [ INFO] [1515523071.564900737]: Planner configuration 'Track2' will use planner 'geometric::RRTConnect'. Additional configuration parameters will be set when the planner is constructed. Debug: RRTConnect: Planner range detected to be 1.256640 Info: RRTConnect: Starting planning with 1 states already in datastructure Debug: RRTConnect: Waiting for goal region samples ... Debug: Beginning sampling thread computation Debug: Stopped goal sampling thread after 10 sampling attempts Debug: RRTConnect: Waited 0.010084 seconds for the first goal sample. Info: RRTConnect: Created 5 states (2 start + 3 goal) Info: Solution found in 0.012115 seconds Info: SimpleSetup: Path simplification took 0.001880 seconds and changed from 4 to 17 states [ERROR] [1515523071.662697635]: Joint trajectory action failing on invalid joints [ WARN] [1515523071.663024659]: Controller failed with error code INVALID_JOINTS [ WARN] [1515523071.663147109]: Controller handle reports status FAILED I suspected it was most likely due to the fact that I had not specified a kinematic solver, so I thought I'd just select the default KDLKinematicsPlugin, but that gave me the following error while launching the planning execution file: [ERROR] [1515523523.939177828]: Group 'Track2' is not a chain [ERROR] [1515523523.939227171]: Kinematics solver of type 'kdl_kinematics_plugin/KDLKinematicsPlugin' could not be initialized for group 'Track2' [ERROR] [1515523523.940096000]: Kinematics solver could not be instantiated for joint group Track2. Defining the planning group 'Track2' as a chain from `base_link` to `track2_link` was not able to solve that either. I have been scouring the internet to find another way in which I can actuate a single joint, but I cannot seem to find any good way. [This question]( suggests setting up a "JointModelGroup" in the SRDF for each single joint, which seems to correspond with just creating a planning group in the setup assistant like I tried earlier. The answer to another question I found suggested the same thing. I've also seen several suggestions towards the `RobotState` class, but that does not exist in Python. I believe its Python equivalent is RobotCommander though, which is where I can get the joint from as shown in my earlier snippet. The joint object that is returned apparently also has a `move` method, but that just tries to retrieve the group it is in, set a joint value target on that and then call its `go()` method, which is the very thing that failed earlier. Relevant parts of the URDF: <robot name="pacbot"> <link name="world"/> <joint name="fixed_base" type="fixed"> <parent link="world"/> <child link="base_link"/> </joint> <link name="base_link"> <inertial> <origin xyz="-1.0287 1.7496 2.683" rpy="0 0 0" /> <mass value="118270" /> <inertia ixx="686480" ixy="-23450" ixz="-529.82" iyy="646590" iyz="-6038.5" izz="1177900" /> </inertial> <visual> <origin xyz="0 0 0" rpy="0 0 0" /> <geometry> <mesh filename="package://pacbot_description/meshes/base_link.STL" /> </geometry> <material name=""> <color rgba="0.75294 0.75294 0.75294 1" /> </material> </visual> <collision> <origin xyz="0 0 0" rpy="0 0 0" /> <geometry> <mesh filename="package://pacbot_description/meshes/base_link.STL" /> </geometry> </collision> </link> <link name="track2_link"> <inertial> <origin xyz="0.467 0.059929 0.10079" rpy="0 0 0" /> <mass value="1993" /> <inertia ixx="741.31" ixy="6.7487E-05" ixz="8.7846E-05" iyy="335.06" iyz="70.438" izz="411.08" /> </inertial> <visual> <origin xyz="0 0 0" rpy="0 0 0" /> <geometry> <mesh filename="package://pacbot_description/meshes/track2_link.STL" /> </geometry> <material name=""> <color rgba="0.75294 0.75294 0.75294 1" /> </material> </visual> <collision> <origin xyz="0 0 0" rpy="0 0 0" /> <geometry> <mesh filename="package://pacbot_description/meshes/track2_link.STL" /> </geometry> </collision> </link> <joint name="track2_joint" type="revolute"> <origin xyz="-0.020167 4.4565 3.216" rpy="7.015E-17 -3.7018E-16 -2.3562" /> <parent link="base_link" /> <child link="track2_link" /> <axis xyz="0 1 0" /> <limit lower="-3.1416" upper="3.1416" effort="1000" velocity="3.1416" /> </joint> <link name="track3_link"> <inertial> <origin xyz="0.467 0.059929 0.10079" rpy="0 0 0" /> <mass value="1993" /> <inertia ixx="741.31" ixy="6.749E-05" ixz="8.7848E-05" iyy="335.06" iyz="70.438" izz="411.08" /> </inertial> <visual> <origin xyz="0 0 0" rpy="0 0 0" /> <geometry> <mesh filename="package://pacbot_description/meshes/track3_link.STL" /> </geometry> <material name=""> <color rgba="0.75294 0.75294 0.75294 1" /> </material> </visual> <collision> <origin xyz="0 0 0" rpy="0 0 0" /> <geometry> <mesh filename="package://pacbot_description/meshes/track3_link.STL" /> </geometry> </collision> </link> <joint name="track3_joint" type="revolute"> <origin xyz="0.64027 1.9109 3.216" rpy="4.4247E-16 3.7928E-16 2.3562" /> <parent link="base_link" /> <child link="track3_link" /> <axis xyz="0 1 0" /> <limit lower="-3.1416" upper="3.1416" effort="1000" velocity="3.1416" /> </joint> </robot> My `controllers.yaml` file: controller_list: - name: "" action_ns: joint_trajectory_action type: FollowJointTrajectory joints: [cart1_joint, main1_joint, elbow1_joint, forearm1_joint, wrist1_joint, gripper1_joint] So, how do I get this done? Is it still possible with MoveIt planning groups, or is there another way in which this should be done? I also need this in order to be able to control the different parts of the gripper at the end of the arm.BvOBartTue, 09 Jan 2018 13:27:41 -0600 use case of communication of nodes on different netowkrs? want to know if there are use cases that nodes on different(distributed) networks communicate with each other, using single ROS Master. It's like: - PC A on Network A: ROS Master and node A(A1, A2...) - PC B on Network B: Node B(B1, B2...) - (PC C on network C: Node C) I heard Rapyuta was true of this case. If you know something about this, let me know!Lain IwakuraSun, 17 Jan 2016 03:00:23 -0600 I use the same planner for both global and local planner and can I have only one planner for navigation instead of using global and local planners? I am trying to write a full coverage path planner, where the robot has to visit every free space in the costmap avoiding obstacles without any repetitions. For this I only want to have a single full coverage path planner instead of having global and local planners. Is it possible in ROS to have only one planner to navigate the robot? If it is possible what changes have to be done in move_base and other related programs?Dharmateja KademTue, 19 Jul 2016 15:05:39 -0500 single board computer should I chose? Hi ros community I' m working with ros to make a robot which can go itself with image proccessing. I am using lots of hardware in this project and I used pcduino V3 until this time. But I want to change pcduino because I' m having some trouble with it. I looked lots of single board compuers on the internet and finally find 4 boards to chosing. But I cannot decide which board I should choice for best performance. Can anyone help me for it? I can give 100$ at most, so I find: - Banana Pi M3 ==> 1.8Ghz * 8 Cores / PowerVR SGX544MP1 / wireless / 8 Gb Emmc Flash /2 usb ports - Orange Pi Plus 2 ==> 1.6Ghz * 4 Cores / Mali 400 Mp2 / wirekes / 16 Gb Emmc Flash / 4 usb ports - Odroid XU4 ==> 2.0Ghz * 4 Cores + 1.4 Ghz * 4 Cores / Mali T 628 MP6 / no wireless / no flash / 3 usb ports - Odroid C2 ==> 2.0Ghz * 4 Cores / Mali 450 / no wireless / no flash / 4 usb ports Which board is the powerfull board from other boards or are there more powerpull board from these?(less $100) Thanks a lot..baseroguzhanSat, 26 Mar 2016 06:43:19 -0500 Frontier_exploration Hello, I am curently working on a turtlebot with ubuntu 14.04 LTS and ROS Indigo, and i am trying to use send the frontier_server an actionlib goal to do unbound exploration. My problem is that when the explore_server receive my goal it say that "couldn't transform from map to U+0001 Failed to set region boundary" From the explore_server code it seems that the problem come from the updateBoundaryPolygon service, but i don't really know what the problem is. Here is the code i use as actionlib single goal client #include <ros/ros.h> #include <actionlib/client/simple_action_client.h> #include <actionlib/client/terminal_state.h> #include <test_client/ExploreTaskAction.h> int main (int argc, char **argv) { ros::init(argc, argv, "frontier_exploration_client"); // create the action client // true causes the client to spin its own thread actionlib::SimpleActionClient<test_client::ExploreTaskAction> ac("explore_server", true); ROS_INFO("Waiting for action server to start."); // wait for the action server to start ac.waitForServer(); //will wait for infinite time ROS_INFO("Action server started, sending goal."); // send a goal to the action test_client::ExploreTaskGoal goal; goal.explore_boundary.header.seq = 1; goal.explore_boundary.header.frame_id = 1; goal.explore_center.point.x = 1; goal.explore_center.point.y = 0; goal.explore_center.point.z = 0; ac.sendGoal(goal); //wait for the action to return bool finished_before_timeout = ac.waitForResult(ros::Duration(30.0)); if (finished_before_timeout) { actionlib::SimpleClientGoalState state = ac.getState(); ROS_INFO("Action finished: %s",state.toString().c_str()); } else ROS_INFO("Action did not finish before the time out."); //exit return 0; } Any clues on where i made a mistake ? EDIT : Ok, problem solved, the cause was the header that was badly configured : it need to be goal.explore_boundary.header.frame_id = "map" to work. The problem now is that the frontier explorer node only give goals that are at the robot's position, resulting in the robot staying at his initial position.Swan BaigneMon, 11 May 2015 03:44:42 -0500 - single instruction, i want to make this instruccion for the turtlebot: > $ turtle_walk with_SPEED with_DIRECTION turtle_walk allows to move the motors of the turtlebot with certain speed and in certain direction, but i don want to do something like keyboard_teleop that stays in a cicle and waits for the user. For example: > $ shh turtle@turtlebot > $ turtle_walk foo bar And the result is that the robot was able to move it self ONE STEP no more and the terminal can receive another diferent instruction.pexisonMon, 02 Feb 2015 08:25:52 -0600 to calculate covariance matrix for monocular SLAM? there, I am using a single camera for visual odometry. The camera is fixed to the robot and I use the common approach of matching descriptors between consecutive frames and then estimating the rotation and translation using SVD. The camera is already calibrated and I already have the points in 3D position. From the rotation matrix and the translation matrix I can obtain the the rotation angles and the new position x,y,z of the robot. My question then is: How can I estimate the covariance matrix for theses values in order to publish an nav_msgs::Odometry matrix? I suspect that I have to backpropagate the points from one frame to the other, but I am not sure. Any references to papers/books are also welcome =) Thanks in advance, PedroPedroGusmaoThu, 31 Jul 2014 11:05:29 -0500 board PC for ROS Which Single board computers are recommended/better suited for running ROS (Fuerte and Ubunutu 12.04 or other recommendation)? This has been asked a few times before, but not recently as far as I could find anwyays, sorry if double up though. My application will be running with a Hokuyo URG LIDAR ( and using an Arduino to do all the motor/servo controls. All low level control such as SLAM will done on board so will need to be capable of processing everything. It will also be sending and receiving high level information from a main computer so will need to be network capable as well, we do currently have a Wireless modem on the robot itself so the SBC does not need built in wireless. Cheers for any advice HenryHenryWMon, 15 Oct 2012 17:44:36 -0500 single echo scan error'm using the urg_node to run the hokuyo utm 30lx ew. I have the lidar set up through a wireless router, I only need it for a single scan(not a multiscan). Occasionally, the node shoots me the warnings, Could not grab single echo scan. I get 5 warnings, then it tries to reconnect. After the reconnect fails, the sequence happens again. Then finally, it successfully reconnects. This would happen pretty maybe once every 1-3 minutes. Is there is a way to get rid the scan retrieving failure? Thank you! Edit: It was because of the wireless set up that I was receiving these errors, should have figured, with the publish rates, it was bound to lose some thing. When connected to the network with Ethernet, I did not receive 1 warning. Should have done more testing before posting this question up. Appreciate anyone who took time to read this.pwongTue, 14 Jan 2014 10:30:31 -0600 do I publish exactly one message? everyone, I have been working with ROS for sometime now, and quite happily. However, there is one sticky issue that I would like to resolve. I learnt the basics of publishing from the tutorial "Writing a simple publisher and subscriber". This is the gist of what is demonstrated: ros::Publisher chatter_pub = n.advertise<std_msgs::String>("chatter", 1000); ros::Rate loop_rate(10); int count = 0; while (ros::ok()) { std_msgs::String msg; std::stringstream ss; ss << "hello world " << count; = ss.str(); chatter_pub.publish(msg); ros::spinOnce(); loop_rate.sleep(); ++count; } I have been using the same format for publishing ever since. Obviously, this will keep publishing as long as the program terminates or roscore terminates. I would like to publish a single message, irrespective of message size. In this case, I would like publish one std_msgs::String message. How do I do that? <EDIT> (Nov 14, 2012) Upon reading comments from Benoit Larochelle and Lorenz, I would like to make my question more specific. In my case, latched topics does not apply to the current application logic. I would like all current subscribers to get the message but not future subscribers. Also, the subscribers are external packages that listen to standard non-stamped messages. In addition, I cannot use actionlib since the subscribers do not use it as well. One example is to send a twist command (that does not have a timestamp) to a swarm of robots simultaneously. We ofcourse dont want future subscribers to react to an old command (latched) and we do not want to send the command at a specific rate, but only send it once. </EDIT> I have tried simple removing the while loop and executing "publish" and "spinOnce()" just one time. This doesn't work, no messages are published. Can anyone tell me how I can publish a single message? Thanks Shanker Keshavdas DFKI, Saarbruecken, Germany ShankerMon, 12 Sep 2011 20:41:35 -0500 dependent cmake flags all, I have a project with multiple compilation units, compiled with the usual ROS CMakeLists.txt file. For one of my compilation units, I want to use a header file from an older version of a library that I am already using in the other units. To do this, I wanted to alter the compile flags in the "${pkg_name}_INCLUDE_DIRS"[1] cmake variable within the CMakeLists.txt script, for *one specific target only*. However it seems that *every* target gets compiled with the last value that the ${pkg_name}_INCLUDE_DIRS variable is set to within this script. Is there a way to alter this variable for just one target? Thanks in Advance [1], 07 Nov 2012 04:32:46 -0600