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

ubisum's profile - activity

2019-10-03 01:04:16 -0500 received badge  Famous Question (source)
2016-08-08 00:21:43 -0500 marked best answer g2o doesn't find its own functions in ROS

Hello everyone.
I designed a ROS package that needs g2o library for SLAM.
I first tried to download and install it via shell, then I tried, as a test, to make some inclusions:

#include "/opt/ros/fuerte/include/g2o/types/slam2d/vertex_se2.h"
#include "/opt/ros/fuerte/include/g2o/types/slam2d/vertex_point_xy.h"
#include "/opt/ros/fuerte/include/g2o/types/slam2d/edge_se2.h"
#include "/opt/ros/fuerte/include/g2o/types/slam2d/edge_se2_pointxy.h"
#include "/opt/ros/fuerte/include/g2o/types/slam2d/types_slam2d.h"

#include "/opt/ros/fuerte/include/g2o/core/sparse_optimizer.h"
#include "/opt/ros/fuerte/include/g2o/core/block_solver.h"
#include "/opt/ros/fuerte/include/g2o/core/factory.h"
#include "/opt/ros/fuerte/include/g2o/core/optimization_algorithm_factory.h"
#include "/opt/ros/fuerte/include/g2o/core/optimization_algorithm_gauss_newton.h"
#include "/opt/ros/fuerte/include/g2o/solvers/csparse/linear_solver_csparse.h"

rosmake built without any issue the package, even when I added

using namespace g2o;

Then, I added a line of code that I actually need:

SparseOptimizer optimizer;

It gave origin to this error:

 CMakeFiles/thesis_main.dir/src/messageListener.o: In function `messageListener':
  /home/ubisum/fuerte_workspace/thesis_pack/src/messageListener.cpp:36: undefined reference to `g2o::SparseOptimizer::SparseOptimizer()'
  CMakeFiles/thesis_main.dir/src/thesis_main.o: In function `~messageListener':
  /home/ubisum/fuerte_workspace/thesis_pack/src/messageListener.h:44: undefined reference to `g2o::SparseOptimizer::~SparseOptimizer()'

As a second attempt, I downloaded vslam package from web, entered its subfolder /g2o and from inside it I ran build.
As a consequence, ROS found a new package g2o, as shown by rospack list; then I updated the manifest file in my package:

<package>
  <description brief="thesis_pack">

     thesis_pack

  </description>
  <author>Biagio</author>
  <license>BSD</license>
  <review status="unreviewed" notes=""/>
  <url>http://ros.org/wiki/thesis_pack</url>
  <depend package="roscpp"/>
  <depend package="rospy"/>
  <depend package="tf"/>
  <depend package="nav_msgs"/>
  <depend package="g2o"/>


</package>

leaving inclusions and g2o's namespace declaration in my .cpp file, but the error continues to remain. Do you know how to solve the problem?

thanks for help

2016-08-08 00:21:25 -0500 marked best answer g2o in ROS creates problems with Csparse

Hello everyone. I downloaded g2o library to use it from inside ROS. Everything seemed to work well, since writing

using namespace g20;

and including test library

#include "/opt/ros/fuerte/include/g2o/core/block_solver.h"

allowed compiling through rosmake from inside my package.
Problems arose when I started to write the real g2o code and just one line

SparseOptimizer optimizer;

caused the following error:

 /opt/ros/fuerte/include/g2o/solvers/csparse/csparse_helper.h:23:16: fatal error: cs.h: File o directory non esistente

Then I updated my system to have Csparse:

sudo apt-get install libsuitesparse-dev

but I got a message advising me that it's already there.
Finally, I modified my package's CMakeLists file:

include_directories(${CSPARSE_INCLUDE_DIR})

but nothing changed.
Does anyone how to solve the problem? thanks

2016-01-14 07:28:32 -0500 received badge  Famous Question (source)
2015-10-14 16:28:13 -0500 marked best answer stage doesn't display world maps

hello everyone
I'm trying to run some world maps in stage simulator. Everything works when writing

rosrun roscd stageros willow-erratic.world

while, when using any other world file (already present in default folder or added to it from internet), I get errors like the following one:

    OpenGL Warning: No pincher, please call crStateSetCurrentPointers() in your SPU
 [Loading willow-four-erratics.world][Image "willow-full.pgm"]
err: Model type laser not found in model typetable (/tmp/buildd/ros-fuerte-stage-1.6.6/debian/ros-fuerte-stage/opt/ros/fuerte/stacks/stage/build/stage/libstage/world.cc CreateModel)
err: Unknown model type laser in world file. (/tmp/buildd/ros-fuerte-stage-1.6.6/debian/ros-fuerte-stage/opt/ros/fuerte/stacks/stage/build/stage/libstage/world.cc CreateModel)

Another error I encountered is

ubisum@ubisum:/opt/ros/fuerte/stacks/stage/world$ rosrun stage stageros autolab.world
OpenGL Warning: No pincher, please call crStateSetCurrentPointers() in your SPU
 [Loading autolab.world][Include chatterbox.inc][Include irobot.inc][Include hokuyo.inc][Include map.inc][Image "bitmaps/autolab.png"]
[FATAL] [1360681774.773654192]: number of position models and laser models must be equal in the world file.
[FATAL] [1360681774.777624430]: BREAKPOINT HIT
    file = /tmp/buildd/ros-fuerte-stage-1.6.6/debian/ros-fuerte-stage/opt/ros/fuerte/stacks/stage/src/stageros.cpp
    line=208

Rilevato trace/breakpoint (core dump creato)

Do you know which are the causes of these two errors and how to solve them?

thanks for support

2015-10-12 11:09:35 -0500 received badge  Taxonomist
2015-09-18 18:52:09 -0500 marked best answer How to notify that a bag file has been completely played?

Hello everyone.
I built a bag file that, every time is played, sends messaged to two topics. I start bag playing from keyboard:

rosbag play -r 2 subset.bag

On the other side, there's a simple program receiving messages from both topics and calling right functions in a specified class to manage them according to their nature:

int main(int argc, char **argv){
    stage_listener sl;
    char buffer [1024];
    while(1){
        int i = fscanf(stdin,"%s",buffer);

        if(strcmp("exit",buffer) == 0)
            exit(0);

        else if(strcmp("num_nodes",buffer) == 0){
            printf("\nOdometry nodes: %i\nScan nodes: %i\n",sl.numOdom(),sl.numScan());
            //int b = (*sl).numOdom();
        }

        else if(strcmp("listen",buffer) == 0){
            ROS_INFO("Activating topics listening...\n");
            ros::init(argc,argv, "listener");
            ros::NodeHandle n_odom, n_scan;
            ros::Subscriber sub_odom = n_odom.subscribe("/odom", 1000, &stage_listener::addOdomNode, &sl);
            ros::Subscriber sub_scan = n_scan.subscribe("/base_scan", 1000, &stage_listener::addScanNode, &sl); 

            ros::spin();
            ROS_INFO("Listening activity completed");
        }

        else{
            ROS_INFO("Command not found\n");
        }
    }

}

The receiver stands waiting for messages after executing instruction

ros::spin();

The problem is that receiver doesn't know when all messages have been sent and keeps waiting, without regaining control and proceeding in executing subsequent instructions. I want, after the end of messages in bag file, main() function to regain control and print on screen by instruction

ROS_INFO("Listening activity completed");

Then, a new execution of while(1) must start, in such a way new commands can be inserted from keyboard through instruction

int i = fscanf(stdin,"%s",buffer);

Is there a way to break ros::spin() loop when there are no more messages to be received?

Thanks for help.

2015-08-31 21:11:31 -0500 marked best answer Undefined reference error while constructing a list of nodes

Hello everyone I need to construct a list of odometric and laser measurement. For this purpose, I first wrote a .h file:

#include "ros/ros.h"
#include "nav_msgs/Odometry.h"
#include "geometry_msgs/Pose.h"
#include "geometry_msgs/Point.h"
#include "stdio.h"
#include "sensor_msgs/LaserScan.h"


class odom_node{
public:
    odom_node();
    ~odom_node();
    float xCoord;
    float yCoord;
    float angle;
    std::string frame_id;
    odom_node *next;
};

class scan_node{
public:
    scan_node();
    float scan[];
    std::string frame_id;
    scan_node *next;
};

class stage_listener{
public:
    stage_listener();

private:
    odom_node odom_graph;
    scan_node scan_list;
    void addOdomNode (const nav_msgs::Odometry);
};  

Then, in an associated .cpp file, I started defining the body of class stage_listener:

#include "ros/ros.h"
#include "nav_msgs/Odometry.h"
#include "geometry_msgs/Pose.h"
#include "geometry_msgs/Point.h"
#include "stdio.h"
#include "sensor_msgs/LaserScan.h"
#include "stage_listener.h"
#include "tf/transform_listener.h"

void addOdomNode (const nav_msgs::Odometry mes){
    geometry_msgs::Pose robot_pose = mes.pose.pose;
    geometry_msgs::Point robot_point = robot_pose.position;

    //float xCoord = robot_point.x;
    //float yCoord = robot_point.y;
    //float zCoord = robot_point.z;

    odom_node on;
    //on.xCoord = robot_point.x;
    //double orientation = tf::getYaw(robot_pose.orientation);
}

int main(){}

Anyway, for what regads line

odom_node on;

I get the following error, after digiting make, once inside my ros package:

CMakeFiles/stage_listener.dir/src/stage_listener.o: In function `addOdomNode(nav_msgs::Odometry_<std::allocator<void> >)':
/home/ubisum/fuerte_workspace/beginner/src/stage_listener.cpp:18: undefined reference to `odom_node::odom_node()'
/home/ubisum/fuerte_workspace/beginner/src/stage_listener.cpp:18: undefined reference to `odom_node::~odom_node()'

Does anyone know the reason? I'm sorry if question may seem too silly, but I'm learning C++ and ROS at the once and it's not easy when coming from Java and MatLab.

Thanks for help

2015-05-27 18:58:30 -0500 received badge  Famous Question (source)
2014-12-05 14:11:07 -0500 received badge  Famous Question (source)
2014-11-09 17:08:14 -0500 received badge  Famous Question (source)
2014-11-03 12:27:15 -0500 received badge  Popular Question (source)
2014-11-03 12:27:15 -0500 received badge  Notable Question (source)
2014-09-05 15:28:43 -0500 received badge  Popular Question (source)
2014-09-05 15:28:43 -0500 received badge  Notable Question (source)
2014-08-24 12:33:51 -0500 received badge  Notable Question (source)
2014-08-24 12:33:51 -0500 received badge  Famous Question (source)
2014-08-14 02:35:38 -0500 received badge  Famous Question (source)
2014-08-14 02:35:38 -0500 received badge  Notable Question (source)
2014-08-14 02:35:38 -0500 received badge  Popular Question (source)
2014-08-08 05:28:53 -0500 received badge  Famous Question (source)
2014-06-12 18:44:27 -0500 received badge  Famous Question (source)
2014-04-20 06:56:02 -0500 marked best answer ROS Hydro on ubuntu 13.10: installation problems

hello everyone. i've just installed last ubuntu's release on my computer (it seemed a good idea), then i tried to install even last release of ROS.
Sadly, that's what i get:

ubisum@biagioPC:~$ sudo apt-get install ros-hydro-desktop-full
Reading package lists... Done
Building dependency tree       
Reading state information... Done
Some packages could not be installed. This may mean that you have
requested an impossible situation or if you are using the unstable
distribution that some required packages have not yet been created
or been moved out of Incoming.
The following information may help to resolve the situation:

The following packages have unmet dependencies:
 ros-hydro-desktop-full : Depends: ros-hydro-desktop but it is not going to be installed
                          Depends: ros-hydro-simulators but it is not going to be installed
E: Unable to correct problems, you have held broken packages.

do you know any breakthrough? thanks.

2014-04-20 06:52:21 -0500 marked best answer ROS errors while exchanging messages with Stage

hello everyone I'm just trying to write a simple C++ client of Stage package. Just to make a test, i want to write a short code to receive some odometry data from /odom topic and print it onto screen:

#include "ros/ros.h"
#include "nav_msgs/Odometry.h"
#include "geometry_msgs/Pose.h"
#include "geometry_msgs/Point.h"
/* #include "geometry_msgs/Point" */
void chatter (const nav_msgs::Odometry mes){
    geometry_msgs::Pose robot_pose = mes.pose;
    geometry_msgs::Point robot_point = robot_pose.position; 
    float xCoord = robot_point.x;
    float yCoord = robot_point.y;
    float zCoord = robot_point.z;
    ROS_INFO("I received %f %f %f/n", xCoord, yCoord, zCoord);  
}
int main(int argc, char **argv){
    ros::init(argc,argv, "listener");
    ros::NodeHandle n;
    ros::Subscriber sub = n.subscribe("/odom", 1000, chatter);
    ros::spin();
    return 0;
} 

Sadly ROS compiler gives me an error:

/home/ubisum/fuerte_workspace/beginner/src/listener.cpp: In function ‘void chatter(nav_msgs::Odometry)’:
/home/ubisum/fuerte_workspace/beginner/src/listener.cpp:8:39: error: conversion from ‘const _pose_type {aka const geometry_msgs::PoseWithCovariance_<std::allocator<void> >}’ to non-scalar type ‘geometry_msgs::Pose’ requested
make[3]: *** [CMakeFiles/listener.dir/src/listener.o] Errore 1
make[3]: uscita dalla directory "/home/ubisum/fuerte_workspace/beginner/build"
make[2]: *** [CMakeFiles/listener.dir/all] Errore 2
make[2]: uscita dalla directory "/home/ubisum/fuerte_workspace/beginner/build"
make[1]: *** [all] Errore 2
make[1]: uscita dalla directory "/home/ubisum/fuerte_workspace/beginner/build"
make: *** [all] Errore 2

Could you help me? I'm both a ROS and C++ newbie. Thanks

2014-03-28 03:52:06 -0500 received badge  Famous Question (source)
2014-02-25 23:03:19 -0500 received badge  Famous Question (source)
2014-02-10 05:18:47 -0500 received badge  Popular Question (source)
2014-02-07 17:55:42 -0500 received badge  Notable Question (source)
2014-01-28 17:31:54 -0500 marked best answer ROS misses some messages

Hello everyone. I'm writing a test program, which receives messages from two different topics and stores them in different queues.
The program, works on a while loop and, at every iteration, before checking for the arrival of new messages, it deletes the top elements of the queues if they have both one.
The program subscribes to a third queue, too, that I use to send a termination message.
Here is the code:

#include "/opt/ros/fuerte/include/ros/ros.h"
#include "/opt/ros/fuerte/include/nav_msgs/Odometry.h"
#include "/opt/ros/fuerte/include/geometry_msgs/Pose.h"
#include "/opt/ros/fuerte/include/geometry_msgs/Point.h"
#include "/opt/ros/fuerte/include/std_msgs/String.h"
#include "/opt/ros/fuerte/include/sensor_msgs/LaserScan.h"
#include "/opt/ros/fuerte/stacks/geometry/tf/include/tf/transform_listener.h"

#include "odom_node.h"
#include "scan_node.h"
#include "messageListener.h"

#include "list"
#include "vector"
#include "coord.h"
#include "math.h"
#include "stdlib.h"
#include "iterator"
#include "string"
#include "iostream"
#include "fstream"
#include "string"
#include "sstream"

#include "stdio.h"
#include "iostream"
#include "map"
#include "math.h"
#include "stdlib.h"
#include "string"

using namespace std;

messageListener::messageListener(){
    odomCounter = 0;
    scanCounter = 0;
}

void messageListener::end_loop(const std_msgs::String mes){
    printf("Setting flag\n");
        while_flag = 0;
}

void messageListener::addOdomNode (const nav_msgs::Odometry mes){
    geometry_msgs::Pose robot_pose = mes.pose.pose;
    geometry_msgs::Point robot_point = robot_pose.position;

    odom_node *on = new odom_node();
    (*on).xCoord = robot_point.x;
    (*on).yCoord = robot_point.y;
    (*on).frame_id = mes.header.frame_id;

    double orientation = tf::getYaw(robot_pose.orientation);
    (*on).angle = (float)orientation;

    odomVector.push_back(*on);
    odomCounter++;
}

vector<coord> messageListener::polar2cart(vector<float> v, float a_min, float a_inc, float range_min, float range_max){
    vector<coord> lc;
    for(int i=0; i<(int)v.size(); i++){
        if(v[i]>= range_min && v[i]<=range_max){
            coord *c = new coord();
            (*c).x = v[i]*cos(a_min + a_inc*i);
            (*c).y = v[i]*sin(a_min + a_inc*i);

            lc.push_back(*c);
        }
    }

    return lc;
}

void messageListener::addScanNode (const sensor_msgs::LaserScan mes){
    //printf("scan");
    scan_node *sn = new scan_node();
    (*sn).scan = mes.ranges;
    (*sn).frame_id = mes.header.frame_id;
    (*sn).cartesian = polar2cart(mes.ranges, mes.angle_min, mes.angle_increment, mes.range_min, mes.range_max);

    scanVector.push_back(*sn);
    scanCounter++;
}

void messageListener::listen(int c, char** v){
    while_flag = 1;
    printf("Listening activity begun\n");
    ros::init(c,v, "listener");
    ros::NodeHandle n_odom, n_scan, n_end;

    ros::Subscriber sub_odom = n_odom.subscribe("/odom", 1000, &messageListener::addOdomNode,this);
    ros::Subscriber sub_scan = n_scan.subscribe("/base_scan", 1000, &messageListener::addScanNode,this);
    ros::Subscriber sub_end = n_end.subscribe("/end", 1000, &messageListener::end_loop,this);
    printf("Subscription complete\n");

    while(while_flag){
        if(odomVector.size()>0 && scanVector.size()>0){
            odomVector.erase(odomVector.begin());
            scanVector.erase(scanVector.begin());
        }

        ros::spinOnce();
    }

    printf("Exit from listening\n");
    printf("Ricevuti %i nodi odometrici e %i nodi scansione\n", odomCounter, scanCounter);
    printf("Terminazione in corso con %i nodi odometrici e %i nodi scansione in coda rimasti\n\n", (int)odomVector.size(), (int)scanVector.size());
}

Here, odomCounter and scanCounter are just two counters that I use to count received messages.
After starting the program, I play a bag file, whose information is reported in the following:

ubisum@ubisum ...
(more)
2014-01-28 17:28:43 -0500 marked best answer adding a message at the end of a bag file

Hello, everyone
Is it possible to add a message at the end of a bag file (the messages is of the same kind of the ones already in the bag)?

thanks for support.

2014-01-28 17:28:39 -0500 marked best answer automatic playing of bag files

hello everyone
my question is simple: I have two bag files to be played in sequence. Is there a way (for example, a launch file) to make this sequential execution automatic without need to perform it manually from the shell? I want, in particular, first bag to be played. After end of playing, second bag must be executed. I can't use something like

rosbag play bag1.bag bag2.bag

since first bag has a timestamp whose year is 1970, so second bag cannot be played before 40 years are past...

thanks for support

2014-01-28 17:28:31 -0500 marked best answer STAGE creates bag files with a wrong timestamp

hello everyone
in these days, i've tried to create bag files by recording messages generated by STAGE robot simulator.
The problem is that every bag file generated has a timestamp associated to the date of linux's birth (january 1st, 1970). I tried twice and I got same problem. This doesn't happen if i generate a custom topic, write on it by my code and store messages in a bag file. in this case, bag file has a correct timestamp.

could you tell me how to force system to write properly timestamps for bags generated by STAGE?
thanks for support.

2014-01-28 17:28:28 -0500 marked best answer my nodes don't send (receive) messages

hello everyone
I created a class stage_listener; then, in an externally defined main() function, an object of class stage_listener is created and its function listen is invoked.
The purpose of this function is forcing the object of class stage_listener to become a listener of certain kinds of messages. Here is the code of function:

void stage_listener::listen(int c, char **v){
    while_flag = 1;
    ROS_INFO("Listening activity begun");
    ros::init(c,v, "listener");
    ros::NodeHandle n_odom, n_scan, n_end;
/*  std_msgs::String s;
    end_loop(s);*/

    //ros::Subscriber sub_odom = n_odom.subscribe("/odom", 1000, &stage_listener::end_loop,this);
    ros::Subscriber sub_odom = n_odom.subscribe("/odom", 1000, &stage_listener::addOdomNode,this);
    ros::Subscriber sub_scan = n_scan.subscribe("/base_scan", 1000, &stage_listener::addScanNode,this);
    ros::Subscriber sub_end = n_end.subscribe("/end", 1000, &stage_listener::end_loop,this);

    while(while_flag){
        //ros::Subscriber sub_odom = n_odom.subscribe("/odom", 1000, &stage_listener::end_loop,this);
        ros::spinOnce();
    }
    ROS_INFO("Exit from while");
}

The function receives, as parameters, the argc and argv of the main() where object has been created, since such parameters are requested by ros::init.
These are the functions used for listening:

void stage_listener::end_loop(const std_msgs::String mes){
    ROS_INFO("Setting flag");
    ROS_INFO("%s",mes.data.c_str());
    while_flag = 0;
}

void stage_listener::addOdomNode (const nav_msgs::Odometry mes){
    geometry_msgs::Pose robot_pose = mes.pose.pose;
    geometry_msgs::Point robot_point = robot_pose.position;

    odom_node *on = new odom_node();
    (*on).xCoord = robot_point.x;
    (*on).yCoord = robot_point.y;
    (*on).frame_id = mes.header.frame_id;

    double orientation = tf::getYaw(robot_pose.orientation);
    (*on).angle = (float)orientation;

    odom_list.push_back(*on);
}

void stage_listener::addScanNode (const sensor_msgs::LaserScan mes){
    scan_node *sn = new scan_node();
    (*sn).scan = mes.ranges;
    (*sn).frame_id = mes.header.frame_id;
    (*sn).cartesian = polar2cart(mes.ranges, mes.angle_min, mes.angle_increment, mes.range_min, mes.range_max);

    scan_list.push_back(*sn);
}

After invocation of function listen, the object created begins to wait for messages. An external node, in another package, prepares and sends an std_msgs::String message:

#include "std_msgs/String.h"
#include "ros/ros.h"

int main(int argc, char **argv){
    ros::init(argc, argv,"end_bag");
    ros::NodeHandle n;

    ros::Publisher chatter_pub = n.advertise<std_msgs::string>("/end",1000);
    ros::Rate loop_rate(10);

    std_msgs::String msg;
    msg.data = "end of loop";

    chatter_pub.publish(msg);

    ROS_INFO("Message sent: %s",msg.data.c_str());

    ros::spinOnce();
    //sleep(3);
    loop_rate.sleep();

    exit(0);
}

The problem is that the message created is never received by the waiting object, since it remains iterating on spinOnce() instruction, never exiting the loop, a result that should be granted by reception of message.

Can you individuate any error in my code causing receiver node not to get any message? thanks for support.

2014-01-28 17:28:25 -0500 marked best answer sending messages containing not predefined types

Hello everyone.
I took a look at how custom messages can be designed in ROS and I realized that they can just include fields of predefined types (for instance, integers and strings).
Instead, I have two active nodes needing to communicate with each other. One of them, produces a list of objects belonging to a class that I have defined. This list should be sent to the other node but I guess it's not possible using standard ROS messages.
Could you suggest a way to bypass the problem, maybe using possible definitions of ROS messages?

Thanks for help.