Skip to content

Commit

Permalink
[Servo] Update servo tutorials for refactor (#734)
Browse files Browse the repository at this point in the history
  • Loading branch information
ibrahiminfinite committed Aug 8, 2023
1 parent 93675a1 commit 3e38458
Show file tree
Hide file tree
Showing 9 changed files with 728 additions and 749 deletions.
13 changes: 4 additions & 9 deletions doc/examples/realtime_servo/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,15 +1,10 @@
add_executable(servo_keyboard_input src/servo_keyboard_input.cpp)
target_include_directories(servo_keyboard_input PUBLIC include)
ament_target_dependencies(servo_keyboard_input ${THIS_PACKAGE_INCLUDE_DEPENDS})

add_executable(servo_cpp_interface_demo src/servo_cpp_interface_demo.cpp)
target_include_directories(servo_cpp_interface_demo PUBLIC include)
ament_target_dependencies(servo_cpp_interface_demo ${THIS_PACKAGE_INCLUDE_DEPENDS})
add_executable(pose_tracking_tutorial src/pose_tracking_tutorial.cpp)
target_include_directories(pose_tracking_tutorial PUBLIC include)
ament_target_dependencies(pose_tracking_tutorial ${THIS_PACKAGE_INCLUDE_DEPENDS})

install(
TARGETS
servo_keyboard_input
servo_cpp_interface_demo
pose_tracking_tutorial
DESTINATION
lib/${PROJECT_NAME}
)
Expand Down
60 changes: 42 additions & 18 deletions doc/examples/realtime_servo/config/demo_rviz_config.rviz
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,10 @@ Panels:
Expanded:
- /Global Options1
- /Status1
- /TF1/Frames1
- /MarkerArray1
Splitter Ratio: 0.5
Tree Height: 628
Tree Height: 549
- Class: rviz_common/Selection
Name: Selection
- Class: rviz_common/Tool Properties
Expand All @@ -21,6 +23,11 @@ Panels:
- /Current View1
Name: Views
Splitter Ratio: 0.5
- Class: rviz_common/Time
Experimental: false
Name: Time
SyncMode: 0
SyncSource: ""
Visualization Manager:
Class: ""
Displays:
Expand All @@ -46,12 +53,12 @@ Visualization Manager:
Enabled: true
Move Group Namespace: ""
Name: PlanningScene
Planning Scene Topic: /moveit_servo/publish_planning_scene
Planning Scene Topic: /servo_node/publish_planning_scene
Robot Description: robot_description
Scene Geometry:
Scene Alpha: 0.8999999761581421
Scene Color: 50; 230; 50
Scene Display Time: 0.20000000298023224
Scene Display Time: 0.009999999776482582
Show Scene Geometry: true
Voxel Coloring: Z-Axis
Voxel Rendering: Occupied Voxels
Expand Down Expand Up @@ -136,7 +143,7 @@ Visualization Manager:
panda_leftfinger:
Value: false
panda_link0:
Value: false
Value: true
panda_link1:
Value: false
panda_link2:
Expand All @@ -156,7 +163,7 @@ Visualization Manager:
panda_rightfinger:
Value: false
world:
Value: true
Value: false
Marker Scale: 1
Name: TF
Show Arrows: true
Expand All @@ -180,6 +187,18 @@ Visualization Manager:
{}
Update Interval: 0
Value: true
- Class: rviz_default_plugins/MarkerArray
Enabled: true
Name: MarkerArray
Namespaces:
{}
Topic:
Depth: 5
Durability Policy: Volatile
History Policy: Keep Last
Reliability Policy: Reliable
Value: /path_markers
Value: true
Enabled: true
Global Options:
Background Color: 48; 48; 48
Expand All @@ -195,6 +214,9 @@ Visualization Manager:
- Class: rviz_default_plugins/Measure
Line color: 128; 128; 0
- Class: rviz_default_plugins/SetInitialPose
Covariance x: 0.25
Covariance y: 0.25
Covariance yaw: 0.06853891909122467
Topic:
Depth: 5
Durability Policy: Volatile
Expand Down Expand Up @@ -223,39 +245,41 @@ Visualization Manager:
Views:
Current:
Class: rviz_default_plugins/Orbit
Distance: 2.155569553375244
Distance: 4.086756229400635
Enable Stereo Rendering:
Stereo Eye Separation: 0.05999999865889549
Stereo Focal Distance: 1
Swap Stereo Eyes: false
Value: false
Focal Point:
X: -0.08608254045248032
Y: -0.20677587389945984
Z: 0.3424459993839264
X: 0
Y: 0
Z: 0
Focal Shape Fixed Size: true
Focal Shape Size: 0.05000000074505806
Invert Z Axis: false
Name: Current View
Near Clip Distance: 0.009999999776482582
Pitch: 0.4603978991508484
Pitch: 0.785398006439209
Target Frame: <Fixed Frame>
Value: Orbit (rviz)
Yaw: 0.8753982782363892
Yaw: 0.785398006439209
Saved: ~
Window Geometry:
Displays:
collapsed: false
Height: 857
Height: 846
Hide Left Dock: false
Hide Right Dock: true
QMainWindow State: 000000ff00000000fd000000040000000000000216000002fffc020000000afb0000001200530065006c0065006300740069006f006e00000001e10000009b0000005c00fffffffb0000001e0054006f006f006c002000500072006f007000650072007400690065007302000001ed000001df00000185000000a3fb000000120056006900650077007300200054006f006f02000001df000002110000018500000122fb000000200054006f006f006c002000500072006f0070006500720074006900650073003203000002880000011d000002210000017afb000000100044006900730070006c006100790073010000003d000002ff000000c900fffffffb0000002000730065006c0065006300740069006f006e00200062007500660066006500720200000138000000aa0000023a00000294fb00000014005700690064006500530074006500720065006f02000000e6000000d2000003ee0000030bfb0000000c004b0069006e0065006300740200000186000001060000030c00000261fb000000280020002d0020005400720061006a006500630074006f0072007900200053006c00690064006500720000000000ffffffff0000000000000000fb0000003c005400720061006a006500630074006f007200790020002d0020005400720061006a006500630074006f0072007900200053006c00690064006500720000000000ffffffff0000000000000000000000010000010f000002d2fc0200000003fb0000001e0054006f006f006c002000500072006f00700065007200740069006500730100000041000000780000000000000000fb0000000a00560069006500770073000000003d000002d2000000a400fffffffb0000001200530065006c0065006300740069006f006e010000025a000000b200000000000000000000000200000490000000a9fc0100000001fb0000000a00560069006500770073030000004e00000080000002e10000019700000003000004420000003efc0100000002fb0000000800540069006d00650100000000000004420000000000000000fb0000000800540069006d0065010000000000000450000000000000000000000416000002ff00000004000000040000000800000008fc0000000100000002000000010000000a0054006f006f006c00730100000000ffffffff0000000000000000
Hide Right Dock: false
QMainWindow State: 000000ff00000000fd000000040000000000000156000002b0fc0200000008fb0000001200530065006c0065006300740069006f006e00000001e10000009b0000005c00fffffffb0000001e0054006f006f006c002000500072006f007000650072007400690065007302000001ed000001df00000185000000a3fb000000120056006900650077007300200054006f006f02000001df000002110000018500000122fb000000200054006f006f006c002000500072006f0070006500720074006900650073003203000002880000011d000002210000017afb000000100044006900730070006c006100790073010000003d000002b0000000c900fffffffb0000002000730065006c0065006300740069006f006e00200062007500660066006500720200000138000000aa0000023a00000294fb00000014005700690064006500530074006500720065006f02000000e6000000d2000003ee0000030bfb0000000c004b0069006e0065006300740200000186000001060000030c00000261000000010000010f000002b0fc0200000003fb0000001e0054006f006f006c002000500072006f00700065007200740069006500730100000041000000780000000000000000fb0000000a00560069006500770073010000003d000002b0000000a400fffffffb0000001200530065006c0065006300740069006f006e010000025a000000b200000000000000000000000200000490000000a9fc0100000001fb0000000a00560069006500770073030000004e00000080000002e10000019700000003000004b00000003efc0100000002fb0000000800540069006d00650100000000000004b0000002fb00fffffffb0000000800540069006d006501000000000000045000000000000000000000023f000002b000000004000000040000000800000008fc0000000100000002000000010000000a0054006f006f006c00730100000000ffffffff0000000000000000
Selection:
collapsed: false
Time:
collapsed: false
Tool Properties:
collapsed: false
Views:
collapsed: true
Width: 1586
X: 1179
Y: 393
collapsed: false
Width: 1200
X: 74
Y: 60
62 changes: 62 additions & 0 deletions doc/examples/realtime_servo/config/panda_simulated_config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
###############################################
# Modify all parameters related to servoing here
###############################################

# 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

# 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

# What to publish? Can save some bandwidth as most robots only require positions or velocities
publish_joint_positions: true
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,
# which other nodes can use as a source for information about the planning environment.
# NOTE: If a different node in your system is responsible for the "primary" planning scene instance (e.g. the MoveGroup node),
# then is_primary_planning_scene_monitor needs to be set to false.
is_primary_planning_scene_monitor: true

## MoveIt properties
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: panda_hand # 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)
hard_stop_singularity_threshold: 30.0 # Stop when the condition number hits this
joint_limit_margin: 0.1 # added as a buffer to joint limits [radians]. If moving quickly, make this larger.
leaving_singularity_threshold_multiplier: 2.0 # Multiply the hard stop limit by this when leaving singularity.

## Topic names
cartesian_command_in_topic: ~/delta_twist_cmds # Topic for incoming Cartesian twist commands
joint_command_in_topic: ~/delta_joint_cmds # Topic for incoming joint angle commands
joint_topic: /joint_states
status_topic: ~/status # Publish status to this topic
command_out_topic: /panda_arm_controller/joint_trajectory # Publish outgoing commands here

## Collision checking for the entire robot body
check_collisions: true # Check collisions?
collision_check_rate: 10.0 # [Hz] Collision-checking can easily bog down a CPU if done too often.
self_collision_proximity_threshold: 0.01 # Start decelerating when a self-collision is this far [m]
scene_collision_proximity_threshold: 0.02 # Start decelerating when a scene collision is this far [m]
152 changes: 152 additions & 0 deletions doc/examples/realtime_servo/launch/pose_tracking_tutorial.launch.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,152 @@
import os
import launch
import launch_ros
from ament_index_python.packages import get_package_share_directory
from launch.conditions import IfCondition, UnlessCondition
from launch.substitutions import LaunchConfiguration
from launch_param_builder import ParameterBuilder
from moveit_configs_utils import MoveItConfigsBuilder


def generate_launch_description():
moveit_config = (
MoveItConfigsBuilder("moveit_resources_panda")
.robot_description(file_path="config/panda.urdf.xacro")
.to_moveit_configs()
)

# Launch Servo as a standalone node or as a "node component" for better latency/efficiency
launch_as_standalone_node = LaunchConfiguration(
"launch_as_standalone_node", default="false"
)

# Get parameters for the Servo node
servo_params = {
"moveit_servo": ParameterBuilder("moveit2_tutorials")
.yaml("config/panda_simulated_config.yaml")
.to_dict()
}

# This filter parameter should be >1. Increase it for greater smoothing but slower motion.
low_pass_filter_coeff = {"butterworth_filter_coeff": 1.5}

# RViz
rviz_config_file = (
get_package_share_directory("moveit2_tutorials")
+ "/config/demo_rviz_config.rviz"
)
rviz_node = launch_ros.actions.Node(
package="rviz2",
executable="rviz2",
name="rviz2",
output="log",
arguments=["-d", rviz_config_file],
parameters=[
moveit_config.robot_description,
moveit_config.robot_description_semantic,
],
)

# ros2_control using FakeSystem as hardware
ros2_controllers_path = os.path.join(
get_package_share_directory("moveit_resources_panda_moveit_config"),
"config",
"ros2_controllers.yaml",
)
ros2_control_node = launch_ros.actions.Node(
package="controller_manager",
executable="ros2_control_node",
parameters=[moveit_config.robot_description, ros2_controllers_path],
output="screen",
)

joint_state_broadcaster_spawner = launch_ros.actions.Node(
package="controller_manager",
executable="spawner",
arguments=[
"joint_state_broadcaster",
"--controller-manager-timeout",
"300",
"--controller-manager",
"/controller_manager",
],
)

panda_arm_controller_spawner = launch_ros.actions.Node(
package="controller_manager",
executable="spawner",
arguments=["panda_arm_controller", "-c", "/controller_manager"],
)

# Launch as much as possible in components
container = launch_ros.actions.ComposableNodeContainer(
name="moveit_servo_demo_container",
namespace="/",
package="rclcpp_components",
executable="component_container_mt",
composable_node_descriptions=[
# Example of launching Servo as a node component
# Launching as a node component makes ROS 2 intraprocess communication more efficient.
launch_ros.descriptions.ComposableNode(
package="moveit_servo",
plugin="moveit_servo::ServoNode",
name="servo_node",
parameters=[
servo_params,
low_pass_filter_coeff,
moveit_config.robot_description,
moveit_config.robot_description_semantic,
moveit_config.robot_description_kinematics,
],
condition=UnlessCondition(launch_as_standalone_node),
),
launch_ros.descriptions.ComposableNode(
package="robot_state_publisher",
plugin="robot_state_publisher::RobotStatePublisher",
name="robot_state_publisher",
parameters=[moveit_config.robot_description],
),
launch_ros.descriptions.ComposableNode(
package="tf2_ros",
plugin="tf2_ros::StaticTransformBroadcasterNode",
name="static_tf2_broadcaster",
parameters=[{"child_frame_id": "/panda_link0", "frame_id": "/world"}],
),
],
output="screen",
)
# Launch a standalone Servo node.
# As opposed to a node component, this may be necessary (for example) if Servo is running on a different PC
servo_node = launch_ros.actions.Node(
package="moveit_servo",
executable="servo_node",
name="servo_node",
parameters=[
servo_params,
low_pass_filter_coeff,
moveit_config.robot_description,
moveit_config.robot_description_semantic,
moveit_config.robot_description_kinematics,
],
output="screen",
condition=IfCondition(launch_as_standalone_node),
)

demo_node = launch_ros.actions.Node(
package="moveit2_tutorials",
executable="pose_tracking_tutorial",
name="pose_tracking_tutorial",
output="screen",
)

return launch.LaunchDescription(
[
rviz_node,
ros2_control_node,
joint_state_broadcaster_spawner,
panda_arm_controller_spawner,
servo_node,
container,
launch.actions.TimerAction(period=10.0, actions=[demo_node]),
]
)
Loading

0 comments on commit 3e38458

Please sign in to comment.