Hello, I have a problem with the manual service server call that should be programmed for the quiz.
I tried manually calling the server with the following command in order to see if I had properly programmed the server:
When i check which type the interface has it returns the following:
user:~/ros2_ws$ ros2 interface show services_quiz_srv/srv/Spin
string direction # Direction to spin (right or left)
float64 angular_velocity # Angular Velocity (in rad/s)
int32 time # Duration of the spin (in seconds)
---
bool success # Did it achieve it?
user:~/ros2_ws$ ros2 service list -t | grep rotate
/rotate [services_quiz_srv/srv/Spin]
Here is a part of the cpp file with the first part of the class:
user:~/ros2_ws$ ros2 service call /rotate
--rate -r services_quiz_srv/srv/Spin
also here the output:
user:~/ros2_ws$ ros2 service info /rotate
usage: ros2 service [-h] [--include-hidden-services] Call `ros2 service <command> -h` for more detailed usage. ...
ros2 service: error: argument Call `ros2 service <command> -h` for more detailed usage.: invalid choice: 'info' (choose from 'call', 'find', 'list', 'type')
Yes, you are right; the source command was wrong. It is the one you suggested.
Quick question - are you sure your package was properly built? Are you able to call the service within your service client?
Before I program the client, I wanted to test this first. I thought that would work.
I can launch the server node:
user:~/ros2_ws$ ros2 launch services_quiz services_quiz_server.launch.py
[INFO] [launch]: All log files can be found below /home/user/.ros/log/2023-04-26-10-57-38-932745-1_xterm-31715
[INFO] [launch]: Default logging verbosity is set to INFO
[INFO] [spin_robot_server_node-1]: process started with pid [31716]
I am running again into problems when loading the course to continue working on it. Had this issue several times now. Do you know what problem causes this?
You can see in the picture below, that the workspace / vs code isnât loading properlyâŠ
I checked again my Spin.srv and the corresponding package.xml and CMakeLists.txt. They are now looking like the following:
Spin.srv:
string direction # Direction to spin (right or left)
float64 angular_velocity # Angular Velocity (in rad/s)
int32 time # Duration of the spin (in seconds)
---
bool success # Did it achieve it?
cmake_minimum_required(VERSION 3.5)
project(services_quiz_srv)
# Default to C99
if(NOT CMAKE_C_STANDARD)
set(CMAKE_C_STANDARD 99)
endif()
# Default to C++14
if(NOT CMAKE_CXX_STANDARD)
set(CMAKE_CXX_STANDARD 14)
endif()
if(CMAKE_COMPILER_IS_GNUCXX OR CMAKE_CXX_COMPILER_ID MATCHES "Clang")
add_compile_options(-Wall -Wextra -Wpedantic)
endif()
# find dependencies
find_package(ament_cmake REQUIRED)
find_package(rclcpp REQUIRED)
find_package(std_msgs REQUIRED)
find_package(rosidl_default_generators REQUIRED)
if(BUILD_TESTING)
find_package(ament_lint_auto REQUIRED)
# the following line skips the linter which checks for copyrights
# comment the line when a copyright and license is added to all source files
set(ament_cmake_copyright_FOUND TRUE)
# the following line skips cpplint (only works in a git repo)
# comment the line when this package is in a git repo and when
# a copyright and license is added to all source files
set(ament_cmake_cpplint_FOUND TRUE)
ament_lint_auto_find_test_dependencies()
endif()
rosidl_generate_interfaces(${PROJECT_NAME}
"srv/Spin.srv"
)
ament_package()
After the succesful build, when i do âtab tabâ after i typed in the command: ros2 service call /rotate services_quiz_srv/srv/Spin
the following is returned: