2020-01-20 16:27:45 -0500 | received badge | ● Good Question
(source)
|
2018-10-05 06:30:35 -0500 | received badge | ● Famous Question
(source)
|
2018-08-08 01:34:10 -0500 | marked best answer | TF behaviour showing delay when using ros::Time::now() vs. ros::Time(0) My situation is that I have /tf topic publishing the following frame transforms: My goal is to create a simple C++ program which extracts the transform A to D at the current time (i.e. ros::Time::now() ). I call E the extracted target frame, and ideally E should coincide with D at each 10 Hz update of the while loop that I am using to listen in on the /tf topic. Here is the C++ code: #include <ros/ros.h>
#include <tf/transform_listener.h>
#include <tf/transform_broadcaster.h>
int main(int argc, char** argv)
{
ros::init(argc, argv, "tf_measurement_jumping_debug");
ros::NodeHandle nh;
tf::TransformListener tf_listener;
tf::TransformBroadcaster tf_broadcaster;
tf::StampedTransform transform;
ros::Rate loop_rate(10);
while (ros::ok())
{
loop_rate.sleep();
try
{
// Get the current transform from A to D
ros::Time tf_time = ros::Time::now();
tf_listener.waitForTransform("A", "D", tf_time, ros::Duration(3.0));
tf_listener.lookupTransform("A", "D", tf_time, transform);
// Publish back what I got
transform.child_frame_id_ = "E"; // Rename to not overwrite D
tf_broadcaster.sendTransform(transform);
}
catch (tf::TransformException ex)
{
ROS_ERROR_STREAM(ex.what());
}
}
}
The result is not satisfactory as shown in the following screen recording: There is some kind fo delay in the transform from frame A to E. The reason I think that this is a delay issue is because if I move frame B slowly enough, then E more or less coincides with D (note that the transform B to C is rigid). In the above code, if instead of ros::Time tf_time = ros::Time::now(); I use ros::Time tf_time = ros::Time(0); then the result is what I want: My question is what is the cause of this? Ideally, I want a solution using ros::Time::now() because - What I am looking for is the current transform, not the latest transform;
- When transforms stop arriving (e.g. because transform C to D is no longer being published) then the
ros::Time(0) "hack" will keep sending the last transform prior to this event and I do not want that. Thank you very much for your help. I have looked at the /tf tutorials and saw the timestamp debugging section - however unfortunately none of it has so far helped me to resolve this problem. Update (tf_monitor output) Here's the output of rosrun tf tf_monitor : RESULTS: for all Frames
Frames:
Frame: B published by unknown_publisher Average Delay: 0.000125737 Max Delay: 0.0130457
Frame: C published by unknown_publisher Average Delay: 0.00024707 Max Delay: 0.0130457
Frame: D published by unknown_publisher Average Delay: 0.24257 Max Delay: 0.282611
All Broadcasters:
Node: unknown_publisher 196.535 Hz, Average Delay: 0.00547737 Max Delay: 0.276091
And here is the output of rosrun tf tf_monitor A D : RESULTS: for A to D
Chain is: A -> B -> C -> D
Net delay avg = 0.864727: max = 3.39458
Frames:
Frame: B published by unknown_publisher Average Delay: -2.90574e-05 Max Delay: 0.0139616
Frame: C published by unknown_publisher Average Delay: 0.000132843 ... (more) |
2018-04-05 10:34:18 -0500 | received badge | ● Nice Question
(source)
|
2017-10-31 03:57:42 -0500 | received badge | ● Famous Question
(source)
|
2017-10-31 03:57:42 -0500 | received badge | ● Notable Question
(source)
|
2017-06-13 12:58:37 -0500 | received badge | ● Notable Question
(source)
|
2017-06-13 12:58:37 -0500 | received badge | ● Popular Question
(source)
|
2017-05-24 09:21:30 -0500 | received badge | ● Popular Question
(source)
|
2017-05-24 04:17:00 -0500 | commented answer | TF behaviour showing delay when using ros::Time::now() vs. ros::Time(0) I added an update to my original post with the output of tf_monitor. Indeed, I want to update E when even one of the tra |
2017-05-24 04:16:51 -0500 | commented answer | TF behaviour showing delay when using ros::Time::now() vs. ros::Time(0) I added an update to my original post with the output of tf_monitor. Indeed, I want to update E when even one of the tra |
2017-05-24 04:16:29 -0500 | commented answer | TF behaviour showing delay when using ros::Time::now() vs. ros::Time(0) I added an update to my original post with the output of tf_monitor. Indeed, I want to update E when even one of the tra |
2017-05-24 04:14:43 -0500 | edited question | TF behaviour showing delay when using ros::Time::now() vs. ros::Time(0) TF behaviour showing delay when using ros::Time::now() vs. ros::Time(0)
My situation is that I have /tf topic publishing |
2017-05-23 02:26:36 -0500 | asked a question | TF behaviour showing delay when using ros::Time::now() vs. ros::Time(0) TF behaviour showing delay when using ros::Time::now() vs. ros::Time(0)
My situation is that I have /tf topic publishing |
2017-03-24 21:12:49 -0500 | received badge | ● Enthusiast
|
2017-03-19 22:52:25 -0500 | asked a question | Callback when user presses radio button in my rqt plugin? I am writing a C++ rqt plugin which has the following layout: I would like to know how one would implement a callback function which executes when the user clicks one of the radio buttons? I.e. I want: - callback function
startEvent to be executed when the user clicks the "Start experiment" radio button - callback function
stopEvent to be executed when the user clicks the "STOP experiment" radio button What follows below is the current state of my code, if you need that info. Otherwise you can ignore it. Thanks for helping! Project tree: .
├── CMakeLists.txt
├── include
│ └── rqt_example_cpp
│ └── my_plugin.h
├── package.xml
├── plugin.xml
├── setup.py
└── src
└── rqt_example_cpp
├── my_plugin.cpp
└── my_plugin.ui
my_plugin.ui: <?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>MyPluginWidget</class>
<widget class="QWidget" name="MyPluginWidget">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>400</width>
<height>300</height>
</rect>
</property>
<property name="windowTitle">
<string>Form</string>
</property>
<widget class="QRadioButton" name="radioButton">
<property name="geometry">
<rect>
<x>20</x>
<y>10</y>
<width>141</width>
<height>21</height>
</rect>
</property>
<property name="text">
<string>Start experiment</string>
</property>
</widget>
<widget class="QRadioButton" name="radioButton_2">
<property name="geometry">
<rect>
<x>20</x>
<y>40</y>
<width>191</width>
<height>21</height>
</rect>
</property>
<property name="font">
<font>
<weight>75</weight>
<bold>true</bold>
</font>
</property>
<property name="text">
<string>STOP experiment</string>
</property>
</widget>
</widget>
<resources/>
<connections/>
</ui>
my_plugin.h: #ifndef RQT_EXAMPLE_CPP_MY_PLUGIN_H
#define RQT_EXAMPLE_CPP_MY_PLUGIN_H
#include <ros/ros.h>
#include <rqt_gui_cpp/plugin.h>
#include <rqt_example_cpp/ui_my_plugin.h>
#include <QWidget>
namespace rqt_plugin {
class MyPlugin : public rqt_gui_cpp::Plugin {
Q_OBJECT
public:
MyPlugin();
virtual void initPlugin(qt_gui_cpp::PluginContext& context);
virtual void shutdownPlugin();
virtual void saveSettings(qt_gui_cpp::Settings& plugin_settings,
qt_gui_cpp::Settings& instance_settings) const;
virtual void restoreSettings(const qt_gui_cpp::Settings& plugin_settings,
const qt_gui_cpp::Settings& instance_settings);
// Comment in to signal that the plugin has a way to configure it
// bool hasConfiguration() const;
// void triggerConfiguration();
private:
Ui::MyPluginWidget ui_;
QWidget* widget_;
ros::NodeHandle ros_nh_;
ros::Publisher ros_pub_;
};
} // namespace rqt_example_cpp
#endif // RQT_EXAMPLE_CPP_MY_PLUGIN_H
my_plugin.cpp: #include "rqt_example_cpp/my_plugin.h"
#include <pluginlib/class_list_macros.h>
#include <QStringList>
namespace rqt_plugin {
MyPlugin::MyPlugin() : rqt_gui_cpp::Plugin() , widget_(0) {
// Constructor is called first before initPlugin function, needless to say.
// give QObjects reasonable names
setObjectName("MyPlugin");
}
void MyPlugin::initPlugin(qt_gui_cpp::PluginContext& context)
{
// access standalone command line arguments
QStringList argv = context.argv();
// create QWidget
widget_ = new QWidget();
// extend the widget with all attributes and children from UI file
ui_.setupUi(widget_);
// add widget to the user interface
context.addWidget(widget_);
// getNodeHandle().subscribe();
}
void MyPlugin::shutdownPlugin()
{
// unregister all publishers here
}
void MyPlugin::saveSettings(qt_gui_cpp::Settings& plugin_settings,
qt_gui_cpp::Settings& instance_settings) const
{
// instance_settings.setValue(k, v)
}
void MyPlugin::restoreSettings(const qt_gui_cpp::Settings& plugin_settings,
const qt_gui_cpp::Settings& instance_settings)
{
// v = instance_settings.value(k)
}
/*bool hasConfiguration() const
{
return true;
}
void triggerConfiguration()
{
// Usually used to open a dialog to offer the user a set of configuration
}*/
} // namespace rqt_example_cpp
PLUGINLIB_DECLARE_CLASS(rqt_plugin, MyPlugin, rqt_plugin::MyPlugin, rqt_gui_cpp::Plugin)
|
2016-11-14 04:36:45 -0500 | received badge | ● Famous Question
(source)
|
2016-10-30 18:12:17 -0500 | received badge | ● Student
(source)
|
2016-10-30 16:10:44 -0500 | received badge | ● Notable Question
(source)
|
2016-10-30 12:57:37 -0500 | received badge | ● Popular Question
(source)
|
2016-10-30 12:18:07 -0500 | commented answer | Where is the source code of installed packages? Thanks, this worked for me! |
2016-10-30 12:17:51 -0500 | received badge | ● Scholar
(source)
|
2016-10-30 12:17:46 -0500 | received badge | ● Supporter
(source)
|
2016-10-30 07:28:08 -0500 | asked a question | Where is the source code of installed packages? I have installed ROS Kinetic and it sits is the /opt/ros/kinetic/ folder which has the following structure: .
├── bin
├── env.sh
├── etc
├── include
├── lib
├── setup.bash
├── setup.sh
├── _setup_util.py
├── setup.zsh
└── share
Now suppose I want to view the source code which makes rosrun turtlesim turtle_teleop_key possible. It is a node of the turtlesim package, so I navigate to this package using roscd turtlesim . This puts me into the directory /opt/ros/kinetic/share/turtlesim , which has the following files: .
├── cmake
├── images
├── msg
├── package.xml
└── srv
The actual .cpp source files are nowhere to be found! How can I view the source files for a given package? turtlesim is just an example, there are of course other packages whose source I'm interested in looking at. |
2016-10-30 06:17:55 -0500 | received badge | ● Organizer
(source)
|