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

problem of using PoseCostMetric #415

Open
frankchan12138 opened this issue Oct 17, 2024 · 3 comments
Open

problem of using PoseCostMetric #415

frankchan12138 opened this issue Oct 17, 2024 · 3 comments
Assignees

Comments

@frankchan12138
Copy link

I tried the plan_single function with PoseCostMetric link the following code(mainly according to simple_stacking.py sample code).

motion_gen_config = MotionGenConfig.load_from_robot_config(
    robot_dict,
    world_file,
    tensor_args,
    # interpolation_dt=interpolation_dt,
    collision_cache={
        'obb': collision_cache_cuboid,
        'mesh': collision_cache_mesh,
    },
    collision_checker_type=CollisionCheckerType.VOXEL,
    ee_link_name=self.__tool_frame,
    trajopt_tsteps=32,
    use_cuda_graph=True,
    interpolation_dt=0.01
)
......
motion_gen_result = self.motion_gen.plan_single(
    start_state,
    goal_pose,
    MotionGenPlanConfig(
        enable_graph=False,
        max_attempts=10,
        enable_graph_attempt=None,
        enable_finetune_trajopt=True,
        partial_ik_opt=False,
        parallel_finetune=True,
        time_dilation_factor=0.75
        pose_cost_metric = PoseCostMetric.create_grasp_approach_metric(
            offset_position=0.1, tstep_fraction=0.8
        )                        
    )
)

I got the error MotionGenStatus.DT_EXCEPTION, and cannot fix it. Later I found that in the inner code of _plan_from_solve_state funtion, seed_traj will become all zero after _solve_trajopt_from_solve_state.

traj_result = self._solve_trajopt_from_solve_state(
      goal,
      solve_state,
      seed_traj,
      trajopt_instance=self.finetune_trajopt_solver,
      num_seeds_override=seed_override,
      newton_iters=newton_iters,
  )
  finetune_time += traj_result.solve_time

But when I play the simple_stacking.py example, It won't produce result like this. Is there any advice or tips to find out what is wrong? Thanks for all the useful information!!

@frankchan12138
Copy link
Author

frankchan12138 commented Oct 21, 2024

Hi! @balakumar-s I have another question, I found that when I successfully call plan_single with pose_cost_metric set.
The first call will return the result as I want link this
output2

But the second call will return Unexpected result link this
output

I wonder if there is a way to make the function return result like the first one all the time. Can I get this by tuning parameters?

Thanks!

@balakumar-s
Copy link
Collaborator

You can make it deterministic by calling motion_gen.reset(reset_seed=True) between planning calls.

@frankchan12138
Copy link
Author

@balakumar-s Thanks for reply, I try to use motion_gen.reset(reset_seed=True) as follow, but still get the same result. i.e first call I get the result I want, but second call will get the unexpected result.

test_pose_cost_metric = PoseCostMetric.create_grasp_approach_metric()
self.motion_gen.reset(reset_seed=True)
motion_gen_result = self.motion_gen.plan_single(
    start_state,
    goal_pose,
    MotionGenPlanConfig(
        enable_graph=False,
        max_attempts=10,
        enable_graph_attempt=None,
        enable_finetune_trajopt=True,
        partial_ik_opt=False,
        parallel_finetune=True,
        time_dilation_factor=time_dilation_factor,
        pose_cost_metric = test_pose_cost_metric
    ),                    
    link_poses = test_link_pose
)

Is that smothing wrong with my code? Thanks for your advice!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants