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

Error: Invalid Arguments

asked 2018-06-10 09:17:16 -0500

Swag10 gravatar image

Hello, I am a beginner and so have been posting very small types of issues. Today i am facing error in my coding.

Below code line provides an invalid argument error for ros::init function

error: Invalid arguments

Candidates are:

void init(const ? &, const ? &, ?)

void init(int &, char * *, const ? &, ?)

#include <ros/ros.h>

#include "husky_highlevel_controller/HuskyHighlevelController.hpp"

int main(int argc, char** argv)
{
  ros::init(argc, argv, "husky_highlevel_controller");
  ros::NodeHandle nodeHandle("~");

  husky_highlevel_controller::HuskyHighlevelController huskyHighlevelController(nodeHandle);

  ros::spin();
  return 0;
}

There may be some small thing I am missing, I have went through the entire ros::init, subscriber, publisher tutorials, but it is hard to find why these errors. Sorry for so many doubts, but I have followed all proper syntax and could not debug it any more further. Yet to start with main code. These are like basic errors before I can start anything. Other error was in ROS::ERROR(), subscribing, publishing and getting parameters

For ROS::ERROR();

error: Invalid arguments '

Candidates are:

void initializeLogLocation(ros::console::LogLocation *, const ? &, enum ros::console::levels::Level)

For nH_.advertise()

error1:

Couldnot resolve advertise

error2:

template argument 1 is invalid

For, nH_.subscribe()

error:

no matching function for call to ‘ros::NodeHandle::subscribe(std_msgs::String&, int, void (husky_highlevel_controller::HuskyHighlevelController::)(const ConstPtr&), husky_highlevel_controller::HuskyHighlevelController)’

#include "husky_highlevel_controller/HuskyHighlevelController.hpp"
#include <ros/ros.h>
#include <sensor_msgs/LaserScan.h>
#include <geometry_msgs/Twist.h>
#include <ros/console.h>

namespace husky_highlevel_controller {

HuskyHighlevelController::HuskyHighlevelController(ros::NodeHandle& nH) : nH_(nH)
{
    if (!readParameters()) {
        ROS_ERROR("Could not read parameters.");
        ros::requestShutdown();
      }
    twistPublisher_=nH_.advertise<geometry_msgs::Twist>(twistTopic_,10);
    subscriber_ = nH_.subscribe(scanTopic_, 10, &HuskyHighlevelController::scanCallback, this);
}
HuskyHighlevelController::~HuskyHighlevelController()
{
}

bool HuskyHighlevelController::readParameters()
{
    if (!nH_.getParam("husky_highlevel_controller/twist_publisher_topic_name", twistTopic_))
        return false;
    if (!nH_.getParam("husky_highlevel_controller/scan_subscriber_topic_name", scanTopic_))
        return false;
}

void HuskyHighlevelController::scanCallback(const sensor_msgs::LaserScan::ConstPtr& msg)
{

}


} /* namespace */
edit retag flag offensive close merge delete

1 Answer

Sort by » oldest newest most voted
0

answered 2019-09-15 20:06:24 -0500

Berg gravatar image

Hello, I am new to ROS also, and encountered exactly the same issue. It's not an issue with ROS (you might be able to verify this through compiling with command line, instead Eclipse). But we need IDE to make programming easier. I resolved the issue by two steps: 1. Context menu of project -> Clean Project 2. Context menu of project -> Index -> Rebuild

edit flag offensive delete link more

Question Tools

2 followers

Stats

Asked: 2018-06-10 09:17:16 -0500

Seen: 781 times

Last updated: Jun 10 '18