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

bielpiero's profile - activity

2015-06-18 03:19:25 -0500 received badge  Famous Question (source)
2015-04-13 13:29:09 -0500 received badge  Notable Question (source)
2014-12-19 13:25:21 -0500 received badge  Popular Question (source)
2014-12-15 08:34:57 -0500 asked a question Subscriber Error.

I'm having next code developed in c++:

stdxros.hpp

#ifndef STDXROS_HPP
#define STDXROS_HPP

#include <ros/ros.h>
#include <geometry_msgs/Twist.h>
#include <std_msgs/Float32.h>
#include <std_msgs/Float64.h>
#include <sensor_msgs/PointCloud.h>
#include <sensor_msgs/LaserScan.h>
#include <nav_msgs/Odometry.h>
#include <rosaria/BumperState.h>
#include <laser_assembler/AssembleScans.h>

#endif

//GeneralController.h
#include "stdxros.hpp"
class GeneralController 
{
private:
    ros::NodeHandle nh;
public:
    GeneralController(ros::NodeHandle nh_);
    ~GeneralController(void);
private:

public:
    void batteryStateCallback(const std_msgs::Float32:ConstPtr& battery);
    void bumperStateCallback(const rosaria::BumperState::ConstPtr& bumpers);
    void poseStateCallback(const nav_msgs::Odometry::ConstPtr& pose);
};

//GeneralController.cpp
#include "GeneralController.h"
GeneralController::GeneralController(ros::NodeHandle nh_)
{
    this->nh = nh_;
}

void GeneralController::bumperStateCallback(const rosaria::BumperState::ConstPtr& bumpers){

    std::cout << "Bumper Event Thrown" << std::endl;

}

void GeneralController::poseStateCallback(const nav_msgs::Odometry::ConstPtr& pose){
    std::cout << "Pose Event Thrown" << std::endl;
}

void GeneralController::batteryStateCallback(const std_msgs::Float32::ConstPtr& battery){
    std::cout << "Battery Event Thrown" << std::endl;
}

servidor.cpp

#include <signal.h>
#include "GeneralController.h"

GeneralController *robot;

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

    ros::init(argc, argv, "bea_con_suerte");
    ros::start();
    ros::NodeHandle nh;

    robot = new GeneralController(nh);

    ros::Subscriber bumper_state = nh.subscribe("/RosAria/bumper_state", 1, &GeneralController::bumperStateCallback, robot);

    while(continue_execution){
    }

    return 0;
}

Makefile

IDIR=/opt/ros/hydro/include
UDIR=/usr/include/libusb-1.0
LDIR=/opt/ros/hydro/lib -Wl,-rpath,/opt/ros/hydro/lib
LIBS=pkg-config --libs libusb-1.0
CC=g++ -std=c++11
CFLAGS=-I$(IDIR) -I$(UDIR)
LFLAGS=-L$(LDIR)
OPTIONS=-lusb-1.0 -lroscpp -lrosconsole -lrostime
AR=ar

all:
    $(CC) GeneralController.cpp -o LuckyBea $(CFLAGS) $(LFLAGS) $(OPTIONS)
clean:
    rm -rf *.o *.a* *~LuckyBea

when execute makefile, next errors are thrown:

g++ -std=c++11 GeneralController.cpp SocketNode2.cpp servidor.cpp SerialPort.cpp -o LuckyBea -I/opt/ros/hydro/include -I/usr/include/libusb-1.0 -L/opt/ros/hydro/lib -Wl,-rpath,/opt/ros/hydro/lib -lusb-1.0 -lroscpp -lrosconsole -lrostime
In file included from /opt/ros/hydro/include/ros/subscriber.h:33:0,
                 from /opt/ros/hydro/include/ros/node_handle.h:33,
                 from /opt/ros/hydro/include/ros/ros.h:45,
                 from stdxros.hpp:4,
                 from GeneralController.h:8,
                 from servidor.cpp:2:
/opt/ros/hydro/include/ros/subscription_callback_helper.h: In instantiation of ‘void ros::SubscriptionCallbackHelperT<P, Enabled>::call(ros::SubscriptionCallbackHelperCallParams&) [with P = const boost::shared_ptr<const rosaria::BumperState_<std::allocator<void> > >&; Enabled = void]’:
servidor.cpp:50:1:   required from here
/opt/ros/hydro/include/ros/subscription_callback_helper.h:140:5: error: use of deleted function ‘boost::shared_ptr<const rosaria::BumperState_<std::allocator<void> > >::shared_ptr(const boost::shared_ptr<const rosaria::BumperState_<std::allocator<void> > >&)’
     callback_(ParameterAdapter<P>::getParameter(event));
     ^
In file included from /usr/include/boost/shared_ptr.hpp:17:0,
                 from /usr/include/boost/format/alt_sstream.hpp:21,
                 from /usr/include/boost/format/internals.hpp:23,
                 from /usr/include/boost/format.hpp:38,
                 from /usr/include/boost/math/policies/error_handling.hpp:30,
                 from /usr/include/boost/math/special_functions/round.hpp:14,
                 from /opt/ros/hydro/include/ros/time.h:58,
                 from /opt/ros/hydro/include/ros/ros.h:38,
                 from stdxros.hpp:4,
                 from GeneralController.h ...
(more)