moveit / moveit_tutorials

A sphinx-based centralized documentation repo for MoveIt
https://moveit.github.io/moveit_tutorials/
BSD 3-Clause "New" or "Revised" License
472 stars 690 forks source link

Running MoveItCpp tutorial with a gazebo controller results in Trajectory messages that are not strictly increasing in time #517

Open rishabhgks opened 4 years ago

rishabhgks commented 4 years ago

Description

I am trying to use the MoveItCpp interface to control a Staubli TX-60 arm. I use their JointTrajectoryController and set the "moveit_controller_manager" to MoveItSimpleControllerManager. The planning happens perfectly and a plan is generated, but when I run the execute() function I get the error:

Waiting to continue: Press 'next' in the RvizVisualToolsGui window to start the demo... continuing
[ WARN] [1597949866.466092505, 6.338000000]: It looks like the planning volume was not specified.
[ INFO] [1597949866.468209561, 6.339000000]: Planner configuration 'arm' will use planner 'geometric::RRTConnect'. Additional configuration parameters will be set when the planner is constructed.
[ INFO] [1597949866.470186891, 6.341000000]: RRTConnect: Starting planning with 1 states already in datastructure
[ INFO] [1597949866.492377495, 6.359000000]: RRTConnect: Created 5 states (2 start + 3 goal)
[ INFO] [1597949866.492431530, 6.359000000]: Solution found in 0.023068 seconds
[ INFO] [1597949866.512285198, 6.372000000]: SimpleSetup: Path simplification took 0.019639 seconds and changed from 4 to 2 states
[ERROR] [1597949866.539251212, 6.395000000]: Trajectory message contains waypoints that are not strictly increasing in time.
[ WARN] [1597949866.542895709, 6.398000000]: Controller arm_controller failed with error INVALID_GOAL: Trajectory message contains waypoints that are not strictly increasing in time.
[ WARN] [1597949866.543342958, 6.398000000]: Controller handle arm_controller reports status FAILED
[ INFO] [1597949866.543531351, 6.398000000]: Completed trajectory execution with status FAILED ...

I tried to debug further and came at the point where planning_component returns a solution to the moveit_cpp_tutorial. I converted the plan_solution1->trajectory to moveit_msgs/RobotTrajectory msg and printed it out on a topic. This is an example of the type of messages being passed by the planner to the TrajectoryExecutionManager:

trajectory: 
  - 
    joint_trajectory: 
      header: 
        seq: 0
        stamp: 
          secs: 0
          nsecs:         0
        frame_id: "world"
      joint_names: [joint_1, joint_2, joint_3, joint_4, joint_5, joint_6]
      points: 
        - 
          positions: [1.504574242972012e-11, -3.284306160367123e-11, -9.605649609056854e-12, -2.1325163857000007e-12, 1.0311751452718454e-12, 8.455458555545192e-13]
          velocities: []
          accelerations: []
          effort: []
          time_from_start: 
            secs: 0
            nsecs:         0
        - 
          positions: [-7.880131335270788e-05, 0.15267103477495161, -0.1833828864002482, -0.0040051460742771645, 0.03048874774064969, 0.003952845536801455]
          velocities: []
          accelerations: []
          effort: []
          time_from_start: 
            secs: 0
            nsecs:         0
        - 
          positions: [-0.0001576026417511582, 0.3053420695827463, -0.36676577279089073, -0.008010292146421813, 0.06097749548026821, 0.007905691072757364]
          velocities: []
          accelerations: []
          effort: []
          time_from_start: 
            secs: 0
            nsecs:         0
        - 
          positions: [-0.0002364039701496085, 0.458013104390541, -0.5501486591815332, -0.012015438218566462, 0.09146624321988672, 0.011858536608713272]
          velocities: []
          accelerations: []
          effort: []
          time_from_start: 
            secs: 0
            nsecs:         0
        - 
          positions: [-0.0003152052985480588, 0.6106841391983356, -0.7335315455721758, -0.01602058429071111, 0.12195499095950524, 0.01581138214466918]
          velocities: []
          accelerations: []
          effort: []
          time_from_start: 
            secs: 0
            nsecs:         0
        - 
          positions: [-0.00039400662694650916, 0.7633551740061305, -0.9169144319628184, -0.02002573036285576, 0.15244373869912375, 0.01976422768062509]
          velocities: []
          accelerations: []
          effort: []
          time_from_start: 
            secs: 0
            nsecs:         0
        - 
          positions: [-0.00047280795534495945, 0.916026208813925, -1.1002973183534608, -0.024030876435000407, 0.18293248643874227, 0.023717073216580998]
          velocities: []
          accelerations: []
          effort: []
          time_from_start: 
            secs: 0
            nsecs:         0
        - 
          positions: [-0.0005516092837434098, 1.06869724362172, -1.2836802047441036, -0.028036022507145056, 0.21342123417836079, 0.02766991875253691]
          velocities: []
          accelerations: []
          effort: []
          time_from_start: 
            secs: 0
            nsecs:         0
        - 
          positions: [-0.0006304106121418601, 1.2213682784295143, -1.467063091134746, -0.0320411685792897, 0.2439099819179793, 0.03162276428849282]
          velocities: []
          accelerations: []
          effort: []
          time_from_start: 
            secs: 0
            nsecs:         0
        - 
          positions: [-0.0007092119405403104, 1.3740393132373092, -1.6504459775253886, -0.036046314651434354, 0.2743987296575978, 0.035575609824448726]
          velocities: []
          accelerations: []
          effort: []
          time_from_start: 
            secs: 0
            nsecs:         0
    multi_dof_joint_trajectory: 
      header: 
        seq: 0
        stamp: 
          secs: 0
          nsecs:         0
        frame_id: ''
      joint_names: []
      points: []
trajectory_start: 
  joint_state: 
    header: 
      seq: 0
      stamp: 
        secs: 0
        nsecs:         0
      frame_id: "world"
    name: [joint_1, joint_2, joint_3, joint_4, joint_5, joint_6]
    position: [1.504574242972012e-11, -3.284306160367123e-11, -9.605649609056854e-12, -2.1325163857000007e-12, 1.0311751452718454e-12, 8.455458555545192e-13]
    velocity: []
    effort: []
  multi_dof_joint_state: 
    header: 
      seq: 0
      stamp: 
        secs: 0
        nsecs:         0
      frame_id: "world"
    joint_names: []
    transforms: []
    twist: []
    wrench: []
  attached_collision_objects: []
  is_diff: False

So the planner is able to plan the multiple positions for the trajectory, but the velocities, accelerations and effort are all empty and more importantly the time_of_start for all of them is 0 which leads to the error that Trajectory Messages are not increasing in time. From here on I'm out of my depth to debug and find out how to resolve this issue.

Your environment

Steps to reproduce

  1. Install the staubli_experimental package into the workspace.
  2. Generate a moveit package using moveit_setup_assistant with a planning_group called 'arm' to control the links from base_link to tool0. Name the package tx60_moveit_config.
  3. Create a launch file and paste the following code inside it.

    
    <?xml version="1.0"?>
    <launch>
    <!-- <include file="$(find staubli_tx60_gazebo)/launch/tx60_gazebo.launch">
    </include> -->
    <include file="$(find gazebo_ros)/launch/empty_world.launch">
    <arg name="world_name" value="worlds/empty.world"/>
    <arg name="gui" value="true"/>
    <arg name="paused" value="false"/>
    </include>
    
    <node name="spawn_gazebo_model" pkg="gazebo_ros" type="spawn_model" 
      output="screen" respawn="false"
      args="-urdf
            -param robot_description
            -model tx60
            -x 0.0
            -y 0.0
            -z 0.0
            -R 0.0
            -P 0.0
            -Y 0.0" >
    </node>
    
    <arg name="controller_yaml" default="tx60_arm_controller.yaml"/>
    <!-- load the joint state controller -->
    <rosparam file="$(find staubli_tx60_gazebo)/config/joint_state_controller.yaml" command="load" />
    <node name="joint_state_controller_spawner" pkg="controller_manager" type="spawner" args="joint_state_controller" />
    
    <!-- load the arm controller -->
    <rosparam file="$(find staubli_tx60_gazebo)/config/$(arg controller_yaml)" command="load" />
    <node name="staubli_tx60_controller_spawner" pkg="controller_manager" type="spawner" args="arm_controller" />
    
    <param name="robot_description" command="$(find xacro)/xacro --inorder '$(find staubli_tx60_gazebo)/urdf/tx60.xacro'" />
    
    <node name="robot_state_publisher" pkg="robot_state_publisher" type="robot_state_publisher"/>
    
    <arg name="robot_description" default="robot_description" />
    <!-- The semantic description that corresponds to the URDF -->
    <param name="$(arg robot_description)_semantic" textfile="$(find wamv_moveit_config)/config/staubli_tx60.srdf" />
    <-- This yaml config file is the moveitcpp_tutorial yaml config file -->
    <rosparam command="load" file="$(find tx60_moveit_config)/config/tx60_arm_moveitcpp.yaml"/>
    
    <!-- Load updated joint limits (override information from URDF) -->
    <group ns="$(arg robot_description)_planning">
    <rosparam command="load" file="$(find tx60_moveit_config)/config/joint_limits.yaml"/>
    </group>
    
    <!-- Load default settings for kinematics; these settings are overridden by settings in a node's namespace -->
    <group ns="$(arg robot_description)_kinematics">
    <rosparam command="load" file="$(find tx60_moveit_config)/config/kinematics.yaml"/>
    </group>
    
    <node name="joint_state_publisher" pkg="joint_state_publisher" type="joint_state_publisher">
    <param name="use_gui" value="false"/>
    <rosparam param="source_list">[/joint_states]</rosparam>
    </node>
    
    <rosparam command="load" file="$(find tx60_moveit_config)/config/ompl_planning.yaml"/>


I renamed the moveitcpp_tutorial cpp file to "tx60_arm_moveitcpp.cpp" and made a few changes. This is the final node that I execute:

include <ros/ros.h>

include

// MoveitCpp // #include <moveit/moveit_cpp/moveit_cpp.h> // #include <moveit/moveit_cpp/planning_component.h>

include "../../moveit/moveit_ros/planning_interface/moveit_cpp/include/moveit/moveit_cpp/moveit_cpp.h"

include "../../moveit/moveit_ros/planning_interface/moveit_cpp/include/moveit/moveit_cpp/planning_component.h"

include <geometry_msgs/PointStamped.h>

include <moveit_visual_tools/moveit_visual_tools.h>

namespace rvt = rviz_visual_tools;

int main(int argc, char** argv) { ros::init(argc, argv, "tx60_arm_moveitcpp"); ros::NodeHandle nh; ros::AsyncSpinner spinner(4); spinner.start();

// BEGIN_TUTORIAL // // Setup // ^^^^^ // static const std::string PLANNING_GROUP = "arm"; static const std::string LOGNAME = "tx60_arm_moveitcpp";

/ Otherwise robot with zeros joint_states / ros::Duration(1.0).sleep();

ROS_INFO_STREAM_NAMED(LOGNAME, "Starting TX60 arm control...");

auto moveit_cpp_ptr = std::make_shared(nh); planning_scene_monitor::PlanningSceneMonitorPtr planning_scene_monitor = moveit_cpp_ptr->getPlanningSceneMonitorNonConst(); planning_scene_monitor->providePlanningSceneService("get_planning_scene");

auto planning_components = std::make_shared(PLANNING_GROUP, moveit_cpp_ptr); auto robot_model_ptr = moveit_cpp_ptr->getRobotModel(); auto robot_start_state = planning_components->getStartState(); auto joint_model_group_ptr = robot_model_ptr->getJointModelGroup(PLANNING_GROUP);

// Visualization // ^^^^^^^^^^^^^ // // The package MoveItVisualTools provides many capabilties for visualizing objects, robots, // and trajectories in RViz as well as debugging tools such as step-by-step introspection of a script moveit_visual_tools::MoveItVisualTools visual_tools("base_link", rvt::RVIZ_MARKER_TOPIC, moveit_cpp_ptr->getPlanningSceneMonitor()); visual_tools.deleteAllMarkers(); visual_tools.loadRemoteControl();

Eigen::Isometry3d text_pose = Eigen::Isometry3d::Identity(); text_pose.translation().z() = 1.75; visual_tools.publishText(text_pose, "MoveItCpp Demo", rvt::WHITE, rvt::XLARGE); visual_tools.trigger();

// Start the demo // ^^^^^^^^^^^^^^^^^^^^^^^^^ visual_tools.prompt("Press 'next' in the RvizVisualToolsGui window to start the demo");

// Planning with MoveItCpp // ^^^^^^^^^^^^^^^^^^^^^^^ // There are multiple ways to set the start and the goal states of the plan // they are illustrated in the following plan examples // // Plan #1 // ^^^^^^^ // // We can set the start state of the plan to the current state of the robot planning_components->setStartStateToCurrentState();

// The first way to set the goal of the plan is by using geometry_msgs::PoseStamped ROS message type as follow geometry_msgs::PoseStamped target_pose1; target_pose1.header.frame_id = "base_link"; target_pose1.pose.orientation.w = 1.0; target_pose1.pose.position.x = 0.2; target_pose1.pose.position.y = 0.02; target_pose1.pose.position.z = 0.8; planning_components->setGoal(target_pose1, "tool0");

// Now, we call the PlanningComponents to compute the plan and visualize it. // Note that we are just planning auto plan_solution1 = planning_components->plan();

// Check if PlanningComponents succeeded in finding the plan if (plan_solution1) { // Visualize the start pose in Rviz visual_tools.publishAxisLabeled(robot_start_state->getGlobalLinkTransform("tool0"), "start_pose"); visual_tools.publishText(text_pose, "Start Pose", rvt::WHITE, rvt::XLARGE); // Visualize the goal pose in Rviz visual_tools.publishAxisLabeled(target_pose1.pose, "target_pose"); visual_tools.publishText(text_pose, "Goal Pose", rvt::WHITE, rvt::XLARGE); // Visualize the trajectory in Rviz visual_tools.publishTrajectoryLine(plan_solution1.trajectory, joint_model_group_ptr); visual_tools.trigger();

/* Uncomment if you want to execute the plan */
planning_components->execute(); // Execute the plan */

}

// Start the next plan visual_tools.deleteAllMarkers(); visual_tools.prompt("Press 'next' in the RvizVisualToolsGui window to continue the demo");

// END_TUTORIAL visual_tools.deleteAllMarkers(); visual_tools.prompt("Press 'next' to end the demo");

ROS_INFO_STREAM_NAMED(LOGNAME, "Shutting down."); ros::waitForShutdown(); }


Please let me know If I can provide any more details on the issue. I'm not familiar with dockers otherwise I would have uploaded one instead of pasting the code.

### Expected behaviour
I believe that I am missing some kind of parameter that is not calculating the time, velocities and accelerations for each waypoint inside the planned trajectory. I could be wrong.
Ultimately I want the arm to move with gazebo controllers and see the movement happen in gazebo as well so that I can plan continuous movements using moveitcpp.
welcome[bot] commented 4 years ago

Thanks for reporting an issue. Because we're a volunteer community, providing a pull request with suggested changes is always welcomed.

rishabhgks commented 4 years ago

@JafarAbdi @henningkayser @rhaschke Could any of you please guide me on where I might be going wrong here?

corot commented 3 years ago

I'm experiencing the same issue when picking/placing in gazebo, but only with the current melodic debians. Doesn't happen if I use compiled master (didn't try compiled melodic)

...
      - 
        positions: [1.2889687027773171, 0.055803899290690184, -0.6248854557842535, 0.7660033740710387]
        velocities: []
        accelerations: []
        effort: []
        time_from_start: 
          secs: 0
          nsecs:         0
      - 
        positions: [1.2434171380344599, 0.15359409387309908, -0.6561297106314428, 0.7343035428209158]
        velocities: []
        accelerations: []
        effort: []
        time_from_start: 
          secs: 0
          nsecs:         0
      - 
        positions: [1.1978655732916028, 0.25138428845550775, -0.687373965478632, 0.7026037115707929]
        velocities: []
        accelerations: []
        effort: []
        time_from_start: 
          secs: 0
          nsecs:         0
      - 
        positions: [1.1523140085487455, 0.34917448303791687, -0.7186182203258215, 0.6709038803206699]
        velocities: []
        accelerations: []
        effort: []
        time_from_start: 
          secs: 0
...

Funny thing is that this started happening after re-making my moveit configuration with an updated wizard! (here the update commit)