TLDR
Suppose your initial positions is saved in initial_positions.yaml
, you can set the initial position before bringing up the robot as follows
initial_positions = os.path.join(
get_package_share_directory("your_package"),
"path/to/initial_positions.yaml",
)
moveit_config = (
MoveItConfigsBuilder("your_robot", package_name="your_robot_package")
.robot_description(
file_path="config/your_robot.urdf.xacro",
mappings={"initial_positions_file": initial_positions},
)
.trajectory_execution(file_path="config/moveit_controllers.yaml")
.planning_pipelines(pipelines=["ompl"])
.to_moveit_configs()
)
Details
Since you're using MoveItSetupAssistant
, it should have generated your_robot.urdf.xacro
Further, I'm assuming you're launching your robot with MoveItConfigsBuilder
with something like
moveit_config = (
MoveItConfigsBuilder("your_robot", package_name="your_robot_package")
.robot_description(file_path="config/your_robot.urdf.xacro")
.trajectory_execution(file_path="config/moveit_controllers.yaml")
.planning_pipelines(pipelines=["ompl"])
.to_moveit_configs()
)
Note that the robot_description()
method allows specifying a mapping
parameter.
Also notice that the generated your_robot.urdf.xacro
has a xacro arg
<xacro:arg name="initial_positions_file" default="initial_positions.yaml" />
You can specify a mapping to override the default initial_positions.yaml
file like so
initial_positions = os.path.join(
get_package_share_directory("your_package"),
"path/to/initial_positions.yaml",
)
moveit_config = (
MoveItConfigsBuilder("your_robot", package_name="your_robot_package")
.robot_description(
file_path="config/your_robot.urdf.xacro",
mappings={"initial_positions_file": initial_positions},
)
.trajectory_execution(file_path="config/moveit_controllers.yaml")
.planning_pipelines(pipelines=["ompl"])
.to_moveit_configs()
)