ROS Resources: Documentation | Support | Discussion Forum | Index | Service Status | ros @ Robotics Stack Exchange
Ask Your Question

satk's profile - activity

2015-04-15 00:24:40 -0500 received badge  Famous Question (source)
2015-03-02 18:07:18 -0500 received badge  Notable Question (source)
2015-02-23 17:02:30 -0500 received badge  Famous Question (source)
2015-02-03 15:50:06 -0500 received badge  Famous Question (source)
2014-12-29 20:46:52 -0500 received badge  Popular Question (source)
2014-12-18 10:52:36 -0500 asked a question ROS HYDRO : Two Turtlebot Create in Gazebo with separate odom published topics

Hi,

I am trying to simulate two turtlebot creates in the gazebo environment. With my current launch files I get the correct robot position and orientation on the topic gazebo/model_states. I would like to publish the Robot1 and Robot2 odometry data on the topic Robot1/odom and Robot2/odom. It should have been working with my current script as I launch the turtlebot group nodes under two different namespaces.

Here is the main launch file sim.launch

<launch>


  <include file="$(find gazebo_ros)/launch/empty_world.launch">
    <arg name="use_sim_time" value="true"/>
    <arg name="debug" value="false"/>
    <arg name="world_name" value="$(find turtlebot_gazebo)/worlds/empty.world"/>
  </include>

  <!-- No namespace here as we will share this description. Access with slash at the beginning -->
  <param name="robot_description"
    command="$(find xacro)/xacro.py $(find turtlebot_description)/urdf/turtlebot_gazebo.urdf.xacro" />


  <!-- BEGIN ROBOT 1-->
  <group ns="robot1">
    <param name="tf_prefix" value="robot1_tf" />
    <include file="$(find turtlebot_gaze)/launch/one_robot.launch" >
      <arg name="init_pose" value="-x 1 -y 1 -z 0" />
      <arg name="robot_name"  value="Robot1" />
    </include>
  </group>

  <!-- BEGIN ROBOT 2-->
  <group ns="robot2">
    <param name="tf_prefix" value="robot2_tf" />
    <include file="$(find turtlebot_gaze)/launch/one_robot.launch" >
      <arg name="init_pose" value="-x -1 -y 1 -z 0" />
      <arg name="robot_name"  value="Robot2" />
    </include>
  </group>
</launch>

This launch file called one_robot.launch file which is below:

<launch>
  <arg name="robot_name"/>
  <arg name="init_pose"/>


  <!-- The odometry estimator, throttling, fake laser etc. go here -->
  <!-- All the stuff as from usual robot launch file -->

  <arg name="base"      value="$(optenv TURTLEBOT_BASE create)"/> <!-- create, roomba -->
  <arg name="battery"   value="$(optenv TURTLEBOT_BATTERY /proc/acpi/battery/BAT0)"/>  <!-- /proc/acpi/battery/BAT0 --> 
  <arg name="stacks"    value="$(optenv TURTLEBOT_STACKS circles)"/>  <!-- circles, hexagons --> 
  <arg name="3d_sensor" value="$(optenv TURTLEBOT_3D_SENSOR asus_xtion_pro)"/>  <!-- kinect, asus_xtion_pro --> 

  <include file="$(find turtlebot_gaze)/launch/create_modified.launch.xml">
    <arg name="base" value="$(arg base)"/>
    <arg name="stacks" value="$(arg stacks)"/>
    <arg name="3d_sensor" value="$(arg 3d_sensor)"/>
    <arg name="init_pose" value="$(arg init_pose)"/>
    <arg name="robot_name" value="$(arg robot_name)"/>
  </include>


  <node pkg="robot_state_publisher" type="robot_state_publisher" name="robot_state_publisher">
    <param name="publish_frequency" type="double" value="30.0"/>
    <remap from="gazebo/model_states" to="/rrbot/gazebo/model_states" />
  </node>

  <!-- Fake laser -->
  <node pkg="nodelet" type="nodelet" name="laserscan_nodelet_manager" args="manager"/>
  <node pkg="nodelet" type="nodelet" name="depthimage_to_laserscan"
        args="load depthimage_to_laserscan/DepthImageToLaserScanNodelet laserscan_nodelet_manager">
    <param name="scan_height" value="10"/>
    <param name="output_frame_id" value="/camera_depth_frame"/>
    <param name="range_min" value="0.45"/>
    <remap from="image" to="/camera/depth/image_raw"/>
    <remap from="scan" to="/scan"/>
  </node>

</launch>

The above launch file calls the create_modified.urdf.xml file which is pasted below:

<launch>
  <arg name="base"/>
  <arg name="stacks"/>
  <arg name="3d_sensor"/>
  <arg name="init_pose"/>
  <arg name="robot_name"/>

  <arg name="urdf_file" default="$(find xacro)/xacro.py '$(find turtlebot_description)/robots/$(arg base)_$(arg stacks)_$(arg 3d_sensor).urdf.xacro'" />
  <param name="robot_description" command="$(arg urdf_file)" />

  <!-- Gazebo model spawner -->
  <node name="spawn_turtlebot_model" pkg="gazebo_ros" type="spawn_model"
        args="$(arg init_pose) -unpause -urdf -param robot_description -model $(arg robot_name)"/>

  <!-- Odometry estimator -->
  <node pkg="robot_pose_ekf" type="robot_pose_ekf" name="robot_pose_ekf">
    <remap from="imu_data" to="turtlebot_node/imu/data"/>
    <remap from="robot_pose_ekf/odom" to="odom_combined"/>
    <param name="freq ...
(more)
2014-12-09 10:37:40 -0500 commented answer Turtlebot Gazebo tutorial can't find diagnostics.yaml

Hi Sudeep, It would be great if you could please share the turtlebot robot.launch for hydro here ? I am still having problems with mine.

2014-12-03 10:40:28 -0500 commented answer Ros Node Hang up

Ok, I will look into the code. Thank you all.

2014-12-03 10:09:08 -0500 commented answer Ros Node Hang up

Hi, I have corrected the discrepancy on the blog. In my actual program the two names are the same. I was just trying to make it more understandable for this blog.

2014-12-03 10:07:52 -0500 received badge  Enthusiast
2014-12-02 19:08:00 -0500 received badge  Notable Question (source)
2014-12-02 15:55:40 -0500 answered a question Ros Node Hang up

I solved the problem by using the mutex lock feature to get the node from getting stuck.

The code that worked for me is below:

#include "ros/ros.h"
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <tf/transform_broadcaster.h>
#include <message_filters/subscriber.h>
#include <message_filters/time_synchronizer.h>
#include <message_filters/synchronizer.h>
#include <message_filters/sync_policies/approximate_time.h>
#include <boost/thread.hpp>

static boost::mutex mutex;
    void Callback(const coop_est::FeatureBArray::ConstPtr& msg, const nav_msgs::Odometry::ConstPtr& odo) /
    {

       DO A NUMBER OF MATRIX OPERATIONS ON THE GLOBAL MATRICES Q, P, Xf

    }


    int main(int argc, char** argv)
    {

      ros::init(argc, argv, "coop_node");

      ros::NodeHandle n;

      mutex.lock();   

      message_filters::Subscriber<coop_est::FeatureBArray> fea_sub(n, "Feature", 1);
      message_filters::Subscriber<nav_msgs::Odometry> odo_sub(n, "odom", 1);
      typedef sync_policies::ApproximateTime<coop_est::FeatureBArray, nav_msgs::Odometry> MySyncPolicy;
      Synchronizer<MySyncPolicy> sync(MySyncPolicy(1), fea_sub, odo_sub);
      sync.registerCallback(boost::bind(&Callback, _1, _2));

      mutex.unlock();
      ros::spin();

      return 0;

    }
2014-11-25 11:27:52 -0500 received badge  Popular Question (source)
2014-11-25 10:25:30 -0500 answered a question Ros Node Hang up

After making the callback function much simpler, I found that the callback function got stuck at the same line repeatedly. I have a for loop inside the callback function and when I change the number of iterations on the for loop, the place where the node gets stuck changes. If the number of iterations are very low then the node does not get stuck.

void FeaturesReceived(const coop_est::FeatureBArray::ConstPtr& msg, const nav_msgs::Odometry::ConstPtr& odo) /
{

for (int i = 0; i< n; i++)
{
   DO A NUMBER OF MATRIX OPERATIONS ON THE GLOBAL MATRICES Q, P, Xf
}
}

My thoughts are that as I am operating on the global Eigen2 type matrix inside the callback, when a second callback is created before the execution of the first one is complete, the program hangs as two callback instances are trying to modify the same memory location.

How can I sequentially execute the callback in ROS and wait until the previous callback has fnished executing ?

Thank you!

2014-11-25 10:20:03 -0500 commented answer Ros Node Hang up

Thank you for your reply ahendrix. I am able to stop the node using ctrl-\ My problem is still not solved. I need a way for ROS to not callback a function again until the previous callback has returned. I am updating the original question with the new findings.

2014-11-25 01:09:16 -0500 received badge  Notable Question (source)
2014-11-24 15:41:21 -0500 received badge  Organizer (source)
2014-11-24 15:40:28 -0500 asked a question Ros Node Hang up

Hi,

I am writing a subscriber node with a long callback function. The node calls the callback function once or twice and then hangs up sometimes inside the callback function or sometimes outside the callback function. I have been able to detect where it hangs by publishing ROS_INFO messages at various points in the code.

Inside the callback function, I modify global variables (matrix). Could that be the reason for the node getting stuck during runtime ?

Any other guesses for why a node will hang such that I cant even ctrl+c and stop it ?

Here is the code:

#include "ros/ros.h"
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <Eigen/Dense>
#include <Eigen/LU>
#include "std_msgs/String.h"
#include <std_msgs/Float32.h>
#include <std_msgs/Int32.h>
#include <tf/transform_broadcaster.h>
#include <nav_msgs/Odometry.h>
#include <coop_est/FeatureB.h>
#include <coop_est/FeatureBArray.h>
#include <nav_msgs/Odometry.h>
#include <tf/transform_datatypes.h>
#include "/opt/ros/hydro/include/tf/LinearMath/Matrix3x3.h"
#include "/opt/ros/hydro/include/tf/LinearMath/Transform.h"
#include "tf/tf.h"
#include <message_filters/subscriber.h>
#include <message_filters/time_synchronizer.h>
#include <message_filters/synchronizer.h>
#include <message_filters/sync_policies/approximate_time.h>
#include <sensor_msgs/Image.h>
#include <sensor_msgs/CameraInfo.h>

using namespace Eigen;
using namespace message_filters;
using namespace sensor_msgs;

// Filter Initialization

VectorXf X(3); // Define Starting position and orientation as the inertial frame
MatrixXf Q(3,3);
MatrixXf P(3,3);

void FeaturesReceived(const coop_est::FeatureBArray::ConstPtr& msg, const nav_msgs::Odometry::ConstPtr& odo) /
{

   DO A NUMBER OF MATRIX OPERATIONS ON THE GLOBAL MATRICES Q, P, Xf

}


int main(int argc, char** argv)
{

  ros::init(argc, argv, "coop_node");

  ros::NodeHandle n;

  int should_continue = 1;
  ros::Rate r(5); // 10 hz


  message_filters::Subscriber<coop_est::FeatureBArray> fea_sub(n, "Feature", 1);
  message_filters::Subscriber<nav_msgs::Odometry> odo_sub(n, "odom", 1);
  typedef sync_policies::ApproximateTime<coop_est::FeatureBArray, nav_msgs::Odometry> MySyncPolicy;
  Synchronizer<MySyncPolicy> sync(MySyncPolicy(1), fea_sub, odo_sub);
  sync.registerCallback(boost::bind(&FeaturesReceived, _1, _2));

  ros::spin();

  return 0;

}

------ UPDATE------

After making the callback function much simpler, I found that the callback function got stuck at the same line repeatedly. I have a for loop inside the callback function and when I change the number of iterations on the for loop, the place where the node gets stuck changes. If the number of iterations are very low then the node does not get stuck.

void FeaturesReceived(const coop_est::FeatureBArray::ConstPtr& msg, const nav_msgs::Odometry::ConstPtr& odo) /
{

for (int i = 0; i< n; i++)
{
   DO A NUMBER OF MATRIX OPERATIONS ON THE GLOBAL MATRICES Q, P, Xf
}
}

My thoughts are that as I am operating on the global Eigen2 type matrix inside the callback, when a second callback is created before the execution of the first one is complete, the program hangs as two callback instances are trying to modify the same memory location.

How can I sequentially execute the callback in ROS and wait until the previous callback has fnished executing ?

Thank you for your help !

2014-11-24 15:32:32 -0500 received badge  Scholar (source)
2014-11-20 15:59:43 -0500 commented answer Time Synchronizer (message_filters) with Custom Message type

Adding Header header in my .msg file fixed the problem. Thanks! Also I filled the header.stamp by writing this command msg.header.stamp = ros::Time::now(); before publishing to the custom message.

2014-11-20 11:00:25 -0500 received badge  Popular Question (source)
2014-11-20 10:18:06 -0500 commented question Time Synchronizer (message_filters) with Custom Message type

Thank you for your reply kmhallen. I have edited the original question to include the error message.

2014-11-19 17:27:43 -0500 asked a question Time Synchronizer (message_filters) with Custom Message type

Hi,

I want to have one callback function for subscription of two topics. I read online here that I can use the message_filters library to time synchronize the topics.

In my ROS node when I use the Image and Camera_info topic as suggested in the example code below, I get no errors.

  message_filters::Subscriber<Image> image_sub(n, "image", 1);
  message_filters::Subscriber<CameraInfo> info_sub(n, "camera_info", 1);
  TimeSynchronizer<Image, CameraInfo> sync(image_sub, info_sub, 10);
  sync.registerCallback(boost::bind(&callback, _1, _2));

But when I replace the Image and CameraInfo message formats with custom messages, as shown below, I get a lot of errors. I am attaching the

  message_filters::Subscriber<coop_est::FeatureBArray> fea_sub(n, "Feature", 1);
  message_filters::Subscriber<nav_msgs::Odometry> odo_sub(n, "odom", 1);
  message_filters::TimeSynchronizer<coop_est::FeatureBArray, nav_msgs::Odometry> sync(fea_sub, odo_sub, 10);
  sync.registerCallback(boost::bind(&FeaturesReceived, _1, _2));

Is message_filters time synchronizer only applicable to certain message formats ?

The error message I get it very long. I am pasting it here:

In file included from /opt/ros/hydro/include/message_filters/time_synchronizer.h:39:0,
                 from /home/quadrotor/catkin_ws/src/coop_est/src/coop_node.cpp:15:
/opt/ros/hydro/include/message_filters/sync_policies/exact_time.h: In member function ‘void message_filters::sync_policies::ExactTime<M0, M1, M2, M3, M4, M5, M6, M7, M8>::add(const typename boost::mpl::at_c<typename message_filters::PolicyBase<M0, M1, M2, M3, M4, M5, M6, M7, M8>::Events, i>::type&) [with int i = 0, M0 = coop_est::FeatureBArray_<std::allocator<void> >, M1 = nav_msgs::Odometry_<std::allocator<void> >, M2 = message_filters::NullType, M3 = message_filters::NullType, M4 = message_filters::NullType, M5 = message_filters::NullType, M6 = message_filters::NullType, M7 = message_filters::NullType, M8 = message_filters::NullType, typename boost::mpl::at_c<typename message_filters::PolicyBase<M0, M1, M2, M3, M4, M5, M6, M7, M8>::Events, i>::type = ros::MessageEvent<const coop_est::FeatureBArray_<std::allocator<void> > >]’:
/opt/ros/hydro/include/message_filters/synchronizer.h:358:5:   instantiated from ‘void message_filters::Synchronizer<Policy>::cb(const typename boost::mpl::at_c<typename Policy::Events, i>::type&) [with int i = 0, Policy = message_filters::sync_policies::ExactTime<coop_est::FeatureBArray_<std::allocator<void> >, nav_msgs::Odometry_<std::allocator<void> >, message_filters::NullType, message_filters::NullType, message_filters::NullType, message_filters::NullType, message_filters::NullType, message_filters::NullType, message_filters::NullType>, typename boost::mpl::at_c<typename Policy::Events, i>::type = ros::MessageEvent<const coop_est::FeatureBArray_<std::allocator<void> > >]’
/opt/ros/hydro/include/message_filters/synchronizer.h:290:5:   instantiated from ‘void message_filters::Synchronizer<Policy>::connectInput(F0&, F1&, F2&, F3&, F4&, F5&, F6&, F7&, F8&) [with F0 = message_filters::Subscriber<coop_est::FeatureBArray_<std::allocator<void> > >, F1 = message_filters::Subscriber<nav_msgs::Odometry_<std::allocator<void> > >, F2 = message_filters::NullFilter<message_filters::NullType>, F3 = message_filters::NullFilter<message_filters::NullType>, F4 = message_filters::NullFilter<message_filters::NullType>, F5 = message_filters::NullFilter<message_filters::NullType>, F6 = message_filters::NullFilter<message_filters::NullType>, F7 = message_filters::NullFilter<message_filters::NullType>, F8 = message_filters::NullFilter<message_filters::NullType>, Policy = message_filters::sync_policies::ExactTime<coop_est::FeatureBArray_<std::allocator<void> >, nav_msgs::Odometry_<std::allocator<void> >, message_filters::NullType, message_filters::NullType, message_filters::NullType, message_filters::NullType, message_filters::NullType, message_filters::NullType, message_filters::NullType>]’
/opt/ros/hydro/include/message_filters/synchronizer.h:282:5:   instantiated from ‘void message_filters::Synchronizer<Policy>::connectInput(F0&, F1&, F2&, F3&, F4&, F5&, F6&, F7&) [with F0 ...
(more)
2014-01-27 21:46:34 -0500 received badge  Famous Question (source)
2013-08-21 04:00:25 -0500 received badge  Notable Question (source)
2013-06-19 08:13:36 -0500 received badge  Popular Question (source)
2013-06-19 05:13:33 -0500 commented answer Workstation as Master [Turtlebot]

Thank you for your reply. I do not get these errors when turtlebot is the master. So, I don't think that the robot is not charged or the connection is loose.

2013-06-18 11:11:21 -0500 received badge  Editor (source)
2013-06-18 11:10:39 -0500 asked a question Workstation as Master [Turtlebot]

Hi, I am trying to run the workstation as master with one turtlebot. After booting up the turtlebot as a non master I launch the turtlebot node by running minimal.launch. The node launches fine but I get the attached errors on the turtlebot commandline. Inspite of these errors, the turtlebot runs fine but when I subscribe to the odometry data on the workstation I noticed that the odometry gets lost for long periods of time. The "rostopic hz /odom" shows "no new messages" on the workstation and there is an error ("device reports readiness to read but returned no data (device disconnected?)") displayed on the turtlebot commandline.

Here is the error I get on the turtlebot commandline:

[ERROR] [WallTime: 1371589364.129064] Failed to contact device with error: [device reports readiness to read but returned no data (device disconnected?)]. Please check that the Create is powered on and that the connector is plugged into the Create.

[ERROR] [WallTime: 1371589370.596000] Failed to contact device with error: [device reports readiness to read but returned no data (device disconnected?)]. Please check that the Create is powered on and that the connector is plugged into the Create.

[ERROR] [WallTime: 1371589377.007524] Failed to contact device with error: [device reports readiness to read but returned no data (device disconnected?)]. Please check that the Create is powered on and that the connector is plugged into the Create.

[ERROR] [WallTime: 1371589383.468197] Failed to contact device with error: [[Errno 11] Resource temporarily unavailable]. Please check that the Create is powered on and that the connector is plugged into the Create.

Thank you,