0
$\begingroup$

A robot should move along waypoints and operate on a state in parallel, say print a state for every waypoint.

Given:

Array of waypoints
Array of states 
len(waypoints) = len(states)

I am planning a path with the waypoints using MoveIts MoveGroupCommander.compute_cartesian_path.

Then I execute the plan using MoveGroupCommander.execute

(plan, fraction) = moveit_commander.MoveGroupCommander(planner).compute_cartesian_path(
            waypoints, 0.1, 0) 
moveit_commander.MoveGroupCommander(planner).execute(plan, wait=True)

As I am using the plan to execute, it is not as easy as calling goto(pose) in every iteration.

The Plan will execute with a non-constant velocity, so a time-based mapping will also be off.

Without coding something advanced, I think there must be some built-in way of doing what I want.

The only other solution would be a spatial mapping, reading the robot pose in a while-loop and then operating on the state if it is close. But this is a very suboptimal solution.

$\endgroup$

1 Answer 1

0
$\begingroup$

It seems like you're on the right track with your approach, but there's a simpler solution that you might not have considered yet. Since you're using MoveIt's MoveGroupCommander to execute a plan along waypoints, you can actually integrate your state updates directly into the compute_cartesian_path function.

Here's a modified version of your code:

(plan, fraction) = moveit_commander.MoveGroupCommander(planner).compute_cartesian_path(
            waypoints, 0.1, 0)

# Integrate state updates
for waypoint, state in zip(waypoints, states):
    # Update the robot's state for each waypoint
    robot.setCurrentState(state)
    # You might need to add a slight delay here
    time.sleep(0.5)

moveit_commander.MoveGroupCommander(planner).execute(plan, wait=True)

By setting the robot's state at each waypoint before executing the plan, you ensure that the state is updated as the robot moves through its waypoints. This approach is straightforward and doesn't require any complex time-based or spatial mapping.

Remember, this is a simple solution and might not be perfectly synchronized with the robot's actual movement, but it should work for basic applications. Good luck with your project!

$\endgroup$
1
  • $\begingroup$ "Thanks for the input, but I'm not sure if this approach would correctly synchronize the state updates with the robot's movements along the waypoints. Could there be a timing mismatch? Nonetheless, I appreciate your suggestion!" $\endgroup$ Commented Nov 28, 2023 at 19:31

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.