Unified Robot Definition Format (URDF) is a standard for description of robots used widely in the ROS ecosystem. O3DE supports URDF through its ROS 2 Gem. The feature of URDF import is still in development. This document will guide you through the process of importing a robot and covers the steps necessary to make it mobile.
- Follow the instructions in the project README to build and test the orchard demo project.
- Examples in the demo use the .xacro extension, which is helpful for parametrization of robot definition. To follow the guide, you need this package installed:
sudo apt install ros-$ROS_DISTRO-xacro
First, we need to produce our URF file out of the .xacro file. This is typically done through running a command and specifying robot parameters. For this example, we will use default values.
In ROSConDemo
folder run:
cd Project/Assets/applekraken_urdf
xacro apple_kraken.xacro > apple_kraken_new.urdf
Run the ROSConDemo O3DE project, load Main
level and import apple_kraken_new.urdf
file using RobotImporter
button.
The apple_kraken_new
prefab should appear in the Entity Outliner
.
The robot imported in this way should look correct and have all the parts included. However, URDF format itself does not include specification of simulation behavior. To enable robot mobility, we need to set up the vehicle control.
In the apple_kraken_new
prefab:
- Add a
Wheel controller
component to entities:wheel_rear_right_link
andwheel_rear_left_link
. Leave all settings default. - Add a
Wheel controller
component to entities:wheel_front_right_link
andwheel_front_left_link
. Set theSteering entity
tosteering_front_right_link
andsteering_front_left_link
respectively (by dragging these entities from theEntity Outliner
). Leave other properties default.
- In the
base_link
entity add aVehicle Model
component. In this component:- Add 2 new axles by clicking
+
next toAxles
. - In the first of these axles:
- Set
Axle tag
toFront
- Add 2 wheels by clicking
+
next toAxle wheels
- Set the first of these wheels to
wheel_front_left_link
and the second towheel_front_right_link
(by dragging these entities from theEntity Outliner
). - Turn on
Is it a steering axle
switch.
- Set
- In the second of these axles:
- Set
Axle tag
toRear
- Add 2 wheels by clicking
+
next toAxle wheels
- Set the first of these wheels to
wheel_rear_left_link
and the second towheel_rear_right_link
(by dragging these entities from theEntity Outliner
). - Turn on the
Is it a drive axle
switch.
- Set
- In the
Drive model
/Steering PID
set:P
:1000.0
OutputLimit
:200.0
- In the
Drive model
/Speed PID
set:P
:250.0
I
:150.0
Imax
:500.0
OutputLimit
:500.0
- Turn on the
AntiWindUp
switch
- In the
Vehicle limits
setSpeed limit
to3.0
- Leave all the other settings default. The component should look like this:
- Add 2 new axles by clicking
- In the
base_link
entity selectROS2 Robot control
component and changeTopic
toackermann_vel
,Type
toackermann_msgs::msg::AckermannDrive
andSteering
toAckermann
.
- In the
base_link
entity add aAckermann Control
component. - In the
base_link
entity add aTag
component. Add 1 tag by clicking+
next toTags
and set the name toRobot
. - In the
base_link
entity add anInput
component and in theInput to event bindings
field selectmobile_robot_control_keyboard.inputbindings
.
In the following step, we will set properties for the manipulator so that it behaves better. Note that desired behavior can be achieved in other ways, but for the purpose of this demo we are going for a simple solution.
- Browse each entity in the
apple_kraken_new
prefab and find allPhysX Collider
components. ChangeCollision Layer
toRobot
in each. - Select the
PhysX Rigid Body
component and turn offGravity enabled
checkbox in following entities:kraken_manipulator_link_1
kraken_manipulator_link_2
kraken_manipulator_link_3
kraken_manipulator_link_4
Effector
Now it is a good time to test the robot. Check that the robot is located over the ground (but not too high) and set a camera to see the robot.
Click the Play button in the right-top corner of the O3DE window, or press Ctrl G
.
You should be able to control robot movement using arrow keys.
URDF format by itself does not specify sensor behavior (unless through Gazebo extensions). Now, we will now add a LIDAR to our robot.
Select the lidar_mount
entity in the apple_kraken_new
prefab, open the right-click menu and select Instantiate Prefab
.
Select ROSConDemo/Project/Prefabs/LidarKraken.prefab
and click OK
. Enter the LidarKraken
prefab, select Sensor
entity and change:
- Set
Ignore layer
toTrue
- Set
Ignored layer index
to1
Select base_link
entity and change its name to apple_kraken_rusty_1
.
This step ensures that our namespace is the same as if the robot was spawned and as such compatible with the demo instructions.
Follow instructions in the o3de_kraken_nav to install the navigation stack.
After the Installation
part run the O3DE simulation (ctrl-g
), switch to terminal and run the following commands:
source /opt/ros/$ROS_DISTRO/setup.bash
cd ~/o3de_kraken_ws
source ./install/setup.bash
export RMW_IMPLEMENTATION=rmw_cyclonedds_cpp
ros2 launch o3de_kraken_nav navigation_multi.launch.py namespace:=apple_kraken_rusty_1 rviz:=True
You should see something like this:
The following steps are dedicated to setting up the manipulator and fine-tuned parameters for its controllers:
In the apple_kraken_new
prefab:
- Open the
kraken_manipulator_link_1
entity and add aMotorizedJoint
component:- Set
ControllerLimits
to0.6
and2.2
- Turn off the
Animation mode
switch - Set
Zero off.
to1.65
- In
PidPosition
set:P
to1200.0
D
to600.0
OutputLimit
to500.0
- Turn off the
SinusoidalTest
switch
- Set
- Open the
kraken_manipulator_link_2
entity and add aMotorizedJoint
component:- Set
Joint Dir.
to1.0, 0.0, 0.0
- Set
ControllerLimits
to-0.5
and1.5
- Turn off the
Animation mode
switch - In
PidPosition
set:P
to1500.0
D
to600.0
OutputLimit
to500.0
- Turn off the
SinusoidalTest
switch
- Set
- Open the
kraken_manipulator_link_4
entity and add aMotorizedJoint
component:- Set
Joint Dir.
to0.0, -1.0, 0.0
- Set
ControllerLimits
to0.35
and0.95
- Set
Zero off.
to0.36
- Turn off the
Animation mode
switch - In
PidPosition
set:P
to250.0
D
to50.0
OutputLimit
to250.0
- Turn off the
SinusoidalTest
switch - Set
Step Parent
tokraken_manipulator_link_2
(by dragging entity from the Entity Outliner)
- Set
- Open the
apple_kraken_rusty_1
entity and add aManipulatorController
component:- Set
m_entityX
tokraken_manipulator_link_2
(by dragging entity from the Entity Outliner) - Set
m_entityY
tokraken_manipulator_link_4
- Set
m_entityZ1
tokraken_manipulator_link_1
- Set
vz
to0.0, 0.0, -1.0
- Set
Rest entity
toRest
- Set
Effector
toEffector
- Set
- In
apple_kraken_rusty_1
, add aApple picking component
component:- Set
Effector
tobase_link
orapple_kraken_rusty_1
- Set
Fruit Storage
tobase_link
orapple_kraken_rusty_1
- Set
Retrieval point
toRetrievalChute
- Set
- In
apple_kraken_rusty_1
, add aKraken Effector
component:- Set
Kraken Reach entity
toReach_visual
- Set
Entity with manipulator
tobase_link
orapple_kraken_rusty_1
- Set
BaseLinkToKinematic
tobase_link
orapple_kraken_rusty_1
- Set
Drive or place the Apple Kraken next to one of apple trees:
You can now start the process of automated apple gathering. When the simulation is running, run these commands in a bash console:
source /opt/ros/$ROS_DISTRO/setup.bash
ros2 service call /apple_kraken_rusty_1/trigger_apple_gathering std_srvs/srv/Trigger
You should see the manipulator picking apples.