eager-dev / eager

[deprecated] Engine Agnostic Gym Environment for Robotics
https://eager-control.readthedocs.io/
Apache License 2.0
16 stars 0 forks source link

Melodic support of SafeActionsProcessor #110

Closed bheijden closed 3 years ago

bheijden commented 3 years ago

When running the SafeActionsProcessor in ROS melodic (with Anaconda3 virtual env), I get the following two error messages.

The first one does not seem to be critical. Do you have this one too @jelledouwe ?

[ERROR] [1622903159.406583466]: Failed to find 3D sensor plugin parameters for octomap generation
[ERROR] [1622903159.452137660]: Exception while loading move_group capability 'move_group/MoveGroupExecuteService': MultiLibraryClassLoader: Could not create object of class type move_group::MoveGroupExecuteService as no factory exists for it. Make sure that the library exists and was explicitly loaded through MultiLibraryClassLoader::loadLibrary()

The second error message below seems to break the node. This seems to be an issue related to python3 & python2 support with ROS Melodic (related issue). @AlexanderKeijzer Do you get this error message as well (you are also using ROS melodic without having it compiled specifically with Python3 support)?

Traceback (most recent call last):
  File "/home/bas/ros_gym_ws/src/ros-gym/eager_process_safe_actions/src/eager_process_safe_actions/safe_actions_node.py", line 4, in <module>
    from safe_actions import SafeActions
  File "/home/bas/PycharmProjects/ros-gym/eager_process_safe_actions/src/eager_process_safe_actions/safe_actions.py", line 3, in <module>
    import moveit_commander
  File "/opt/ros/melodic/lib/python2.7/dist-packages/moveit_commander/__init__.py", line 2, in <module>
    from .roscpp_initializer import *
  File "/opt/ros/melodic/lib/python2.7/dist-packages/moveit_commander/roscpp_initializer.py", line 35, in <module>
    from moveit_ros_planning_interface import _moveit_roscpp_initializer
ImportError: dynamic module does not define module export function (PyInit__moveit_roscpp_initializer)

Complete terminal output

/home/bas/anaconda3/envs/px150/bin/python /home/bas/PycharmProjects/ros-gym/examples/ur5e_example/scripts/preprocess_example.py
/home/bas/anaconda3/envs/px150/lib/python3.7/site-packages/gym/logger.py:30: UserWarning: WARN: Box bound precision lowered by casting to float32
  warnings.warn(colorize('%s: %s'%('WARN', msg % args), 'yellow'))
... logging to /home/bas/.ros/log/bdcac30e-c606-11eb-aad4-ac675d3b5380/roslaunch-bas-Alienware-m15-R2-25294.log
started roslaunch server http://192.168.68.113:38789/

SUMMARY
========

PARAMETERS
 * /rosdistro: melodic
 * /rosversion: 1.14.11

NODES
  /ros_env/
    physics_bridge (eager_bridge_webots/webots_node.py)

ROS_MASTER_URI=http://localhost:11311
process[ros_env/physics_bridge-1]: started with pid [25338]
... logging to /home/bas/.ros/log/bdcac30e-c606-11eb-aad4-ac675d3b5380/roslaunch-bas-Alienware-m15-R2-25338.log
started roslaunch server http://192.168.68.113:34639/

SUMMARY
========

PARAMETERS
 * /rosdistro: melodic
 * /rosversion: 1.14.11

NODES
  /ros_env/
    webots (webots_ros/webots_launcher.py)

ROS_MASTER_URI=http://localhost:11311
process[ros_env/webots-1]: started with pid [25359]
... logging to /home/bas/.ros/log/bdcac30e-c606-11eb-aad4-ac675d3b5380/roslaunch-bas-Alienware-m15-R2-25294.log
xacro: in-order processing became default in ROS Melodic. You can drop the option.
started roslaunch server http://192.168.68.113:46385/

SUMMARY
========

PARAMETERS
 * /ros_env/objects/ur5e1/joints/move_group/allow_trajectory_execution: False
 * /ros_env/objects/ur5e1/joints/move_group/capabilities: move_group/MoveGr...
 * /ros_env/objects/ur5e1/joints/move_group/endeffector/planner_configs: ['SBLkConfigDefau...
 * /ros_env/objects/ur5e1/joints/move_group/jiggle_fraction: 0.05
 * /ros_env/objects/ur5e1/joints/move_group/manipulator/default_planner_config: RRTConnectkConfig...
 * /ros_env/objects/ur5e1/joints/move_group/manipulator/longest_valid_segment_fraction: 0.01
 * /ros_env/objects/ur5e1/joints/move_group/manipulator/planner_configs: ['SBLkConfigDefau...
 * /ros_env/objects/ur5e1/joints/move_group/max_safe_path_cost: 1
 * /ros_env/objects/ur5e1/joints/move_group/planner_configs/BKPIECEkConfigDefault/border_fraction: 0.9
 * /ros_env/objects/ur5e1/joints/move_group/planner_configs/BKPIECEkConfigDefault/failed_expansion_score_factor: 0.5
 * /ros_env/objects/ur5e1/joints/move_group/planner_configs/BKPIECEkConfigDefault/min_valid_path_fraction: 0.5
 * /ros_env/objects/ur5e1/joints/move_group/planner_configs/BKPIECEkConfigDefault/range: 0.0
 * /ros_env/objects/ur5e1/joints/move_group/planner_configs/BKPIECEkConfigDefault/type: geometric::BKPIECE
 * /ros_env/objects/ur5e1/joints/move_group/planner_configs/ESTkConfigDefault/goal_bias: 0.05
 * /ros_env/objects/ur5e1/joints/move_group/planner_configs/ESTkConfigDefault/range: 0.0
 * /ros_env/objects/ur5e1/joints/move_group/planner_configs/ESTkConfigDefault/type: geometric::EST
 * /ros_env/objects/ur5e1/joints/move_group/planner_configs/KPIECEkConfigDefault/border_fraction: 0.9
 * /ros_env/objects/ur5e1/joints/move_group/planner_configs/KPIECEkConfigDefault/failed_expansion_score_factor: 0.5
 * /ros_env/objects/ur5e1/joints/move_group/planner_configs/KPIECEkConfigDefault/goal_bias: 0.05
 * /ros_env/objects/ur5e1/joints/move_group/planner_configs/KPIECEkConfigDefault/min_valid_path_fraction: 0.5
 * /ros_env/objects/ur5e1/joints/move_group/planner_configs/KPIECEkConfigDefault/range: 0.0
 * /ros_env/objects/ur5e1/joints/move_group/planner_configs/KPIECEkConfigDefault/type: geometric::KPIECE
 * /ros_env/objects/ur5e1/joints/move_group/planner_configs/LBKPIECEkConfigDefault/border_fraction: 0.9
 * /ros_env/objects/ur5e1/joints/move_group/planner_configs/LBKPIECEkConfigDefault/min_valid_path_fraction: 0.5
 * /ros_env/objects/ur5e1/joints/move_group/planner_configs/LBKPIECEkConfigDefault/range: 0.0
 * /ros_env/objects/ur5e1/joints/move_group/planner_configs/LBKPIECEkConfigDefault/type: geometric::LBKPIECE
 * /ros_env/objects/ur5e1/joints/move_group/planner_configs/PRMkConfigDefault/max_nearest_neighbors: 10
 * /ros_env/objects/ur5e1/joints/move_group/planner_configs/PRMkConfigDefault/type: geometric::PRM
 * /ros_env/objects/ur5e1/joints/move_group/planner_configs/PRMstarkConfigDefault/type: geometric::PRMstar
 * /ros_env/objects/ur5e1/joints/move_group/planner_configs/RRTConnectkConfigDefault/range: 0.0
 * /ros_env/objects/ur5e1/joints/move_group/planner_configs/RRTConnectkConfigDefault/type: geometric::RRTCon...
 * /ros_env/objects/ur5e1/joints/move_group/planner_configs/RRTkConfigDefault/goal_bias: 0.05
 * /ros_env/objects/ur5e1/joints/move_group/planner_configs/RRTkConfigDefault/range: 0.0
 * /ros_env/objects/ur5e1/joints/move_group/planner_configs/RRTkConfigDefault/type: geometric::RRT
 * /ros_env/objects/ur5e1/joints/move_group/planner_configs/RRTstarkConfigDefault/delay_collision_checking: 1
 * /ros_env/objects/ur5e1/joints/move_group/planner_configs/RRTstarkConfigDefault/goal_bias: 0.05
 * /ros_env/objects/ur5e1/joints/move_group/planner_configs/RRTstarkConfigDefault/range: 0.0
 * /ros_env/objects/ur5e1/joints/move_group/planner_configs/RRTstarkConfigDefault/type: geometric::RRTstar
 * /ros_env/objects/ur5e1/joints/move_group/planner_configs/SBLkConfigDefault/range: 0.0
 * /ros_env/objects/ur5e1/joints/move_group/planner_configs/SBLkConfigDefault/type: geometric::SBL
 * /ros_env/objects/ur5e1/joints/move_group/planner_configs/TRRTkConfigDefault/frountierNodeRatio: 0.1
 * /ros_env/objects/ur5e1/joints/move_group/planner_configs/TRRTkConfigDefault/frountier_threshold: 0.0
 * /ros_env/objects/ur5e1/joints/move_group/planner_configs/TRRTkConfigDefault/goal_bias: 0.05
 * /ros_env/objects/ur5e1/joints/move_group/planner_configs/TRRTkConfigDefault/init_temperature: 10e-6
 * /ros_env/objects/ur5e1/joints/move_group/planner_configs/TRRTkConfigDefault/k_constant: 0.0
 * /ros_env/objects/ur5e1/joints/move_group/planner_configs/TRRTkConfigDefault/max_states_failed: 10
 * /ros_env/objects/ur5e1/joints/move_group/planner_configs/TRRTkConfigDefault/min_temperature: 10e-10
 * /ros_env/objects/ur5e1/joints/move_group/planner_configs/TRRTkConfigDefault/range: 0.0
 * /ros_env/objects/ur5e1/joints/move_group/planner_configs/TRRTkConfigDefault/temp_change_factor: 2.0
 * /ros_env/objects/ur5e1/joints/move_group/planner_configs/TRRTkConfigDefault/type: geometric::TRRT
 * /ros_env/objects/ur5e1/joints/move_group/planning_plugin: ompl_interface/OM...
 * /ros_env/objects/ur5e1/joints/move_group/planning_scene_monitor/publish_geometry_updates: False
 * /ros_env/objects/ur5e1/joints/move_group/planning_scene_monitor/publish_planning_scene: False
 * /ros_env/objects/ur5e1/joints/move_group/planning_scene_monitor/publish_state_updates: False
 * /ros_env/objects/ur5e1/joints/move_group/planning_scene_monitor/publish_transforms_updates: False
 * /ros_env/objects/ur5e1/joints/move_group/request_adapters: default_planner_r...
 * /ros_env/objects/ur5e1/joints/move_group/start_state_max_bounds_error: 0.1
 * /ros_env/objects/ur5e1/joints/robot_description: <?xml version="1....
 * /ros_env/objects/ur5e1/joints/robot_description_kinematics/manipulator/kinematics_solver: kdl_kinematics_pl...
 * /ros_env/objects/ur5e1/joints/robot_description_kinematics/manipulator/kinematics_solver_attempts: 3
 * /ros_env/objects/ur5e1/joints/robot_description_kinematics/manipulator/kinematics_solver_search_resolution: 0.005
 * /ros_env/objects/ur5e1/joints/robot_description_kinematics/manipulator/kinematics_solver_timeout: 0.005
 * /ros_env/objects/ur5e1/joints/robot_description_planning/joint_limits/elbow_joint/has_acceleration_limits: True
 * /ros_env/objects/ur5e1/joints/robot_description_planning/joint_limits/elbow_joint/has_velocity_limits: True
 * /ros_env/objects/ur5e1/joints/robot_description_planning/joint_limits/elbow_joint/max_acceleration: 3.14
 * /ros_env/objects/ur5e1/joints/robot_description_planning/joint_limits/elbow_joint/max_velocity: 3.14
 * /ros_env/objects/ur5e1/joints/robot_description_planning/joint_limits/shoulder_lift_joint/has_acceleration_limits: True
 * /ros_env/objects/ur5e1/joints/robot_description_planning/joint_limits/shoulder_lift_joint/has_velocity_limits: True
 * /ros_env/objects/ur5e1/joints/robot_description_planning/joint_limits/shoulder_lift_joint/max_acceleration: 3.14
 * /ros_env/objects/ur5e1/joints/robot_description_planning/joint_limits/shoulder_lift_joint/max_velocity: 3.14
 * /ros_env/objects/ur5e1/joints/robot_description_planning/joint_limits/shoulder_pan_joint/has_acceleration_limits: True
 * /ros_env/objects/ur5e1/joints/robot_description_planning/joint_limits/shoulder_pan_joint/has_velocity_limits: True
 * /ros_env/objects/ur5e1/joints/robot_description_planning/joint_limits/shoulder_pan_joint/max_acceleration: 3.14
 * /ros_env/objects/ur5e1/joints/robot_description_planning/joint_limits/shoulder_pan_joint/max_velocity: 3.14
 * /ros_env/objects/ur5e1/joints/robot_description_planning/joint_limits/wrist_1_joint/has_acceleration_limits: True
 * /ros_env/objects/ur5e1/joints/robot_description_planning/joint_limits/wrist_1_joint/has_velocity_limits: True
 * /ros_env/objects/ur5e1/joints/robot_description_planning/joint_limits/wrist_1_joint/max_acceleration: 3.14
 * /ros_env/objects/ur5e1/joints/robot_description_planning/joint_limits/wrist_1_joint/max_velocity: 6.28
 * /ros_env/objects/ur5e1/joints/robot_description_planning/joint_limits/wrist_2_joint/has_acceleration_limits: True
 * /ros_env/objects/ur5e1/joints/robot_description_planning/joint_limits/wrist_2_joint/has_velocity_limits: True
 * /ros_env/objects/ur5e1/joints/robot_description_planning/joint_limits/wrist_2_joint/max_acceleration: 3.14
 * /ros_env/objects/ur5e1/joints/robot_description_planning/joint_limits/wrist_2_joint/max_velocity: 6.28
 * /ros_env/objects/ur5e1/joints/robot_description_planning/joint_limits/wrist_3_joint/has_acceleration_limits: True
 * /ros_env/objects/ur5e1/joints/robot_description_planning/joint_limits/wrist_3_joint/has_velocity_limits: True
 * /ros_env/objects/ur5e1/joints/robot_description_planning/joint_limits/wrist_3_joint/max_acceleration: 3.14
 * /ros_env/objects/ur5e1/joints/robot_description_planning/joint_limits/wrist_3_joint/max_velocity: 6.28
 * /ros_env/objects/ur5e1/joints/robot_description_semantic: <?xml version="1....
 * /ros_env/objects/ur5e1/joints/safe_actions/checks_per_rad: 15
 * /ros_env/objects/ur5e1/joints/safe_actions/duration: 0.1
 * /ros_env/objects/ur5e1/joints/safe_actions/group_name: manipulator
 * /ros_env/objects/ur5e1/joints/safe_actions/joint_names: ['shoulder_pan_jo...
 * /ros_env/objects/ur5e1/joints/safe_actions/object_frame: base_link
 * /ros_env/objects/ur5e1/joints/safe_actions/vel_limit: 3.0
 * /rosdistro: melodic
 * /rosversion: 1.14.11

NODES
  /ros_env/objects/ur5e1/joints/
    move_group (moveit_ros_move_group/move_group)
    safe_actions (eager_process_safe_actions/safe_actions_node.py)

ROS_MASTER_URI=http://localhost:11311
process[ros_env/objects/ur5e1/joints/move_group-2]: started with pid [25503]
process[ros_env/objects/ur5e1/joints/safe_actions-3]: started with pid [25504]
[ WARN] [1622903159.335239612]: Skipping virtual joint 'fixed_base' because its child frame 'base_link' does not match the URDF frame 'world'
[ WARN] [1622903159.365265829]: Kinematics solver doesn't support #attempts anymore, but only a timeout.
Please remove the parameter '/ros_env/objects/ur5e1/joints/robot_description_kinematics/manipulator/kinematics_solver_attempts' from your configuration.
[ WARN] [1622903159.406368437]: Resolution not specified for Octomap. Assuming resolution = 0.1 instead
[ERROR] [1622903159.406583466]: Failed to find 3D sensor plugin parameters for octomap generation
[ERROR] [1622903159.452137660]: Exception while loading move_group capability 'move_group/MoveGroupExecuteService': MultiLibraryClassLoader: Could not create object of class type move_group::MoveGroupExecuteService as no factory exists for it. Make sure that the library exists and was explicitly loaded through MultiLibraryClassLoader::loadLibrary()
[ INFO] [1622903159.334657969]: Loading robot model 'ur5e'...
[ INFO] [1622903159.335252074]: No root/virtual joint specified in SRDF. Assuming fixed joint
[ INFO] [1622903159.403055830]: MoveGroup debug mode is OFF
Starting planning scene monitors...
[ INFO] [1622903159.403072619]: Starting planning scene monitor
[ INFO] [1622903159.404104302]: Listening to '/ros_env/objects/ur5e1/joints/planning_scene'
[ INFO] [1622903159.404117060]: Starting world geometry update monitor for collision objects, attached objects, octomap updates.
[ INFO] [1622903159.405158334]: Listening to '/ros_env/objects/ur5e1/joints/collision_object'
[ INFO] [1622903159.406156842]: Listening to '/ros_env/objects/ur5e1/joints/planning_scene_world' for planning scene world geometry
[ INFO] [1622903159.411740803]: Listening to '/ros_env/objects/ur5e1/joints/attached_collision_object' for attached collision objects
Planning scene monitors started.
[ INFO] [1622903159.429821509]: Initializing OMPL interface using ROS parameters
[ INFO] [1622903159.441998964]: Using planning interface 'OMPL'
[ INFO] [1622903159.445198462]: Param 'default_workspace_bounds' was not set. Using default value: 10
[ INFO] [1622903159.445437122]: Param 'start_state_max_bounds_error' was set to 0.1
[ INFO] [1622903159.445687129]: Param 'start_state_max_dt' was not set. Using default value: 0.5
[ INFO] [1622903159.445908360]: Param 'start_state_max_dt' was not set. Using default value: 0.5
[ INFO] [1622903159.446131720]: Param 'jiggle_fraction' was set to 0.05
[ INFO] [1622903159.446374278]: Param 'max_sampling_attempts' was not set. Using default value: 100
[ INFO] [1622903159.446409946]: Using planning request adapter 'Add Time Parameterization'
[ INFO] [1622903159.446417354]: Using planning request adapter 'Fix Workspace Bounds'
[ INFO] [1622903159.446422001]: Using planning request adapter 'Fix Start State Bounds'
[ INFO] [1622903159.446429713]: Using planning request adapter 'Fix Start State In Collision'
[ INFO] [1622903159.446436497]: Using planning request adapter 'Fix Start State Path Constraints'
Loading 'move_group/ApplyPlanningSceneService'...
Loading 'move_group/ClearOctomapService'...
Loading 'move_group/MoveGroupCartesianPathService'...
Loading 'move_group/MoveGroupExecuteService'...
Loading 'move_group/MoveGroupExecuteTrajectoryAction'...
Loading 'move_group/MoveGroupGetPlanningSceneService'...
Loading 'move_group/MoveGroupKinematicsService'...
Loading 'move_group/MoveGroupMoveAction'...
Loading 'move_group/MoveGroupPickPlaceAction'...
Loading 'move_group/MoveGroupPlanService'...
Loading 'move_group/MoveGroupQueryPlannersService'...
Loading 'move_group/MoveGroupStateValidationService'...
[ INFO] [1622903159.475977433]: 

********************************************************
* MoveGroup using: 
*     - ApplyPlanningSceneService
*     - ClearOctomapService
*     - CartesianPathService
*     - ExecuteTrajectoryAction
*     - GetPlanningSceneService
*     - KinematicsService
*     - MoveAction
*     - PickPlaceAction
*     - MotionPlanService
*     - QueryPlannersService
*     - StateValidationService
********************************************************

[ INFO] [1622903159.476007177]: MoveGroup context using planning plugin ompl_interface/OMPLPlanner
[ INFO] [1622903159.476014724]: MoveGroup context initialization complete

You can start planning now!

Traceback (most recent call last):
  File "/home/bas/ros_gym_ws/src/ros-gym/eager_process_safe_actions/src/eager_process_safe_actions/safe_actions_node.py", line 4, in <module>
    from safe_actions import SafeActions
  File "/home/bas/PycharmProjects/ros-gym/eager_process_safe_actions/src/eager_process_safe_actions/safe_actions.py", line 3, in <module>
    import moveit_commander
  File "/opt/ros/melodic/lib/python2.7/dist-packages/moveit_commander/__init__.py", line 2, in <module>
    from .roscpp_initializer import *
  File "/opt/ros/melodic/lib/python2.7/dist-packages/moveit_commander/roscpp_initializer.py", line 35, in <module>
    from moveit_ros_planning_interface import _moveit_roscpp_initializer
ImportError: dynamic module does not define module export function (PyInit__moveit_roscpp_initializer)
[ros_env/objects/ur5e1/joints/safe_actions-3] process has died [pid 25504, exit code 1, cmd /home/bas/ros_gym_ws/src/ros-gym/eager_process_safe_actions/src/eager_process_safe_actions/safe_actions_node.py __name:=safe_actions __log:=/home/bas/.ros/log/bdcac30e-c606-11eb-aad4-ac675d3b5380/ros_env-objects-ur5e1-joints-safe_actions-3.log].
log file: /home/bas/.ros/log/bdcac30e-c606-11eb-aad4-ac675d3b5380/ros_env-objects-ur5e1-joints-safe_actions-3*.log
AlexanderKeijzer commented 3 years ago

https://github.com/eager-dev/eager/blob/0375222635b914b485b426d089498a90bbee32a4/eager_process_safe_actions/src/eager_process_safe_actions/safe_actions_node.py#L1

This line should not explicitly reference python3 but just python. It will likely work on both melodic and noetic then (will start in python 2 in melodic and python 3 in noetic).

Edit: maybe you also need to run rosdep for moveit?

bheijden commented 3 years ago

Changing to python2 seems problematic with the current implementation, as the node requires gym and is note entirely written in python2 compatible code unfortunately.

bheijden commented 3 years ago

Currently, as a work around to get it working on melodic is to change the shebang in: https://github.com/eager-dev/eager/blob/0375222635b914b485b426d089498a90bbee32a4/eager_process_safe_actions/src/eager_process_safe_actions/safe_actions_node.py#L1

with python2. This will break Noetic support so it is a hacky work around for Melodic.

Also, this requires commenting out all the gym related stuff: https://github.com/eager-dev/eager/blob/0375222635b914b485b426d089498a90bbee32a4/eager_process_safe_actions/src/eager_process_safe_actions/safe_actions.py#L4 https://github.com/eager-dev/eager/blob/0375222635b914b485b426d089498a90bbee32a4/eager_core/src/eager_core/action_processor.py#L6

and explicitly supplying the preprocessor with a new action_space, instead of inferring it from the node: https://github.com/eager-dev/eager/blob/0375222635b914b485b426d089498a90bbee32a4/examples/ur5e_example/scripts/example_custom_env.py#L24

ZZWang21 commented 1 year ago

I have the similar problem, how did you solve it? Thanks. @bheijden