Ch10 mastering ROS: AsyncSpinner not found (Kinetic)
I am having the following errors:
home/marcus/catkin_ws/src/seven_dof_arm_test/src/test_random.cpp:9:6: error: ‘AsyncSpinner’ was not declared in this scope
ros:AsyncSpinner async_spinner(1);
/home/marcus/catkin_ws/src/seven_dof_arm_test/src/test_random.cpp:10:2: error: ‘spinner’ was not declared in this scope
spinner.start();
^
/home/marcus/catkin_ws/src/seven_dof_arm_test/src/test_random.cpp:13:2: error: ‘move_group_interface’ has not been declared
move_group_interface::MoveGroupInterface move_group("arm");
^
/home/marcus/catkin_ws/src/seven_dof_arm_test/src/test_random.cpp:15:2: error: ‘group’ was not declared in this scope
group.setRandomTarget();
OBS: I have already copied the following code from github: "spinner,h" inside the moveit library and edited the cmakelists...to include this library....I am using kinetic so this library did not existed in the "/opt/ros/kinetic/include/moveit/movegroupinterface$"
It only existed the movegroup.h and the movegroupinterface.h .....so I created the spinner.h too However You can see that in the error ....."the spinner" ..."the movegroup"...."the movegroupinterface" was not declared...
My test_random.cpp is below:
//Movelt! header file
#include <moveit/move_group_interface/move_group_interface.h>
#include <moveit/move_group_interface/spinner.h>
#include <moveit/move_group_interface/move_group.h>
int main(int argc, char **argv)
{
ros::init(argc, argv, "test_random_node", ros::init_options::AnonymousName);
//start a ROS spinning thread
ros:AsyncSpinner async_spinner(1);
spinner.start();
//this connects to a running instance of the move_group node
//Here the Planning group is "arm"
move_group_interface::MoveGroupInterface move_group("arm");
//Specify that our target will be a random one
group.setRandomTarget();
//plan the motion and then move the group to the sampled target
group.move();
ros::waitForShutdown();
}
Edit: To link with roscpp I wrote in C.makeLists:
cmake_minimum_required(VERSION 2.8.3)
project(seven_dof_arm_test)
add_compile_options(-std=c++11)
## Compile as C++11, supported in ROS Kinetic and newer
# add_compile_options(-std=c++11)
## Find catkin macros and libraries
## if COMPONENTS list like find_package(catkin REQUIRED COMPONENTS xyz)
## is used, also find other catkin packages
find_package(catkin REQUIRED COMPONENTS
interactive_markers
cmake_modules
moveit_core
moveit_ros_perception
moveit_ros_planning_interface
pluginlib
roscpp
std_msgs
).....................................etc....
and I included <ros/ros.h>
and removed the spinner.h
in include....However the terminal displayed the same error unfortunately.
Do you have another suggestion my friend?
Asked by Vini71 on 2019-06-20 15:46:56 UTC
Answers
//Movelt! header file #include <moveit/move_group_interface/move_group_interface.h> #include <moveit/move_group_interface/spinner.h> #include <moveit/move_group_interface/move_group.h>
I don't think this has anything to do with Kinetic vs Indigo: you're not including the required headers.
Remove the spinner.h
you created and add
#include <ros/ros.h>
That should resolve your issues.
Be sure to also link against roscpp
.
Asked by gvdhoorn on 2019-06-20 16:21:33 UTC
Comments
Thanks it worked. I think I am with probllems in C++ and in to comprehend ROS errors...I having another problem with the test_custom.cpp in arm tutorial from chapter 10 of Mastering ROS....I am very sad..
Asked by Vini71 on 2019-06-23 16:18:44 UTC
Your line ros:AsyncSpinner async_spinner(1);
is missing a colon for the namespace. Add the colon to make it ros::AsyncSpinner async_spinner(1);
.
Asked by ssnover on 2019-06-21 16:02:37 UTC
Comments
Please show us your complete
CMakeLists.txt
.And "the same error" is too vague. Please show verbatim copy-pastes of error messages.
And I believe on Kinetic the correct type would be
moveit::planning_interface::MoveGroupInterface
, notmove_group_interface::MoveGroupInterface
.Asked by gvdhoorn on 2019-06-21 06:31:12 UTC
Thanks for the answer. I tried to implement you suggestion above, unfortonately it did not work. My complete CMakeLists is following below:
cmake_minimum_required(VERSION 2.8.3) project(seven_dof_arm_test)
add_compile_options(-std=c++11)
Compile as C++11, supported in ROS Kinetic and newer
add_compile_options(-std=c++11)
Find catkin macros and libraries
if COMPONENTS list like find_package(catkin REQUIRED COMPONENTS xyz)
is used, also find other catkin packages
find_package(catkin REQUIRED COMPONENTS interactive_markers cmake_modules moveit_core moveit_ros_perception moveit_ros_planning_interface pluginlib roscpp std_msgs )
System dependencies are found with CMake's conventions
find_package(Boost REQUIRED COMPONENTS system)
Uncomment this if the package has a setup.py. This macro ensures
modules and global scripts declared therein get installed
See http://ros.org/doc/api/catkin/html/user_guide/setup_dot_py.html
catkin_python_setup()
Asked by Vini71 on 2019-06-21 13:14:42 UTC
The terminal error is below:
In file included from /home/marcus/catkin_ws/src/seven_dof_arm_test/src/test_random.cpp:4:0: /opt/ros/kinetic/include/moveit/move_group_interface/move_group.h:43:2: warning: #warning "This header is deprecated and will go away in ROS lunar." "Please use moveit/move_group_interface/move_group_interface.h" "and the class MoveGroupInterface instead of MoveGroup" [-Wcpp] #warning "This header is deprecated and will go away in ROS lunar."\ ^ /home/marcus/catkin_ws/src/seven_dof_arm_test/src/test_random.cpp: In function ‘int main(int, char**)’: /home/marcus/catkin_ws/src/seven_dof_arm_test/src/test_random.cpp:9:6: error: ‘AsyncSpinner’ was not declared in this scope ros:AsyncSpinner async_spinner(1); ^ /home/marcus/catkin_ws/src/seven_dof_arm_test/src/test_random.cpp:9:6: note: suggested alternative: In file included from /opt/ros/kinetic/include/ros/node_handle.h:46:0, from /opt/ros/kinetic/include/ros/ros.h:45, from
Asked by Vini71 on 2019-06-21 13:15:30 UTC
And finally my test_random.cpp is below:
//Movelt! header file
include
include
include
int main(int argc, char **argv) { ros::init(argc, argv, "test_random_node", ros::init_options::AnonymousName); //start a ROS spinning thread ros:AsyncSpinner async_spinner(1); spinner.start(); //this connects to a running instance of the move_group node //Here the Planning group is "arm" moveit::planning_interface::MoveGroupInterface move_group("arm"); //move_group_interface::MoveGroupInterface move_group("arm"); //Specify that our target will be a random one group.setRandomTarget(); //plan the motion and then move the group to the sampled target group.move(); ros::waitForShutdown();
Asked by Vini71 on 2019-06-21 13:16:05 UTC
@marcusvini178 please don't use comments to give more code. That's not what they're for (plus it's completely unreadable)
Asked by jayess on 2019-06-21 17:17:58 UTC