ROS Resources: Documentation | Support | Discussion Forum | Index | Service Status | Q&A
Ask Your Question

Drumzone's profile - activity

2017-04-10 22:30:11 -0500 received badge  Famous Question (source)
2016-10-17 03:34:06 -0500 received badge  Famous Question (source)
2016-09-07 10:14:57 -0500 received badge  Notable Question (source)
2016-07-20 03:25:12 -0500 received badge  Popular Question (source)
2016-07-19 04:04:13 -0500 asked a question Rosserial + cpp nodes: cannot use data from rosserial

Hi everyone!

I would like to use ultra sonic sensors mounted on a turtlebot to create an obstacle avoidance feature.

Those sensors are connected on an Arduino Uno and I'm using Rosserial_arduino to pass the data to my ros nodes.

My problem is that I can read the data from the sensors, publish them onto a topic (called /Maxbotix_sensor) and print them in the terminal via rostopic echo /Maxbotix_sensor.

But, I have a problem with the subscriber in my ROS node: only one set of data shows up and then nothing else...

Do you have any ideas why that happened?

Thank you for your advices and your help!

EDIT: I tried again this morning by restarting from nothing> I followed again the tutorials about subcribers/publishers and it's now working!

PS: Here are the codes (really really simple) for:

  • Arduino

#include <ros.h>
#include <geometry_msgs/Twist.h>

ros::NodeHandle  nh;

geometry_msgs::Twist msg;
ros::Publisher pub1("Maxbotix_sensor", &msg);

const int anPin1 = 0;
const int anPin2 = 1;
const int anPin3 = 2;
const int anPin4 = 3;
const int anPin5 = 4;
int triggerPin1 = 13;
float distance1, distance2, distance3, distance4, distance5;
float data1, data2, data3, data4, data5;

const int nb_sample_4_average = 1000;

void setup()


void start_sensor(){
void read_sensor(){

  for(int i=0; i<nb_sample_4_average; i++)
    /* Get distance between sensor and object & convert in meters (*0.0254)*/
    distance1 = (analogRead(anPin1)/2)*0.0254;
    distance2 = (analogRead(anPin2)/2)*0.0254;
    distance3 = (analogRead(anPin3)/2)*0.0254;
    distance4 = (analogRead(anPin4)/2)*0.0254;
    distance5 = (analogRead(anPin5)/2)*0.0254;

    /* Filter the values */
    data1 = data1 + distance1;
    data2 = data2 + distance2;
    data3 = data3 + distance3;
    data4 = data4 + distance4;
    data5 = data5 + distance5;

void loop()

  /* Put data into the msg*/
  msg.linear.x = data1/nb_sample_4_average;
  msg.linear.y = data2/nb_sample_4_average;
  msg.linear.z = data3/nb_sample_4_average;
  msg.angular.x = data4/nb_sample_4_average;
  msg.angular.y = data5/nb_sample_4_average;</xmp>
  /* RAZ buffers*/

  /* Publish the msg */
  pub1.publish( &msg );
  • my node .cpp

#include "test_sensor_node.hpp"

using namespace std;
using namespace ros;

int main(int argc, char **argv)
    ros::init(argc, argv, "test_sensor");
    ObsAvoid Obs;
    return 0;

void ObsAvoid::obstacle_avoidance(const geometry_msgs::Twist& msg)
    cout<<"New data"<<endl;

    obstacle[0] = msg.linear.x;
    obstacle[1] = msg.linear.y;
    obstacle[2] = msg.linear.z;
    obstacle[3] = msg.angular.x;
    obstacle[4] = msg.angular.y;

    for(int ii=0;ii=4;ii++)
  • my node .hpp


#include <ros/ros.h>
#include <iostream>
#include <math.h>
#include <string>
#include <stdio.h>
#include <geometry_msgs/Twist.h>

using namespace std;
using namespace ros;

class ObsAvoid
        ros::NodeHandle n;
        ros::Subscriber sub1;       
        float obstacle[5];
            for(int i=0;i=4;i++)
        void obstacle_avoidance(const geometry_msgs::Twist& msg);   

2016-07-11 21:02:21 -0500 commented answer Rotate Kinect frame for turtlebot localization?

Sorry for the late answer... Thank you again for your help!

2016-07-06 00:52:05 -0500 commented answer Rotate Kinect frame for turtlebot localization?

Of course the topics should be the same. I worked on it again and I found a solution: I modified the Kobuki joint state publisher for the wheels and I add the publisher for the Dynamixel motor. So now it's all good! Thank you again for your help and your advices !!

2016-07-05 02:34:16 -0500 received badge  Notable Question (source)
2016-07-05 01:49:50 -0500 commented answer Rotate Kinect frame for turtlebot localization?

by the dynamixel doesn't seem to be used by Rviz. Do you know I could set this up? I'd like to 'force" Rviz to get the message?

Thank you again for your help! (2/2)

2016-07-05 01:46:25 -0500 commented answer Rotate Kinect frame for turtlebot localization?

OK! So now I have an accurate model of my robot but I'm now facing problems with the joint_state_publisher... Same as Pi robot example I created a launch file including the joint_state_publisher but once everything is launched (robot, openni, dynamixel, Rviz), the joint_state published (1/2)

2016-07-04 19:55:56 -0500 received badge  Supporter (source)
2016-07-03 20:31:36 -0500 received badge  Enthusiast
2016-07-01 23:42:35 -0500 received badge  Popular Question (source)
2016-06-29 03:12:36 -0500 commented answer Rotate Kinect frame for turtlebot localization?

Thank you so much for your reply!! I didn't have knowledge about the xacro file. I'll try and let you know how it's going. But about the 3rd point you mentioned, amcl and gmapping are assuming that Kinect is immobile? Is there another method which take kinect orientation into account?

2016-06-28 21:26:49 -0500 asked a question Rotate Kinect frame for turtlebot localization?

Hello !

I'm currently working on SLAM method with turtlebot2. I followed all tutorials about mapping and localization and everything works well.

But I'd like to add some more features: my kinect is actually not directly fixed to the turtlebot but it's mounted on a Dynamixel Motor to allow a rotation on the Z axis.

So my problem is that the localization is well working when the kinect frame is aligned with the turtlebot frame (the Kinect orientation on the vertical axis is the same as the turtlebot's one) but as soon as the orientations are not the same, I have a problem in the localization. This is pretty normal but I'd like to allow the Kinect to rotate and still have a good localization.

In theory, I "just" have to apply a rotation matrix between the Kinect frame and the turtlebot frame depending on the Dynamixel angle but I have honestly no idea how to apply this transformation...

I had a look on tf tutorials and I did the tutorials tf tutorials but I'm quite locked here.

So my questions are:

  1. How can I apply the theoretical rotation matrix between Kinect frame and Turtlebot frame?

  2. Where should I implement the rotation transformation between the frames (because there are not a lot of files in turtlebot_navigation folder)?

  3. Is it possible to update the angle for the rotation transformation as often as the motor angle changes?

Let me know if wasn't clear in my explanations.

Thank you for your answers and your advices!