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

ROS C++ Dynamic Reconfigure bind error

asked 2022-03-27 06:55:01 -0500

kamiln497 gravatar image

Hello, I've got problem with Dynamic reconfigure. I want to create bind function for DynamicGUI Class due to tutorial, but something is wrong. All Dynamic reconfigure functionality is in DynamicGUI Class.

DynamicGui.h

#include <gateway_sim/SimulationConfig.h>
#include <dynamic_reconfigure/server.h>
#ifndef DYNAMICGUI_H
#define DYNAMICGUI_H

class DynamicGUI
{
public:
    DynamicGUI();
    ~DynamicGUI();

    ethercat_gateway::DOutput GatewayOutput; 
    ethercat_gateway::DAInput GatewayInput;

    dynamic_reconfigure::Server<gateway_sim::SimulationConfig> dParamServer;
    dynamic_reconfigure::Server<gateway_sim::SimulationConfig>::CallbackType f;
    void paramCb(gateway_sim::SimulationConfig &config, uint32_t level);
};

#endif

DynamicGui.cpp

#include <gateway_sim/DynamicGui.h>

DynamicGUI::DynamicGUI()
{
    f= boost::bind(&DynamicGUI::paramCb, _1, _2);
    dParamServer.setCallback(f);
}

void DynamicGUI::paramCb(gateway_sim::SimulationConfig &config, uint32_t level)
{
    GatewayOutput.Output_value_Ch1 = config.Output_value_Ch1;
    GatewayOutput.Output_value_Ch2 = config.Output_value_Ch2;
    GatewayOutput.Output_value_Ch3 = config.Output_value_Ch3;
    GatewayOutput.Output_value_Ch4 = config.Output_value_Ch4;
    GatewayOutput.Output_value_Ch5 = config.Output_value_Ch5;
    GatewayOutput.Output_value_Ch6 = config.Output_value_Ch6;
    GatewayOutput.Output_value_Ch7 = config.Output_value_Ch7;
    GatewayOutput.Output_value_Ch8 = config.Output_value_Ch8;
    GatewayOutput.Output_value_Ch9 = config.Output_value_Ch9;
    GatewayOutput.Output_value_Ch10 = config.Output_value_Ch10;
    GatewayOutput.Output_value_Ch11 = config.Output_value_Ch11;
    GatewayOutput.Output_value_Ch12 = config.Output_value_Ch12;
    GatewayOutput.Output_value_Ch13 = config.Output_value_Ch13;
    GatewayOutput.Output_value_Ch14 = config.Output_value_Ch14;
    GatewayOutput.Output_value_Ch15 = config.Output_value_Ch15;
    GatewayOutput.Output_value_Ch16 = config.Output_value_Ch16;
}

The Class is created in ControlNode node.

#include <gateway_sim/ControlNode.h>
#include<gateway_sim/DynamicGui.h>
#include <signal.h>

ControlNode::ControlNode() : TurckIO (nh), Motor1(nh,"s1"), Motor2 (nh, "s2") 
{

  DynamicGUI Reconfigurate();
    ControlDataTimer = nh.createTimer(ros::Duration(0.01), &ControlNode::timerCallback, this);
    ControlDataTimer1s = nh.createTimer(ros::Duration(1), &ControlNode::timerCallback1s, this);

}

I receive error:

In file included from /usr/include/boost/bind.hpp:22,
                 from /opt/ros/noetic/include/ros/publisher.h:35,
                 from /opt/ros/noetic/include/ros/node_handle.h:32,
                 from /opt/ros/noetic/include/ros/ros.h:45,
                 from /home/kamil/catkin_ws/src/gateway_sim/include/gateway_sim/ControlNode.h:11,
                 from /home/kamil/catkin_ws/src/gateway_sim/include/gateway_sim/DynamicGui.h:2,
                 from /home/kamil/catkin_ws/src/gateway_sim/src/DynamicGui.cpp:1:
/usr/include/boost/bind/bind.hpp: In instantiation of ‘struct boost::_bi::result_traits<boost::_bi::unspecified, void (DynamicGUI::*)(gateway_sim::SimulationConfig&, unsigned int)>’:
/usr/include/boost/bind/bind.hpp:1284:48:   required from ‘class boost::_bi::bind_t<boost::_bi::unspecified, void (DynamicGUI::*)(gateway_sim::SimulationConfig&, unsigned int), boost::_bi::list2<boost::_bi::value<DynamicGUI*>, boost::arg<1> > >’
/home/kamil/catkin_ws/src/gateway_sim/src/DynamicGui.cpp:7:50:   required from here
/usr/include/boost/bind/bind.hpp:75:37: error: ‘void (DynamicGUI::*)(gateway_sim::SimulationConfig&, unsigned int)’ is not a class, struct, or union type
   75 |     typedef typename F::result_type type;
      |                                     ^~~~
In file included from /usr/include/boost/function/detail/maybe_include.hpp:29,
                 from /usr/include/boost/function/detail/function_iterate.hpp:14,
                 from /usr/include/boost/preprocessor/iteration/detail/iter/forward1.hpp:58,
                 from /usr/include/boost/function.hpp:71,
                 from /opt/ros/noetic/include/ros/forwards.h:40,
                 from /opt/ros/noetic/include/ros/common.h:37,
                 from /opt/ros/noetic/include/ros/ros.h:43,
                 from /home/kamil/catkin_ws/src/gateway_sim/include/gateway_sim/ControlNode.h:11,
                 from /home/kamil/catkin_ws/src/gateway_sim/include/gateway_sim/DynamicGui.h:2,
                 from /home/kamil/catkin_ws/src/gateway_sim/src/DynamicGui.cpp:1:
/usr/include/boost/function/function_template.hpp: In instantiation of ‘static void boost::detail::function::void_function_obj_invoker2<FunctionObj, R, T0, T1>::invoke(boost::detail::function ...
(more)
edit retag flag offensive close merge delete

1 Answer

Sort by » oldest newest most voted
0

answered 2022-03-31 12:54:41 -0500

kamiln497 gravatar image

Solved.

in .h file:

dynamic_reconfigure::Server<gateway_sim::SimulationConfig> dParamServer;
dynamic_reconfigure::Server<gateway_sim::SimulationConfig>::CallbackType f;

In .cpp:

f= boost::bind(&DynamicGUI::paramCb, this, _1, _2);
dParamServer.setCallback(f);
edit flag offensive delete link more

Question Tools

Stats

Asked: 2022-03-27 06:55:01 -0500

Seen: 204 times

Last updated: Mar 31 '22