Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Servo] Refactoring servo #2224

Merged
merged 55 commits into from
Aug 7, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
55 commits
Select commit Hold shift + click to select a range
8050f38
Add C++ APIs: JointJog, Twist and Pose
ibrahiminfinite Jun 3, 2023
dd33754
Rewrite collision monitor
ibrahiminfinite Jun 8, 2023
57fffac
Improve pose tracking + address review comments
ibrahiminfinite Jun 9, 2023
5d73ad7
Squash updates
ibrahiminfinite Jun 12, 2023
2de4c33
Update pose demo and non planning frame command tests
ibrahiminfinite Jun 26, 2023
1008a0e
Refactor command processing into free functions
ibrahiminfinite Jun 28, 2023
965bc5c
Remove tests for wrong frame
ibrahiminfinite Jun 28, 2023
1992189
Singularity scaling does not need joint model group as arg
ibrahiminfinite Jun 28, 2023
b63d0b6
Readablity renaming
ibrahiminfinite Jun 28, 2023
00081cb
Add ROS API for jointjog, twist and pose
ibrahiminfinite Jul 1, 2023
5e2b211
ROS API updates
ibrahiminfinite Jul 2, 2023
6684095
Stop pose tracking on command switch
ibrahiminfinite Jul 2, 2023
0c1ee22
Remove unused launch file
ibrahiminfinite Jul 7, 2023
e4029d8
Remove test dependency on node
ibrahiminfinite Jul 7, 2023
47f7db5
Make util tests self contained
ibrahiminfinite Jul 7, 2023
c1ec27e
Add integration tests for C++ API
ibrahiminfinite Jul 7, 2023
67e1be3
start/stop collision checking with pause service
ibrahiminfinite Jul 14, 2023
90441e7
Improve dynamic pose tracking + review suggestions.
ibrahiminfinite Jul 14, 2023
9772b38
Increase twist + bug fix
ibrahiminfinite Jul 15, 2023
72a5137
Fix pre-commit edit
ibrahiminfinite Jul 15, 2023
a9d5edc
Review updates 1
ibrahiminfinite Jul 17, 2023
1feb399
Add support for unitless commands
ibrahiminfinite Jul 17, 2023
5abc826
Update tests to include unitless computation
ibrahiminfinite Jul 17, 2023
84511ed
Add support for realtime kernel
ibrahiminfinite Jul 17, 2023
95bdaba
ROS API updates
ibrahiminfinite Jul 17, 2023
345bec0
Disable copy construction and assignment
ibrahiminfinite Jul 17, 2023
6c525ef
Make servo responsive to model group change, remove robot specific da…
ibrahiminfinite Jul 18, 2023
2575b5f
Fix collision checking
ibrahiminfinite Jul 18, 2023
25b99d6
Remove unused keycode
ibrahiminfinite Jul 18, 2023
7358d68
Add ROS API tests
ibrahiminfinite Jul 25, 2023
df619c7
Review updates
ibrahiminfinite Jul 27, 2023
63229e6
Make ServoNode a component
ibrahiminfinite Jul 27, 2023
b43abf8
Review updates
ibrahiminfinite Jul 28, 2023
0673950
Comment fix
ibrahiminfinite Jul 28, 2023
e28d088
Review updates
ibrahiminfinite Jul 28, 2023
e45e963
Fix jointjog command conversion
ibrahiminfinite Jul 31, 2023
5b26b05
Add frame transfrom for twist
ibrahiminfinite Aug 1, 2023
99d9805
Add frame transform for pose
ibrahiminfinite Aug 1, 2023
f0b7fdc
Use active joint models
ibrahiminfinite Aug 2, 2023
e5ccdf2
formatting
ibrahiminfinite Aug 2, 2023
a8fa042
Fix command processing condition
ibrahiminfinite Aug 2, 2023
dc1cb30
Definie linear and angular step outside loop in pose demo
ibrahiminfinite Aug 2, 2023
70c06ea
Latch command + smooth halt
ibrahiminfinite Aug 3, 2023
d524172
Minor updates
ibrahiminfinite Aug 3, 2023
78f5c43
Exception handling for transfrom
ibrahiminfinite Aug 3, 2023
7dfe3de
Fix timeout behaviour
ibrahiminfinite Aug 4, 2023
7d5a9d6
Update ROS API tests
ibrahiminfinite Aug 4, 2023
46a9ead
Fail test if joint_state not available
ibrahiminfinite Aug 4, 2023
a1024a3
Stop publishing after smooth halt
ibrahiminfinite Aug 4, 2023
061fb69
Update tests + clang-tidy
ibrahiminfinite Aug 5, 2023
83a11c4
More clang-tidy
ibrahiminfinite Aug 6, 2023
710eb64
Update moveit_msgs repo
ibrahiminfinite Aug 6, 2023
2ee77d3
Add comment for component interface
ibrahiminfinite Aug 6, 2023
eda3133
Fix NOLINT in header
sea-bass Aug 7, 2023
b40a11d
Log halting only while stopping and with debug level
sea-bass Aug 7, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
157 changes: 62 additions & 95 deletions moveit_ros/moveit_servo/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ moveit_package()

set(THIS_PACKAGE_INCLUDE_DEPENDS
control_msgs
control_toolbox
geometry_msgs
moveit_core
moveit_msgs
Expand Down Expand Up @@ -42,60 +41,59 @@ include_directories(
# This library provides a way of loading parameters for servo
generate_parameter_library(
moveit_servo_lib_parameters
src/servo_parameters.yaml
config/servo_parameters.yaml
)

# This library provides a C++ interface for sending realtime twist or joint commands to a robot
add_library(moveit_servo_lib SHARED
src/collision_check.cpp
add_library(moveit_servo_lib_cpp SHARED
src/collision_monitor.cpp
src/servo.cpp
src/servo_calcs.cpp
src/utilities.cpp
)
set_target_properties(moveit_servo_lib PROPERTIES VERSION "${moveit_servo_VERSION}")
ament_target_dependencies(moveit_servo_lib ${THIS_PACKAGE_INCLUDE_DEPENDS})
target_link_libraries(moveit_servo_lib moveit_servo_lib_parameters)
src/utils/common.cpp
src/utils/command.cpp

add_library(pose_tracking SHARED src/pose_tracking.cpp)
ament_target_dependencies(pose_tracking ${THIS_PACKAGE_INCLUDE_DEPENDS})
target_link_libraries(pose_tracking moveit_servo_lib)
)
set_target_properties(moveit_servo_lib_cpp PROPERTIES VERSION "${moveit_servo_VERSION}")
target_link_libraries(moveit_servo_lib_cpp moveit_servo_lib_parameters)
ament_target_dependencies(moveit_servo_lib_cpp ${THIS_PACKAGE_INCLUDE_DEPENDS})

#####################
## Component Nodes ##
#####################
add_library(moveit_servo_lib_ros SHARED src/servo_node.cpp)
set_target_properties(moveit_servo_lib_ros PROPERTIES VERSION "${moveit_servo_VERSION}")
target_link_libraries(moveit_servo_lib_ros moveit_servo_lib_cpp)
ament_target_dependencies(moveit_servo_lib_ros ${THIS_PACKAGE_INCLUDE_DEPENDS})

# Add and export library to run as a ROS node component, and receive commands via topics
add_library(servo_node SHARED src/servo_node.cpp)
ament_target_dependencies(servo_node ${THIS_PACKAGE_INCLUDE_DEPENDS})
target_link_libraries(servo_node moveit_servo_lib)
rclcpp_components_register_nodes(servo_node "moveit_servo::ServoNode")
######################
## Components ##
######################

# Add executable for using a controller
add_library(servo_controller_input SHARED src/teleop_demo/joystick_servo_example.cpp)
ament_target_dependencies(servo_controller_input PUBLIC ${THIS_PACKAGE_INCLUDE_DEPENDS})
rclcpp_components_register_nodes(servo_controller_input "moveit_servo::JoyToServoPub")
rclcpp_components_register_node(
moveit_servo_lib_ros
PLUGIN "moveit_servo::ServoNode"
EXECUTABLE servo_node
)

######################
## Executable Nodes ##
######################

# An executable node for the servo server
add_executable(servo_node_main src/servo_node_main.cpp)
target_link_libraries(servo_node_main servo_node)
ament_target_dependencies(servo_node_main ${THIS_PACKAGE_INCLUDE_DEPENDS})
# Executable node for the joint jog demo
add_executable(demo_joint_jog demos/cpp_interface/demo_joint_jog.cpp )
target_link_libraries(demo_joint_jog moveit_servo_lib_cpp)
ament_target_dependencies(demo_joint_jog ${THIS_PACKAGE_INCLUDE_DEPENDS})

# An example of pose tracking
add_executable(servo_pose_tracking_demo src/cpp_interface_demo/pose_tracking_demo.cpp)
target_link_libraries(servo_pose_tracking_demo pose_tracking)
ament_target_dependencies(servo_pose_tracking_demo ${THIS_PACKAGE_INCLUDE_DEPENDS})
# Executable node for the twist demo
add_executable(demo_twist demos/cpp_interface/demo_twist.cpp )
target_link_libraries(demo_twist moveit_servo_lib_cpp)
ament_target_dependencies(demo_twist ${THIS_PACKAGE_INCLUDE_DEPENDS})

# Add executable to publish fake servo commands for testing/demo purposes
add_executable(fake_command_publisher test/publish_fake_jog_commands.cpp)
ament_target_dependencies(fake_command_publisher
rclcpp
geometry_msgs
std_srvs
)
# Executable node for the pose demo
add_executable(demo_pose demos/cpp_interface/demo_pose.cpp )
target_link_libraries(demo_pose moveit_servo_lib_cpp)
ament_target_dependencies(demo_pose ${THIS_PACKAGE_INCLUDE_DEPENDS})

# Keyboard control example for servo
add_executable(servo_keyboard_input demos/servo_keyboard_input.cpp)
target_include_directories(servo_keyboard_input PUBLIC include)
ament_target_dependencies(servo_keyboard_input ${THIS_PACKAGE_INCLUDE_DEPENDS})

#############
## Install ##
Expand All @@ -104,11 +102,9 @@ ament_target_dependencies(fake_command_publisher
# Install Libraries
install(
TARGETS
moveit_servo_lib
moveit_servo_lib_cpp
moveit_servo_lib_ros
moveit_servo_lib_parameters
pose_tracking
servo_node
servo_controller_input
EXPORT moveit_servoTargets
LIBRARY DESTINATION lib
ARCHIVE DESTINATION lib
Expand All @@ -119,9 +115,11 @@ install(
# Install Binaries
install(
TARGETS
servo_node_main
servo_pose_tracking_demo
fake_command_publisher
demo_joint_jog
demo_twist
demo_pose
servo_node
servo_keyboard_input
ARCHIVE DESTINATION lib
LIBRARY DESTINATION lib
RUNTIME DESTINATION lib/moveit_servo
Expand All @@ -135,56 +133,25 @@ install(DIRECTORY config DESTINATION share/moveit_servo)
ament_export_targets(moveit_servoTargets HAS_LIBRARY_TARGET)
ament_export_dependencies(${THIS_PACKAGE_INCLUDE_DEPENDS})

#############
## TESTING ##
#############

if(BUILD_TESTING)
find_package(ament_lint_auto REQUIRED)
find_package(ament_cmake_gtest REQUIRED)
find_package(ros_testing REQUIRED)
find_package(Boost REQUIRED COMPONENTS filesystem)

# These don't pass yet, disable them for now
set(ament_cmake_copyright_FOUND TRUE)
set(ament_cmake_cpplint_FOUND TRUE)
set(ament_cmake_flake8_FOUND TRUE)
set(ament_cmake_uncrustify_FOUND TRUE)

# Run all lint tests in package.xml except those listed above
ament_lint_auto_find_test_dependencies()

# Servo integration launch test
ament_add_gtest_executable(test_servo_integration
test/test_servo_interface.cpp
test/servo_launch_test_common.hpp
)
target_link_libraries(test_servo_integration moveit_servo_lib_parameters)
ament_target_dependencies(test_servo_integration ${THIS_PACKAGE_INCLUDE_DEPENDS})
add_ros_test(test/launch/test_servo_integration.test.py TIMEOUT 120 ARGS "test_binary_dir:=${CMAKE_CURRENT_BINARY_DIR}")

# Servo collision checking integration test
ament_add_gtest_executable(test_servo_collision
test/test_servo_collision.cpp
test/servo_launch_test_common.hpp
)
target_link_libraries(test_servo_collision moveit_servo_lib_parameters)
ament_target_dependencies(test_servo_collision ${THIS_PACKAGE_INCLUDE_DEPENDS})
add_ros_test(test/launch/test_servo_collision.test.py TIMEOUT 120 ARGS "test_binary_dir:=${CMAKE_CURRENT_BINARY_DIR}")

# pose_tracking
ament_add_gtest_executable(test_servo_pose_tracking
test/pose_tracking_test.cpp
)
ament_target_dependencies(test_servo_pose_tracking ${THIS_PACKAGE_INCLUDE_DEPENDS})
target_link_libraries(test_servo_pose_tracking pose_tracking)
add_ros_test(test/launch/test_servo_pose_tracking.test.py TIMEOUT 120 ARGS "test_binary_dir:=${CMAKE_CURRENT_BINARY_DIR}")

# Unit tests
ament_add_gtest(servo_calcs_unit_tests
test/servo_calcs_unit_tests.cpp
)
target_link_libraries(servo_calcs_unit_tests moveit_servo_lib)

find_package(ament_cmake_gtest REQUIRED)
find_package(ros_testing REQUIRED)

ament_add_gtest_executable(moveit_servo_utils_test tests/test_utils.cpp)
target_link_libraries(moveit_servo_utils_test moveit_servo_lib_cpp)
ament_target_dependencies(moveit_servo_utils_test ${THIS_PACKAGE_INCLUDE_DEPENDS})
add_ros_test(tests/launch/servo_utils.test.py TIMEOUT 30 ARGS "test_binary_dir:=${CMAKE_CURRENT_BINARY_DIR}")

ament_add_gtest_executable(moveit_servo_cpp_integration_test tests/test_integration.cpp tests/servo_cpp_fixture.hpp)
target_link_libraries(moveit_servo_cpp_integration_test moveit_servo_lib_cpp)
ament_target_dependencies(moveit_servo_cpp_integration_test ${THIS_PACKAGE_INCLUDE_DEPENDS})
add_ros_test(tests/launch/servo_cpp_integration.test.py TIMEOUT 30 ARGS "test_binary_dir:=${CMAKE_CURRENT_BINARY_DIR}")

ament_add_gtest_executable(moveit_servo_ros_integration_test tests/test_ros_integration.cpp tests/servo_ros_fixture.hpp)
ament_target_dependencies(moveit_servo_ros_integration_test ${THIS_PACKAGE_INCLUDE_DEPENDS})
add_ros_test(tests/launch/servo_ros_integration.test.py TIMEOUT 120 ARGS "test_binary_dir:=${CMAKE_CURRENT_BINARY_DIR}")

endif()

Expand Down
2 changes: 1 addition & 1 deletion moveit_ros/moveit_servo/config/demo_rviz_config.rviz
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ Visualization Manager:
Enabled: true
Move Group Namespace: ""
Name: PlanningScene
Planning Scene Topic: /servo_node/publish_planning_scene
Planning Scene Topic: /moveit_servo_demo/publish_planning_scene
Robot Description: robot_description
Scene Geometry:
Scene Alpha: 0.8999999761581421
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ Visualization Manager:
Enabled: true
Move Group Namespace: ""
Name: PlanningScene
Planning Scene Topic: /monitored_planning_scene
Planning Scene Topic: /servo_node/publish_planning_scene
Robot Description: robot_description
Scene Geometry:
Scene Alpha: 0.8999999761581421
Expand Down
23 changes: 9 additions & 14 deletions moveit_ros/moveit_servo/config/panda_simulated_config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,22 +2,20 @@
# Modify all parameters related to servoing here
###############################################

## Properties of incoming commands
command_in_type: "unitless" # "unitless"> in the range [-1:1], as if from joystick. "speed_units"> cmds are in m/s and rad/s
# Optionally override Servo's internal velocity scaling when near singularity or collision (0.0 = use internal velocity scaling)
# override_velocity_scaling_factor = 0.0 # valid range [0.0:1.0]

## Properties of outgoing commands
publish_period: 0.034 # 1/Nominal publish rate [seconds]

command_in_type: "speed_units" # "unitless"> in the range [-1:1], as if from joystick. "speed_units"> cmds are in m/s and rad/s
scale:
# Scale parameters are only used if command_in_type=="unitless"
linear: 0.4 # Max linear velocity. Unit is [m/s]. Only used for Cartesian commands.
rotational: 0.8 # Max angular velocity. Unit is [rad/s]. Only used for Cartesian commands.
# Max joint angular/linear velocity. Only used for joint commands on joint_command_in_topic.
joint: 0.5

# Optionally override Servo's internal velocity scaling when near singularity or collision (0.0 = use internal velocity scaling)
# override_velocity_scaling_factor = 0.0 # valid range [0.0:1.0]

## Properties of outgoing commands
publish_period: 0.034 # 1/Nominal publish rate [seconds]
low_latency_mode: false # Set this to true to publish as soon as an incoming Twist command is received (publish_period is ignored)

# What type of topic does your robot driver expect?
# Currently supported are std_msgs/Float64MultiArray or trajectory_msgs/JointTrajectory
command_out_type: trajectory_msgs/JointTrajectory
Expand All @@ -28,6 +26,7 @@ publish_joint_velocities: true
publish_joint_accelerations: false

## Plugins for smoothing outgoing commands
use_smoothing: true
smoothing_filter_plugin_name: "online_signal_smoothing::ButterworthFilterPlugin"

# If is_primary_planning_scene_monitor is set to true, the Servo server's PlanningScene advertises the /get_planning_scene service,
Expand All @@ -41,11 +40,7 @@ move_group_name: panda_arm # Often 'manipulator' or 'arm'
planning_frame: panda_link0 # The MoveIt planning frame. Often 'base_link' or 'world'

## Other frames
ee_frame_name: panda_link8 # The name of the end effector link, used to return the EE pose
robot_link_command_frame: panda_link0 # commands must be given in the frame of a robot link. Usually either the base or end effector

## Stopping behaviour
incoming_command_timeout: 0.1 # Stop servoing if X seconds elapse without a new command
ee_frame: panda_link8 # The name of the end effector link, used to return the EE pose

## Configure handling of singularities and joint limits
lower_singularity_threshold: 17.0 # Start decelerating when the condition number hits this (close to singularity)
Expand Down
21 changes: 0 additions & 21 deletions moveit_ros/moveit_servo/config/pose_tracking_settings.yaml

This file was deleted.

Loading