Quantcast
Channel: ROS Answers: Open Source Q&A Forum - RSS feed
Viewing all articles
Browse latest Browse all 417

eclipse and catkin_make not linking to ros.h dependencies

$
0
0
Hello all, So I am working on a project where I basically want to create a node to take information from another, check it, then publish that information elsewhere. I was working on it yesterday and my coding environment was working fine(eclipse mars) however at one point yesterday it stopped recognizing all of my references to ros functions or message types. I thought it was just an eclipse specific thing so I tried to run it with catkin_make in my catkin workspace and that threw the same "undefined reference to ros*" errors as the build did in eclipse. Like I said, all was fine and dandy but now it isn't working. Below is the code for the node I am working with. #include #include "/opt/ros/indigo/include/ros/ros.h" #include #include #include #include /// ROS node name const std::string ComponentName = "vel_cmd_filter_node"; const std::string J5CommandTopic = "/j5_cmd"; const std::string MoveBaseCmd = "/cmd_vel"; /// default forward linear velocity command in m/s const float DefaultVelocityCmd = 0.0; /// default angular velocity command in rad/s const float DefaultTurnRateCmd = 0.0; /// the rate at which the component will publish commands const int LoopRate = 10; // Hz /// input value limits /// these are just here for safety and do not reflect the actual limits of the platform const double MaxVelocityCommand = 3.0; const double MaxTurnRateCommand = 1.0; geometry_msgs::Twist incoming; void chatterCallback(const geometry_msgs::Twist& velcmd); geometry_msgs::Twist getCommandMsg(); int main(int argc, char **argv) { // get all command line arguments that aren't ROS specific // these should be the velocity command parameters // initialize ROS std::vector args; geometry_msgs::Twist velcmd; ros::init(argc,argv, ComponentName); ros::removeROSArgs(argc, argv, args); ros::NodeHandle nh; ros::Subscriber sub = nh.subscribe(MoveBaseCmd, 1000, chatterCallback); // velocity command publisher ros::Publisher velCmdPub = nh.advertise(J5CommandTopic, 1000); // asynchronous spinner to receive ROS messages ros::AsyncSpinner spinner(0); // loop rate used to control the frequency of message publication ros::Rate loop_rate(LoopRate); // set up message command geometry_msgs::Twist cmdMsg = getCommandMsg(); // run loop spinner.start(); while (ros::ok()) { // publish velocity command ROS_INFO("Sending Velocity Command: {%f, %f}", cmdMsg.linear.x, cmdMsg.angular.z); if (cmdMsg.linear.x || cmdMsg.angular.z) { velCmdPub.publish(cmdMsg); } ros::spinOnce(); loop_rate.sleep(); } // shutdown component spinner.stop(); ros::shutdown(); return 0; } void chatterCallback(const geometry_msgs::Twist& velcmd) { ROS_INFO("I heard this velocity: [%f]", velcmd.linear.x); ROS_INFO("I heard this rotation: [%f]", velcmd.angular.z); incoming = velcmd; } geometry_msgs::Twist getCommandMsg() { geometry_msgs::Twist msg; // body coordinates // x is forward linear motion msg.linear.x = DefaultVelocityCmd; // rotation around the Z axis msg.angular.z = DefaultTurnRateCmd; // all other parameters are ignored in the Twist message // NOTE:: args[0] is the name of the if (incoming.linear.x) { try { msg.linear.x = incoming.linear.x; msg.linear.x = std::max(msg.linear.x, -MaxVelocityCommand); msg.linear.x = std::min(msg.linear.x, MaxVelocityCommand); } catch (...) { // could not parse the input, use default value msg.linear.x = DefaultVelocityCmd; } } if (incoming.angular.z) { try { msg.angular.z = incoming.angular.z; msg.angular.z = std::max(msg.angular.z, -MaxTurnRateCommand); msg.angular.z = std::min(msg.angular.z, MaxTurnRateCommand); } catch (...) { // could not parse the input, use default value msg.angular.z = DefaultTurnRateCmd; } } return msg; } Sorry about the wonky formatting...I'm still trying to get use to this posting stuff. Please let me know if you need more info! And thanks for the help!!! Here is my cmake file like requested! cmake_minimum_required(VERSION 2.8.3) project(vel_cmd_filter) find_package(catkin REQUIRED COMPONENTS j5_msgs roscpp rospy std_msgs genmsg ) INCLUDE_DIRS include LIBRARIES vel_cmd_filter CATKIN_DEPENDS j5_msgs roscpp rospy std_msgs DEPENDS system_lib ) include_directories( ${catkin_INCLUDE_DIRS} ) add_executable(vel_cmd_filter_node src/vel_cmd_filter_node.cpp) I went through and deleted all the generated commented out things so you don't have to look at all that garbage. I also switched things around from my original post so I changed it to the most recent code.Thanks!

Viewing all articles
Browse latest Browse all 417

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>