Project 5 wire contract (extra credit) — RRT-Connect in 2-D and in configuration space¶
This is the external contract for Project 5's runtime. It reuses the Project 1 transport
unchanged: spec/ROSBRIDGE_PROTOCOL.md, TCP, newline-delimited JSON, 127.0.0.1:9095,
advertise/publish/subscribe, advertise_service/call_service/service_response. Grading is
100% black-box over this contract. Nothing depends on a UI, internal file names, or process
topology.
Keywords. MUST and MUST NOT are requirements; SHOULD is a strong recommendation that is not graded; MAY is permitted but optional. An input marked UNSPECIFIED is one your runtime will not receive: you may do anything with it except crash or hang. OUT OF SCOPE is not part of the project at all.
Project 5 is kinematics and search only. Nothing here involves mass, inertia, gravity, simulation or control gains.
What you build¶
Project 5 is an extra-credit project with no checkpoint. It grades RRT-Connect motion planning twice: for a point in the plane, and for a robot in its configuration space.
| Interface | What it does |
|---|---|
/plan_path_2d (service) |
Plans a collision-free path for a point in a 2-D world of circular obstacles. It needs no robot description. |
/param_server/set_param, /param_server/get_param |
The parameter server, the same as Projects 3 and 4 (restated below). The robot arrives as the robot_description parameter. |
/plan_motion (service) |
Plans a collision-free path through the robot's configuration space: every movable joint, and optionally the planar base. Every point of the path must be valid by "State validity" below. |
Internal topology is up to you: one node or many. Only the wire is graded. A
/check_state_validity service (below) is a useful building block and MAY be offered; it is
not graded.
Runtime and Make ABI¶
make build, make run and make clean are defined in the handout's "Submission, building,
and running" section (the same rules as Projects 1–4).
make runMUST launch the gateway and whatever provides the interfaces above, and each service you implement MUST be answering within 10 seconds ofmake runstarting.- The gateway speaks the shared protocol (
spec/ROSBRIDGE_PROTOCOL.md). Project 5 usescall_serviceand the protocol's errorstatusreply to an unknown operation; the rest of your Project 1 gateway may stay as it is. - A gateway call timeout of at least 30 seconds (SHOULD): a planning request may take seconds.
make runMUST NOT launch anything that publishes/joint_statesor that setsrobot_description. Your Project 3robot_state_publisherand Project 4 IK services MAY run; nothing in Project 5 depends on them.make demoMAY exist for anything you want to show off. It is not graded.
The runtime starts with no robot_description set. It needs no files, environment
variables or command-line arguments: every robot, scene and planning problem arrives over the
wire.
Line size: every hop MUST carry lines of at least 1 MiB. A URDF travels as one JSON string, and a planned path with hundreds of points travels as one reply. A fixed 64 KiB line buffer will fail; read until the newline, in the gateway and in every node-to-node connection.
Numbers¶
Numbers are JSON numbers; integers MUST be accepted wherever a number is expected. true and
false are not numbers (in Python, isinstance(True, int) is True, so test for bool
first). UNSPECIFIED everywhere: non-finite numbers, hexadecimal floats, and numbers with
magnitude above 1e6.
Reply envelope and errors¶
Every service replies with the standard {"values": {...}, "result": <bool>, "status":
<string>} envelope. "Rejected" below means result: false with a non-empty status; the
contents of values in a rejected reply are UNSPECIFIED except where stated. After any
rejected request, the service MUST keep answering later requests correctly.
/plan_path_2d¶
A point moves in the plane. Plan a path from start to goal that stays inside the boundary
and never touches an obstacle.
Request:
{"start": [x, y], "goal": [x, y],
"boundary": {"min": [x_min, y_min], "max": [x_max, y_max]},
"obstacles": [{"center": [x, y], "radius": r}, ...],
"step_size": 0.25, "max_iterations": 5000}
boundaryis an axis-aligned rectangle withx_min < x_maxandy_min < y_max.obstaclesis a list of circles (possibly empty) withradius > 0. Obstacles MAY overlap each other and MAY extend past the boundary.step_size(> 0) is the RRT extension step the problem was designed for. You SHOULD use it as your step.max_iterations(an integer≥ 1) is your iteration budget: you SHOULD stop and report failure after that many iterations (one iteration = one random sample).- Other fields (for example
seed) MAY be present and MAY be used or ignored.
Validity. A point p is valid when it is inside the closed boundary
(x_min ≤ p.x ≤ x_max and y_min ≤ p.y ≤ y_max) and outside every closed obstacle disc
(‖p − center‖ > radius for every obstacle). A straight segment is valid when every point on
it is valid. (Because the boundary is convex, a segment is inside it exactly when both
endpoints are; a segment touches a disc exactly when the distance from the disc's centre to the
segment is at most the radius.)
Reply when a path is found:
pathMUST have at least two points. Its first point MUST bestartand its last pointgoal(each coordinate within1e-6).- Every point MUST be valid and every segment between consecutive points MUST be valid.
- There is no limit on segment length, no density requirement and no optimality requirement: any valid path is correct. Smoothing is allowed.
- Values MAY contain anything else (iteration counts, the trees, ...). None of it is graded.
When no path is found:
- If
startorgoalis not a valid point, the reply MUST havefound: false(or be rejected). It MUST NOT havefound: true. - If both are valid but no valid path connects them (for example, the goal is enclosed by
overlapping obstacles), the reply MUST NOT have
found: true, and it MUST arrive within the time bound below for anymax_iterations ≤ 5000. Report it as{"values": {"found": false}, "result": true, "status": "<why>"}; a rejected reply is also accepted. - A solvable problem MUST be solved. Every solvable problem your runtime receives is one that
plain RRT-Connect with the given
step_sizesolves in well under a tenth ofmax_iterations, and its passages are at least2 × step_sizewide.
Time bound: a reply SHOULD arrive within 5 seconds, and MUST arrive within 20 seconds.
MUST be rejected: a missing or non-numeric start, goal, boundary corner, obstacle center
or radius; a start, goal, corner or center that is not a list of exactly 2 numbers;
obstacles that is missing or not a list.
UNSPECIFIED: x_min ≥ x_max or y_min ≥ y_max; a non-positive radius, step_size or
max_iterations; a non-integer max_iterations (it is always a JSON integer such as 5000); a
missing or non-number step_size or max_iterations; a boundary that is not an object; an
obstacles entry that is not an object; a request (args) that is not an object; start equal to goal; a start or goal on
(within 1e-3 of) a boundary edge or an obstacle's circle; passages narrower than
2 × step_size.
param_server¶
The same as Projects 3 and 4, restated here in full.
/param_server/set_param¶
Request: {"name": "<parameter name>", "value": <any JSON value>}.
- A missing or non-string
nameMUST be rejected, and nothing stored. - Otherwise the server MUST store
valueundername(a missingvaluestoresnull), increment that name'sversion(each name's version starts at 0 and the first set makes it 1), and replyresult: truewith{"version": <new version>}. - The server MUST NOT interpret or validate
value. A malformed URDF is still stored.
/param_server/get_param¶
Request: {"name": "<parameter name>"}.
- If
namehas been set:result: truewith{"value": <stored value>, "version": <version>}, the value exactly as stored. - If it has never been set:
result: false, non-emptystatus, values{"value": null, "version": 0}. - UNSPECIFIED: the
valuesof a rejectedset_param, andget_paramwith a missing or non-stringname.
The only parameter set from outside your runtime during grading is robot_description: the
URDF text as one JSON string (spec/ROBOT_DESCRIPTION.md). A node MAY read other parameters of
its own, and MUST then use its documented default when one has never been set.
Versions are relative. Do not assume robot_description's version starts at any
particular number. A version number is meaningful only relative to the version set_param
returns.
Reading the robot¶
/plan_motion (and /check_state_validity, if you offer it) answer for the robot described by
robot_description. Read it through /param_server/get_param, either in the background
(polling is fine) or on each request.
description_version(MUST). Every/plan_motionreply, success or error, carriesvalues.description_version: therobot_descriptionversion the reply reflects, or0ifrobot_descriptionhas never been set.- Pickup bound (MUST). Once
set_paramofrobot_descriptionhas replied with versionV, every reply sent 2 seconds or more later MUST carrydescription_version >= V, and every reply MUST be computed for the description whose version it echoes. If versions arrive faster than you poll, you MAY skip intermediate ones. - An invalid description (anything
spec/ROBOT_DESCRIPTION.md"Validity" says MUST be rejected) MUST NOT crash or hang any service. While it is the newest version, the services MAY either reject every request (description_version= the invalid version) or keep answering for the previously loaded valid robot (description_version= that robot's version). Either way, the next valid version MUST be picked up under the bound above. - With no robot loaded, every request MUST be rejected.
Configurations, frames and the scene¶
Configuration¶
A configuration is {"name": ["<coordinate>", ...], "position": [<number>, ...]}, the shape of
sensor_msgs/JointState. Its coordinates are:
- every movable joint of the robot (
revolute,continuous,prismatic), by joint name, in radians or metres; - three base coordinates with reserved names:
base/xandbase/y(metres) andbase/yaw(radians). They place the robot's root link in the world (below).
Rules, as in Project 4's joint_state:
- A coordinate the configuration does not name is at
0. So a configuration without base names puts the root link at the world origin. - Names that are neither movable joints nor base coordinates (unknown names,
fixedjoints) MUST be ignored. - Positions are used exactly as given. Nothing is clamped or wrapped.
- MUST be rejected:
nameandpositionof different lengths, and a non-number position for a movable joint or base coordinate. - UNSPECIFIED: a configuration that is not an object, or whose
nameorpositionis missing or not a list; duplicate names; a robot with a joint namedbase/x,base/yorbase/yaw.
Frames¶
- The world frame is the frame of the scene. Its z axis is up; the ground plane is
z = 0. - The root link's pose in the world is
T_base = Trans(base/x, base/y, 0) · Rz(base/yaw). - Forward kinematics is Project 3's and Project 4's (
spec/ROBOT_DESCRIPTION.md, "Kinematic semantics"): linkℓ's pose in the world isT_base · T_root→ℓ(q).
The scene¶
Each /check_state_validity and /plan_motion request carries the scene it is asked about:
{"boundary": {"min": [x_min, y_min, z_min], "max": [x_max, y_max, z_max]},
"spheres": [{"center": [x, y, z], "radius": r}, ...]}
in the world frame, with x_min < x_max, y_min < y_max, every radius > 0, and spheres
possibly empty. The scene is part of the request: your runtime MUST NOT carry a scene over
from one request to the next. boundary z values are carried for completeness and have no
effect (see below).
State validity¶
Collision geometry¶
Each link has at most one collision shape: the geometry of its first <collision> element
if it has one, otherwise the geometry of its first <visual> element, otherwise none (a link
with no shape never collides). spec/ROBOT_DESCRIPTION.md gives the shapes and their
attributes; a geometry <origin> follows the same rules as a joint's origin.
Warning: reusing a Project 3 or 4 URDF parser. Those projects read only each link's first
<visual>. Project 5 robots MAY contain a link that has a<collision>element and no<visual>element. A parser that ignores<collision>sees no shape for that link, so your planner treats it as never colliding and can return a path whose points are not valid. Extend your parser to read the first<collision>before you rely on it for planning.
The link's box is an axis-aligned box in the link's own frame, computed from its shape:
- The shape's own box, centred on the geometry frame's origin:
<box size="a b c"/>:[−a/2, a/2] × [−b/2, b/2] × [−c/2, c/2];<cylinder radius="r" length="l"/>(axis along z):[−r, r] × [−r, r] × [−l/2, l/2];<sphere radius="r"/>:[−r, r]³.- Transform its 8 corners by the geometry's
<origin>(Trans(xyz) · Rot(rpy), into the link frame), and take the smallest axis-aligned box containing them. When the origin is rotated, this box is larger than the shape: that is intended.
The base links are the root link and every link attached to it through fixed joints only
(the links that move rigidly with the root whatever the joints do).
Validity¶
A configuration q in scene S is valid when all three hold:
- Joint limits. Every
revoluteandprismaticjoint is within its<limit>:lower ≤ q_j ≤ upper.continuousjoints and base coordinates have no limits. - Boundary. For every base link with a box, all 8 corners of its box, transformed into the
world frame, satisfy
x_min ≤ x ≤ x_maxandy_min ≤ y ≤ y_max. Only base links are tested, and only on x and y: an arm may reach over the boundary, and z is not bounded. - Obstacles. For every link with a box and every sphere, the link does not hit the
sphere. A link hits a sphere when the sphere's centre, transformed into the link's frame
(by the inverse of the link's world pose), lies inside the link's box inflated by the
radius on every axis:
min_i − r ≤ c_i ≤ max_i + rfor each axisi. (This test is conservative: near a box's edges and corners it reports a hit where the sphere would just miss. That is intended.)
There is no self-collision test. Every comparison above is inclusive; inputs are never within
1e-6 of an equality (a limit, a boundary edge, or an inflated face).
/check_state_validity (MAY; not graded)¶
If you offer it (for your own tests, or as the collision checker your planner calls), this is its
recommended shape. Request: {"configuration": <configuration>, "scene": <scene>}.
Reply:
{"values": {"valid": false, "reason": "collision", "description_version": 3},
"result": true, "status": ""}
valid(boolean): the validity of the configuration in the scene.reason:"valid"when valid; otherwise one of"joint_limit","outside_boundary","collision".- A malformed scene is one that is missing or not an object, has a boundary corner or sphere
centerthat is not a list of exactly 3 numbers, a non-numberradius, orspheresthat is missing or not a list.
/plan_motion¶
Plan a path through the robot's configuration space from start to goal, valid in the
request's scene.
Request:
{"start": <configuration>, "goal": <configuration>, "scene": <scene>,
"base_dofs": false, "max_iterations": 2000}
- The planned coordinates are every movable joint of the robot, plus
base/x,base/yandbase/yawwhenbase_dofsistrue. startandgoalfollow the configuration rules (a coordinate they do not name is0). Whenbase_dofsisfalse, neither names a base coordinate: the base stays at the world origin for the whole path.- When
base_dofsistrue,base/xis bounded by[x_min, x_max]andbase/yby[y_min, y_max](every path point MUST respect these bounds, even for a robot whose base links have no box: these bounds are part of the planning problem, in addition to validity), andbase/yawandcontinuousjoints are unbounded (circular). max_iterations(an integer≥ 1) is your iteration budget, as in/plan_path_2d. Other fields (seed,step_size, ...) MAY be present and MAY be used or ignored.
Reply when a path is found:
{"values": {"found": true,
"trajectory": {"joint_names": ["shoulder", "elbow"],
"points": [{"positions": [0.0, 0.0]},
{"positions": [0.04, 0.03]}, ...]},
"description_version": 3},
"result": true, "status": ""}
trajectory.joint_namesMUST list every planned coordinate exactly once, in any order (includingbase/x,base/y,base/yawwhenbase_dofsistrue). Each point'spositionshas one entry per name (thetrajectory_msgs/JointTrajectoryshape).- Endpoints. The first point MUST equal the start and the last point the goal, each
coordinate within
1e-6(forcontinuousjoints andbase/yaw, within1e-6modulo 2π). - Every point MUST be a valid configuration in the scene (with the base at the origin when
base_dofsisfalse). - Density. Consecutive points MUST differ by at most 0.05 in every coordinate (radians or
metres). For
continuousjoints andbase/yaw, the difference is measured the short way round (wrapped into[−π, π]). Densify your path before replying: your planner may search with a larger step, but the path you return is executed point by point. - No optimality requirement: any path that meets the above is correct.
When no path is found: exactly the /plan_path_2d rules, with configurations in place of points
(an invalid start or goal MUST NOT give found: true; a valid but disconnected problem MUST NOT
give found: true, and its reply MUST arrive within the time bound for max_iterations ≤ 2000).
A solvable problem MUST be solved: every solvable problem your runtime receives is one that
plain RRT-Connect, extending by a step of 0.1 to 0.3 (the largest change of any one coordinate),
solves in well under a tenth of max_iterations.
Time bound: a reply SHOULD arrive within 10 seconds, and MUST arrive within 20 seconds.
MUST be rejected: no robot loaded; a missing start or goal, or one that is a malformed
configuration (see "Configuration"); a malformed scene (as defined under
/check_state_validity above); a non-boolean base_dofs. Every reply, found or not, accepted or rejected, carries
description_version.
UNSPECIFIED: a robot with more than 12 movable joints or links with boxes; scenes with more than
100 spheres; a start or goal within 1e-3 of a joint limit or a validity boundary; a start or
goal whose base coordinates are given when base_dofs is false; a missing base_dofs or
max_iterations.
Out of the graded surface¶
These are OUT OF SCOPE for the graded runtime. A runtime MAY offer them; none is graded:
- the follow-trajectory action (
/joint_trajectory_action/*,/joint_trajectory), and any execution of a planned path; /check_state_validityas a service (its semantics define a valid path point, above);- dynamics of any kind (mass, inertia, gravity, simulation, PID or gain tuning);
- behavior trees and their plan / follow-trajectory / condition leaves;
- stepped planning sessions (
/plan_motion_begin,_step,_end), tree snapshots (/rrt/tree) and other progress topics; - scene state and scene editing (
/planning_scene/*), stored worlds, random scene generation, batch validity checks, and navigation maps (/map); - mesh geometry, self-collision, exact (non-inflated) collision tests and
<mimic>; - RRT-Star, path optimality and trajectory timing;
- a WebSocket gateway (port 9096 is a non-goal for every course project).