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

Bernardo's profile - activity

2013-12-04 04:22:14 -0500 received badge  Famous Question (source)
2013-05-14 07:43:57 -0500 received badge  Famous Question (source)
2013-05-06 14:49:15 -0500 received badge  Famous Question (source)
2013-04-29 23:54:12 -0500 received badge  Famous Question (source)
2013-04-05 07:07:11 -0500 received badge  Notable Question (source)
2013-04-05 04:14:31 -0500 received badge  Popular Question (source)
2013-04-04 12:12:10 -0500 asked a question Velocities Turtlebot cmd_vel

Hi, I have a doubt concerning the velocities, especially the angular one. If I want to make Turtlebot spin 90 degrees for a second, for example, what angular vel. should I set? Would it change something if I also set the linear one?

I have this code:

ros::Rate loop_rate(1); //Frecuencia de realización del bucle (10 Hz)

    while (ros::ok())   //Bucle mientras no se reciba "Ctrl+C"
    {
          vel.linear.x = 0;   //velocidad de avance
          vel.angular.z = 1.57;   //velocidad de giro

          vel_pub_.publish(vel);

          loop_rate.sleep();
    }

I guess that with this code, each message arrives each second. How should I modify this code to make the robot spin 90 degrees in one second?

2013-04-03 07:50:46 -0500 received badge  Notable Question (source)
2013-03-28 08:22:07 -0500 received badge  Popular Question (source)
2013-03-27 07:27:54 -0500 asked a question Help- implement a fuzzy logic controller in ROS for avoiding Obstacles

Hello. I need help. I'm trying to implement a fuzzy controller for avoiding obstacles. I could integrate it in ROS and I want to do it with the Turtlebot. As input, I've got the distance and angle position, and as output, the fuzzy controller tells me the linear and angular velocities.

As the Turtlebot I'm working with uses a Kinect, I suppose that it gives me distance measures from a minimum angle to a maximum angle. What I do is to check the minimum distance and obstacle positions point-per-point, and according to what I read in some forums, Turtlebot's Kinect only works properly within -28 to 28 degrees. Thus, the loop should be within that range.

My problem is the following. When the robot is near an obstacle, it spins to a side, but suddenly it spins to the other side successively (like if the robot was saying "no" with its body). I think there's some other way to do it, but I need your advice. Here's the code:

/*
 * Stand-alone codes for fuzzy inference systems.
 * J.-S. Roger Jang, 1994.
 * Copyright 1994-2002 The MathWorks, Inc.
 * $Revision: 1.12 $  $Date: 2002/06/17 12:47:24 $
 */


#define DEBUG 1
/* Start of the regular fismain.c */

#include "fis.h" //Libreria Controlador Difuso.
#include "ros/ros.h" //Libreria Estandar ROS.
#include <stdio.h>   //Libreria Estandar c++ 
#include <stdarg.h> // Libreria Estandar c++
#include <sensor_msgs/LaserScan.h> //Libreria "LaserScan del package "sensor_msgs" 
#include <geometry_msgs/Twist.h>  //Librería "Twist" del package "geometry_msgs"

/* Main routine 
 **********************************************************************/
/*
    Variables globales del programa. Se utilizan variables globales para
    hacer posible y eficiente el uso del controlador difuso sin tener que
    cargarlo en cada nueva evaluación del mismo.
*/
        FIS *fis;
    DOUBLE **dataMatrix, **fisMatrix, **outputMatrix;
    int fis_row_n, fis_col_n;






/***********************************************************************
                Procedimiento para inicialización
 **********************************************************************/
int inicializaSistemaDifuso(char *fis_file)
{
    /* obtain data matrix and FIS matrix */
    fisMatrix = returnFismatrix(fis_file, &fis_row_n, &fis_col_n);
        /* build FIS data structure */
    fis = (FIS *)fisCalloc(1, sizeof(FIS));
    fisBuildFisNode(fis, fisMatrix, fis_col_n, MF_POINT_N);
    dataMatrix = (DOUBLE **)fisCreateMatrix(10, 10, sizeof(DOUBLE));
        outputMatrix = (DOUBLE **)fisCreateMatrix(10, 10, sizeof(DOUBLE));
   return 1; 
}

/***********************************************************************
                Procedimiento para finalización
 **********************************************************************/
int finalizaSistemaDifuso(void)
{
    /* clean up memory */
    fisFreeFisNode(fis);
    fisFreeMatrix((void **)fisMatrix, fis_row_n);
    fisFreeMatrix((void**)dataMatrix,10);
    fisFreeMatrix((void**)outputMatrix,10);
    return 1;
}

int presentarInformacion(FIS *fis)
{
    fisPrintData(fis);
    return 1;
}

/***********************************************************************
                Procedimiento para usar el controlador
 **********************************************************************/
int evaluarFisOnLine(FIS *fis, DOUBLE **dataMatrix, DOUBLE **outputMatrix )
{
    getFisOutput(dataMatrix[0], fis, outputMatrix[0]);
    return 1; 
}

/*************************************************************************
     Procedimiento para realizar las lecturas sensoriales del Robot
**************************************************************************/
void scanCallback (const sensor_msgs::LaserScan::ConstPtr& scan_msg)
 {

    for (unsigned int i=0;i< scan_msg->ranges.size();i++){   
                   if (scan_msg->ranges[i]<dataMatrix[0][0]){
    /*Distancia-->*/   dataMatrix[0][0]=scan_msg->ranges[i];  
    /*Angulo-->*/      dataMatrix[0][1] = ((double)i*scan_msg->angle_increment)+scan_msg->angle_min;
              //      std::cout << dataMatrix[0][0] <<" ------ "<< dataMatrix[0][1] << std::endl;          



                      }                
     }

}

int main(int argc, char **argv)
{  
  ros::init(argc, argv, "fuzzyros");   //Creación del nodo "fuzzyros"
  int ret;
  dataMatrix[0][0]=10;
  ret=inicializaSistemaDifuso("AvoidObstacleFuzzy.fis");
    if ( ret != 1 ){
        printf("Ha ocurrido un error al inicializar el sistema difuso. No se puede continuar");
       printf("\n\nPulse una ...
(more)
2013-03-11 20:59:12 -0500 received badge  Notable Question (source)
2013-03-11 16:52:29 -0500 received badge  Popular Question (source)
2013-03-11 12:42:13 -0500 asked a question Help It doesn't compile my program.

Hi ,I have a problem when I try compiling my program I have the files fismain.cpp , fis.h and fis.c and when I compiled without ROS I havent a problem but when I try to integrate in ROS I cant compiling,There is not defined as certain functions are in the file fis. c.

  • I've added in CMakelist.txt:

add_library(fis /home/magno/proyecto/fis.c)

rosbuild_add_executable(fismain src/fismain.cpp) target_link_libraries(fismain fis)

The error is:

Linking CXX executable ../bin/fismain
CMakeFiles/fismain.dir/src/fismain.o: In function `inicializaSistemaDifuso(char*)':
/home/magno/proyecto/prueba5/src/fismain.cpp:40: undefined reference to `returnFismatrix'
/home/magno/proyecto/prueba5/src/fismain.cpp:43: undefined reference to `fisBuildFisNode'
CMakeFiles/fismain.dir/src/fismain.o: In function `finalizaSistemaDifuso()':
/home/magno/proyecto/prueba5/src/fismain.cpp:56: undefined reference to `fisFreeMatrix'
/home/magno/proyecto/prueba5/src/fismain.cpp:57: undefined reference to `fisFreeMatrix'
/home/magno/proyecto/prueba5/src/fismain.cpp:58: undefined reference to `fisFreeMatrix'
CMakeFiles/fismain.dir/src/fismain.o: In function `presentarInformacion':
/home/magno/proyecto/prueba5/src/fismain.cpp:64: undefined reference to `fisPrintData'
CMakeFiles/fismain.dir/src/fismain.o: In function `evaluarFisOnLine':
/home/magno/proyecto/prueba5/src/fismain.cpp:73: undefined reference to `getFisOutput'
CMakeFiles/fismain.dir/src/fismain.o: In function `presentarInformacion':
/home/magno/proyecto/prueba5/src/fismain.cpp:64: undefined reference to `fisPrintData'
CMakeFiles/fismain.dir/src/fismain.o: In function `evaluarFisOnLine':
/home/magno/proyecto/prueba5/src/fismain.cpp:73: undefined reference to `getFisOutput'
collect2: ld devolvió el estado de salida 1
make[3]: *** [../bin/fismain] Error 1
make[3]: se sale del directorio «/home/magno/proyecto/prueba5/build»
make[2]: *** [CMakeFiles/fismain.dir/all] Error 2
make[2]: se sale del directorio «/home/magno/proyecto/prueba5/build»
make[1]: *** [all] Error 2
make[1]: se sale del directorio «/home/magno/proyecto/prueba5/build»
make: *** [all] Error 2

sorry for my english.

2013-03-11 03:38:41 -0500 received badge  Popular Question (source)
2013-03-10 22:38:19 -0500 received badge  Notable Question (source)
2013-03-09 16:45:18 -0500 received badge  Popular Question (source)
2013-03-09 09:37:28 -0500 received badge  Nice Question (source)
2013-03-09 06:01:24 -0500 received badge  Student (source)
2013-03-09 05:35:26 -0500 asked a question How to make use of some libraries in ROS

To be able to use this in ROS I'd need to make use of these files:

include "fis.h" include "fis.c"

How could I do it? I think I have to make some modifications in CMakeList.txt but I don't know how to.

The directory for the files is /home/magno/proyecto/prueba5/src

Cheers and thank you

2013-03-09 04:54:49 -0500 asked a question How to make use of some libraries to implement a fuzzy controller in ROS

Hello. I need to implement a fuzzy controller in ROS, using MatLab Fuzzy Toolbox, and I have the necessary files:

fis.h : contains structure and function declarations fis.c : contains function definitions, it's in C fismain.cpp : I want to make use of the inference engine here and modify it

To be able to use this in ROS I'd need to make use of these files:

include "fis.h" include "fis.c"

How could I do it? I think I have to make some modifications in CMakeList.txt but I don't know how to.

The directory for the files is /home/magno/proyecto/prueba5/src

Cheers and thank you

2013-02-04 04:33:39 -0500 received badge  Editor (source)
2013-02-04 04:19:55 -0500 received badge  Famous Question (source)
2013-02-04 04:13:32 -0500 answered a question Help - how to avoid obstacles with Turtlebot's LaserScan.

I got my robot to stop when it reaches a minimum distance,But, as you told me, I want to reduce the velocity with Vel=vel*0.5, but instead the robot always keeps moving at a constant velocity.What can I do? Thank you for your help.

include <ros ros.h="">

include <sensor_msgs laserscan.h="">

include <geometry_msgs twist.h="">

void scanCallback (const sensor_msgs::LaserScan::ConstPtr& scan_msg) { geometry_msgs::Twist vel; //Declaración de la variable global vel

ros::NodeHandle n; ros::Publisher vel_pub_=n.advertise<geometry_msgs::twist>("cmd_vel", 1); ros::Time ahora; double minDist=10;
double angle;
double speed=0.5;

for (unsigned int i=0;i< scan_msg->ranges.size();i++){   

  angle = ((double)i*scan_msg->angle_increment)+scan_msg->angle_min;

   if (scan_msg->ranges[i]< minDist){
       minDist=scan_msg->ranges[i];      
       std::cout << minDist << std::endl;          
   }
 } 

if( minDist<=0.6){

            vel.linear.x = 0.0;//velocidad de avance
            vel.angular.z = 0.0;//velocidad de giro
            vel_pub_.publish(vel);
 }
else {


            speed=0.5*speed;
            vel.linear.x = speed;//velocidad de avance
            vel.angular.z = 0.0;//velocidad de giro
            vel_pub_.publish(vel);
            //std::cout << speed << std::endl;  


}

} int main(int argc, char** argv){ ros::init(argc, argv, "DistanceObstacle"); ros::NodeHandle n; ros::Publisher vel_pub_=n.advertise<geometry_msgs::twist>("cmd_vel", 1); ros::Subscriber scan_sub = n.subscribe("scan", 1, scanCallback);
ros::spin(); //Mantiene la suscripcionn al topic hasta que se reciba "Ctrl+C"

return 0;

2013-02-01 03:45:52 -0500 received badge  Notable Question (source)
2013-02-01 03:21:49 -0500 received badge  Popular Question (source)
2013-02-01 02:49:00 -0500 asked a question Help - how to avoid obstacles with Turtlebot's LaserScan.

Hello,my name is Bernardo,I've got a problem and I don't know how to solve it. I want to create a very simple program: the robot advances in a straight line and as it approaches an obstacle, it must decelerate until it stops. The problem is that while I'm subscribing to the laser, the robot (when I start the run) moves at the speed I told him, but when it reaches the minimum distance, the robot doesn't stop and I don't know how to make him do that. Please, I need help. Here's the code:

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


void scanCallback (const sensor_msgs::LaserScan::ConstPtr& scan_msg)
 {
 geometry_msgs::Twist vel; //Declaración de la variable global vel

 ros::NodeHandle n;
 ros::Publisher vel_pub_=n.advertise<geometry_msgs::Twist>("cmd_vel", 1);
 ros::Rate loop_rate(50);// Frecuencia de realializacion del bucle
 ros::Time ahora; 


    for (unsigned int x=0;x< scan_msg->ranges.size();x++){   


             if(scan_msg->ranges[x]>=0.8) {

                vel.linear.x = 0.3;//velocidad de avance
                vel.angular.z = 0.0;//velocidad de giro
                vel_pub_.publish(vel);

                }


              ahora = ros::Time::now();
              if(scan_msg->ranges[x]<=0.7){   

                 while (ros::Time::now() < (ahora + ros::Duration(0.5))){

                    vel.linear.x = 0.05;//velocidad de avance
                    vel.angular.z = 0.0;//velocidad de giro
                    vel_pub_.publish(vel);
                    loop_rate.sleep();

}
               }

               ahora = ros::Time::now(); 
               if(scan_msg->ranges[x]<= 0.6){

                    while (ros::Time::now() < (ahora + ros::Duration(0.5))){ 
                    vel.linear.x = 0.0;//velocidad de avance
                    vel.angular.z = 0.0;//velocidad de giro
                    vel_pub_.publish(vel);}
                    loop_rate.sleep();

                }


     }
 }
int main(int argc, char** argv){
  ros::init(argc, argv, "DistanceObstacle");

  ros::NodeHandle n;
  ros::Publisher vel_pub_=n.advertise<geometry_msgs::Twist>("cmd_vel", 1);
  ros::Subscriber scan_sub = n.subscribe("scan", 1, scanCallback);

  ros::spin(); //Mantiene la suscripción al topic hasta que se reciba "Ctrl+C"
  return 0;

}

I've just managed to make my robot to stop when it's at a minimum distance,But, as you told me, I want to reduce the velocity with Vel=vel*0.5, but instead the robot always keeps moving at a constant velocity.What can I do? Thank you for your help

include <ros ros.h="">

include <sensor_msgs laserscan.h="">

include <geometry_msgs twist.h="">

void scanCallback (const sensor_msgs::LaserScan::ConstPtr& scan_msg) { geometry_msgs::Twist vel; //Declaración de la variable global vel

ros::NodeHandle n; ros::Publisher vel_pub_=n.advertise<geometry_msgs::twist>("cmd_vel", 1); ros::Time ahora; double minDist=10;
double angle;
double speed=0.5;

for (unsigned int i=0;i< scan_msg->ranges.size();i++){   

  angle = ((double)i*scan_msg->angle_increment)+scan_msg->angle_min;

   if (scan_msg->ranges[i]< minDist){
       minDist=scan_msg->ranges[i];      
       std::cout << minDist << std::endl;          
   }
 } 

if( minDist<=0.6){

            vel.linear.x = 0.0;//velocidad de avance
            vel.angular.z = 0.0;//velocidad de giro
            vel_pub_.publish(vel);
 }
else {


            speed=0.5*speed;
            vel.linear.x = speed;//velocidad de avance
            vel.angular.z = 0.0;//velocidad de giro
            vel_pub_.publish(vel);
            //std::cout << speed ...
(more)