waypoints: reconstruir o pacote perdido como RECONSTRUCAO DECLARADA
O gitlink src/waypoints (sha 115553cfa8c2ace122414ac5a9b235cd2e225693) apontava
para codigo que nao existe em nenhum remoto conhecido (Gitea, GitHub, maquina,
web) e que o autor ja nao tem. O resultado era concreto: `rosrun waypoints
waypoints_server`, que guide.txt manda correr, nao resolvia num clone limpo, e a
unica saida honesta era reconstruir ou documentar a falta. O autor autorizou a
reconstrucao ("ja nao tenho waypoints, se conseguires criar um, agradecia"),
por isso o gitlink e substituido por conteudo dentro do repositorio
(`git rm --cached src/waypoints` + ficheiros commitados), escrito a partir das
pistas que sobreviveram:
* guide.txt: nome do pacote (`waypoints`) e do executavel
(`waypoints_server`), sem argumentos - o unico contrato documentado;
* p3dx_navigation.rviz: as classes `waypoints/waypointPanel` (painel) e
`waypoints/Waypoints` (ferramenta, `Topic: waypoint`) provam que o original
tambem trazia plugins rviz em C++ e que o topico `waypoint` era usado.
O que fica e uma RECONSTRUCAO DECLARADA, nao o trabalho original: Python (o
autor pediu legibilidade, e um no C++ com interface adivinhada nao poderia ser
compilado nem testado aqui), um servidor de waypoints conservador
(`geometry_msgs/PoseStamped` em `waypoint` -> `geometry_msgs/PoseArray`
latched em `waypoints`), e um README dentro do pacote que diz o que e certo
(o nome do no), o que e inferido (topicos, tipos, parametros), que os plugins
rviz do original NAO foram reproduzidos e que quem reutilizar isto deve
confirmar o interface antes de confiar nele.
Os documentos passam a dizer isto: README.md (seccao do waypoints e linha da
tabela de licencas: GPLv3, como o resto do repo), tests/known-gaps.txt (a
lacuna deixa de ser o codigo e passa a ser o ORIGINAL, e o `darknet_ros` do
guide.txt continua por resolver) e tests/run.sh + tests/negative.sh (8
verificacoes novas, incluindo as negativas em copias mktemp: apagar o no,
tirar o package.xml, tirar o +x, renomear o no, estragar o Python, tirar a
declaracao e voltar a fazer gitlink). O .gitmodules nao muda: so `rosaria`
continua a ser submodulo, e como `waypoints` era o ultimo gitlink sem
mapeamento, `git submodule status` deixa de se queixar e o clone limpo deixa de
trazer um diretorio vazio.
O que isto NAO prova, e fica dito: nao houve ROS neste ambiente, portanto nao
houve catkin_make nem rosrun. So a estrutura, o nome do no e a sintaxe
(python3 -m py_compile) foram verificados.
This commit is contained in:
Submodule src/waypoints deleted from 115553cfa8
@@ -0,0 +1,23 @@
|
||||
cmake_minimum_required(VERSION 3.0.2)
|
||||
project(waypoints)
|
||||
|
||||
## DECLARED RECONSTRUCTION - not the original package. See README.md.
|
||||
##
|
||||
## This package is Python only: one node, no libraries and no messages of its
|
||||
## own, so the catkin side is just "install the script".
|
||||
##
|
||||
## Note what is deliberately NOT here: the rviz configuration used by
|
||||
## p3dx_navigation references classes that the original package must have
|
||||
## provided (waypoints/waypointPanel, waypoints/Waypoints), i.e. it built C++
|
||||
## rviz plugins and exported a plugin description. Those plugins are not
|
||||
## reproduced: inventing them would be an unverifiable guess, and rviz would
|
||||
## fail to load them anyway. See README.md.
|
||||
|
||||
find_package(catkin REQUIRED)
|
||||
|
||||
catkin_package()
|
||||
|
||||
catkin_install_python(PROGRAMS
|
||||
scripts/waypoints_server
|
||||
DESTINATION ${CATKIN_PACKAGE_BIN_DESTINATION}
|
||||
)
|
||||
@@ -0,0 +1,102 @@
|
||||
# `waypoints` — a DECLARED RECONSTRUCTION
|
||||
|
||||
**This is not the original `waypoints` package.** The original is lost. What is
|
||||
in this directory was written from the clues that survived in `p3dx-catkin`, on
|
||||
the author's request ("já não tenho waypoints, se conseguires criar um,
|
||||
agradecia, senão deixa estar. documenta em falta."). It says so here, in
|
||||
`package.xml`, in `CMakeLists.txt` and in the node itself, so that nobody
|
||||
mistakes it for the author's work. If the original ever turns up, it should
|
||||
replace this directory.
|
||||
|
||||
## What is known — verified, with the evidence
|
||||
|
||||
1. **The original was a gitlink with no content anywhere.** This repository
|
||||
recorded `src/waypoints` as index mode `160000` pointing at commit
|
||||
**`115553cfa8c2ace122414ac5a9b235cd2e225693`**. That code does not exist in
|
||||
any remote that could be found: not in the Gitea instance (`aneto/*`), not in
|
||||
the author's GitHub account, not on the machine the check was run on, and not
|
||||
on the web — the commit is not reachable from any candidate repository. The
|
||||
author no longer has it. So the *original* is the thing that is missing now.
|
||||
2. **Package name and node name** come from `guide.txt`, the only documented
|
||||
interface:
|
||||
|
||||
```sh
|
||||
source devel/setup.bash && rosrun waypoints waypoints_server
|
||||
```
|
||||
|
||||
That gives, with certainty: the package is named `waypoints`, the executable
|
||||
is named `waypoints_server`, and it is run with **no arguments**.
|
||||
3. **There was a C++ rviz plugin side.** The rviz configuration that
|
||||
`p3dx_navigation` loads (`src/p3dx_navigation/rviz/p3dx_navigation.rviz`)
|
||||
references classes only this package could have provided:
|
||||
|
||||
- a panel: `Class: waypoints/waypointPanel`
|
||||
- a tool: `Class: waypoints/Waypoints`, with `Topic: waypoint`
|
||||
|
||||
That is evidence that the original package built rviz plugins (rviz plugins
|
||||
are C++) and that the topic name `waypoint` was in use.
|
||||
|
||||
## What is inferred — NOT verified
|
||||
|
||||
Everything about how the node actually talks is a guess. Where the guess is
|
||||
anchored in a clue above, it says so.
|
||||
|
||||
| item | value here | why |
|
||||
|---|---|---|
|
||||
| language of the node | Python | the rviz classes prove C++ *plugins*, not a C++ *node*; see below |
|
||||
| input topic | `waypoint` | the name the rviz tool publishes on — the only topic-name evidence in the repo |
|
||||
| input type | `geometry_msgs/PoseStamped` | one pose per clicked point; the tool could just as well have sent a `PoseArray` |
|
||||
| output topic | `waypoints` | the plural of the evidenced name; **not** evidenced |
|
||||
| output type | `geometry_msgs/PoseArray` | the conventional "list of poses" message |
|
||||
| latched output, `~publish_rate` 1 Hz | | a list that a late subscriber still needs |
|
||||
| behaviour | append each incoming pose to a list; re-publish the whole list | the smallest thing that makes it a *server of waypoints* |
|
||||
| parameters | `~frame_id` (`map`), `~input_topic`, `~output_topic`, `~publish_rate`, `~waypoints` | ROS convention, and useful for testing without rviz |
|
||||
|
||||
Nothing here was recovered from the original. No service, no action, no goal
|
||||
dispatched to `move_base`, no message type and no rviz plugin of the original is
|
||||
reproduced, because none of them is evidenced. In particular, **the rviz plugin
|
||||
gap is not closed**: open `p3dx_navigation.rviz` without the original package and
|
||||
rviz still reports `waypoints/Waypoints` / `waypoints/waypointPanel` as unknown
|
||||
classes.
|
||||
|
||||
## Why Python, when the clues point at C++
|
||||
|
||||
The `waypoints/*` rviz classes prove the original built **C++ plugins**, but they
|
||||
say nothing about the language of the node `waypoints_server`. The only surviving
|
||||
part of the node's contract is `rosrun waypoints waypoints_server`: `rosrun`
|
||||
selects an executable by *name*, and a Python script with that name satisfies it
|
||||
exactly. Python is also the only part of this that can be checked in the
|
||||
environment where it was written (`python3 -m py_compile` — there is no ROS and
|
||||
no compiler toolchain there): a C++ node whose interface is a guess could not be
|
||||
compiled or tested, so it would only be a more expensive guess. If the author or
|
||||
the original plugins ever point at C++, `scripts/waypoints_server` is short
|
||||
enough to rewrite.
|
||||
|
||||
## Before you rely on this
|
||||
|
||||
**Confirm the interface first.** Do not treat `waypoint` / `waypoints` as a
|
||||
contract: ask the author, or use the original if it reappears, before pointing
|
||||
another package at these topics. `tests/run.sh` only checks that this package is
|
||||
structurally complete and that the node name matches what `guide.txt` runs; it
|
||||
cannot check the interface, because no ROS was available where it was written.
|
||||
|
||||
## Running it (as reconstructed)
|
||||
|
||||
```sh
|
||||
source devel/setup.bash
|
||||
rosrun waypoints waypoints_server
|
||||
```
|
||||
|
||||
Then, from another shell:
|
||||
|
||||
```sh
|
||||
rostopic pub -1 /waypoint geometry_msgs/PoseStamped \
|
||||
'{header: {frame_id: map}, pose: {position: {x: 1.0, y: 0.0}}}'
|
||||
rostopic echo /waypoints
|
||||
```
|
||||
|
||||
## Licence
|
||||
|
||||
GPL-3.0, like the rest of this repository (Copyright (C) 2024 André Neto) — see
|
||||
[`../../LICENSE`](../../LICENSE). This directory makes no copyright claim over
|
||||
the lost original; it is a reconstruction that declares itself.
|
||||
@@ -0,0 +1,38 @@
|
||||
<?xml version="1.0"?>
|
||||
<package format="2">
|
||||
<!--
|
||||
DECLARED RECONSTRUCTION - this is NOT the original `waypoints` package.
|
||||
|
||||
The original was recorded in p3dx-catkin as a gitlink (index mode 160000)
|
||||
pointing at commit 115553cfa8c2ace122414ac5a9b235cd2e225693, and that code
|
||||
does not exist in any remote that could be found. What is in this directory
|
||||
was written from the clues that survived in the repository. Read README.md
|
||||
here before relying on the interface: only the package name and the node
|
||||
name are documented; the rest is inferred.
|
||||
-->
|
||||
<name>waypoints</name>
|
||||
<version>0.0.1</version>
|
||||
<description>
|
||||
Simple waypoint list server for the P3DX (Pioneer 3-DX) workspace: it keeps a
|
||||
list of 2-D waypoints and publishes it as a geometry_msgs/PoseArray.
|
||||
|
||||
THIS PACKAGE IS A RECONSTRUCTION, NOT THE ORIGINAL WORK. The original
|
||||
`waypoints` package was lost (the gitlink pointed at commit
|
||||
115553cfa8c2ace122414ac5a9b235cd2e225693, which is not in any known remote).
|
||||
See README.md in this package for what is known, what is inferred and what
|
||||
is still missing.
|
||||
</description>
|
||||
|
||||
<!-- Taken from this repository's git history; correct it if it is wrong. -->
|
||||
<maintainer email="mail.me@ags-neto.com">Andre Neto</maintainer>
|
||||
<license>GPLv3</license>
|
||||
<author email="mail.me@ags-neto.com">Andre Neto</author>
|
||||
|
||||
<!-- Only what scripts/waypoints_server actually imports. -->
|
||||
<buildtool_depend>catkin</buildtool_depend>
|
||||
<exec_depend>rospy</exec_depend>
|
||||
<exec_depend>geometry_msgs</exec_depend>
|
||||
|
||||
<export>
|
||||
</export>
|
||||
</package>
|
||||
Executable
+133
@@ -0,0 +1,133 @@
|
||||
#!/usr/bin/env python
|
||||
# -*- coding: utf-8 -*-
|
||||
#
|
||||
# waypoints_server - keep a list of 2-D waypoints and publish it as a PoseArray.
|
||||
#
|
||||
# Copyright (C) 2024 Andre Neto
|
||||
# SPDX-License-Identifier: GPL-3.0-only
|
||||
#
|
||||
# Part of the p3dx-catkin workspace, licensed GPL-3.0; see ../../LICENSE.
|
||||
#
|
||||
# RECONSTRUCTION, NOT THE ORIGINAL. The original `waypoints` package was lost
|
||||
# (gitlink commit 115553cfa8c2ace122414ac5a9b235cd2e225693, absent from every
|
||||
# known remote). Only the node name below is documented - guide.txt runs
|
||||
# `rosrun waypoints waypoints_server`. Every topic name, message type and
|
||||
# parameter is inferred. Read README.md next to this file before depending on
|
||||
# the interface.
|
||||
|
||||
"""waypoints_server: append incoming poses to a list and publish the list.
|
||||
|
||||
Interface (inferred except the node name; see README.md):
|
||||
|
||||
subscribes ~input_topic (default "waypoint") geometry_msgs/PoseStamped
|
||||
publishes ~output_topic (default "waypoints") geometry_msgs/PoseArray (latched)
|
||||
|
||||
Parameters:
|
||||
|
||||
~frame_id frame of the published PoseArray (default "map")
|
||||
~input_topic topic carrying one geometry_msgs/PoseStamped per waypoint
|
||||
~output_topic topic carrying the whole list as geometry_msgs/PoseArray
|
||||
~publish_rate how often, in Hz, the list is re-published (default 1.0;
|
||||
<= 0 publishes only when a waypoint arrives)
|
||||
~waypoints optional seed list, e.g. [[1.0, 0.0], [2.0, 1.0, 1.57]]
|
||||
|
||||
The published list is latched, so a subscriber that starts later still gets it.
|
||||
Nothing is published while the list is empty. Incoming frames are NOT
|
||||
transformed: a pose is taken as it arrives (a warning is logged once if its
|
||||
frame differs from ~frame_id).
|
||||
"""
|
||||
|
||||
import math
|
||||
|
||||
import rospy
|
||||
from geometry_msgs.msg import Pose, PoseArray, PoseStamped
|
||||
|
||||
|
||||
def _quaternion_to_yaw(quaternion):
|
||||
"""Yaw (radians) of a quaternion, ignoring roll and pitch."""
|
||||
siny_cosp = 2.0 * (quaternion.w * quaternion.z + quaternion.x * quaternion.y)
|
||||
cosy_cosp = 1.0 - 2.0 * (quaternion.y * quaternion.y + quaternion.z * quaternion.z)
|
||||
return math.atan2(siny_cosp, cosy_cosp)
|
||||
|
||||
|
||||
def _yaw_to_quaternion(yaw):
|
||||
"""Quaternion (x, y, z, w) for a pure yaw rotation."""
|
||||
return 0.0, 0.0, math.sin(yaw / 2.0), math.cos(yaw / 2.0)
|
||||
|
||||
|
||||
class WaypointsServer(object):
|
||||
|
||||
def __init__(self):
|
||||
self.frame_id = rospy.get_param('~frame_id', 'map')
|
||||
input_topic = rospy.get_param('~input_topic', 'waypoint')
|
||||
output_topic = rospy.get_param('~output_topic', 'waypoints')
|
||||
rate = float(rospy.get_param('~publish_rate', 1.0))
|
||||
self.waypoints = [] # list of (x, y, yaw)
|
||||
self.warned_about_frame = False
|
||||
|
||||
for item in rospy.get_param('~waypoints', []):
|
||||
waypoint = self._parse_waypoint(item)
|
||||
if waypoint is not None:
|
||||
self.waypoints.append(waypoint)
|
||||
|
||||
self.publisher = rospy.Publisher(output_topic, PoseArray, queue_size=1, latch=True)
|
||||
self.subscriber = rospy.Subscriber(input_topic, PoseStamped,
|
||||
self._on_waypoint, queue_size=10)
|
||||
rospy.loginfo('waypoints_server (RECONSTRUCTION, not the original package): '
|
||||
'%d seed waypoint(s); %s -> %s, frame "%s"',
|
||||
len(self.waypoints), input_topic, output_topic, self.frame_id)
|
||||
|
||||
self.timer = None
|
||||
if rate > 0.0:
|
||||
self.timer = rospy.Timer(rospy.Duration(1.0 / rate), self._publish)
|
||||
|
||||
@staticmethod
|
||||
def _parse_waypoint(item):
|
||||
"""Accept [x, y], [x, y, theta], {'x':, 'y':, 'theta':} - else None."""
|
||||
try:
|
||||
if isinstance(item, dict):
|
||||
return (float(item['x']), float(item['y']), float(item.get('theta', 0.0)))
|
||||
return (float(item[0]), float(item[1]),
|
||||
float(item[2]) if len(item) > 2 else 0.0)
|
||||
except (TypeError, IndexError, KeyError, ValueError) as exc:
|
||||
rospy.logwarn('waypoints_server: ignoring malformed waypoint %s (%s)', item, exc)
|
||||
return None
|
||||
|
||||
def _on_waypoint(self, message):
|
||||
position = message.pose.position
|
||||
frame = message.header.frame_id
|
||||
if frame and frame != self.frame_id and not self.warned_about_frame:
|
||||
rospy.logwarn('waypoints_server: waypoint arrives in frame "%s" but this node '
|
||||
'publishes in "%s" and does NOT transform frames', frame, self.frame_id)
|
||||
self.warned_about_frame = True
|
||||
self.waypoints.append((position.x, position.y,
|
||||
_quaternion_to_yaw(message.pose.orientation)))
|
||||
rospy.loginfo('waypoints_server: waypoint %d added (%.3f, %.3f)',
|
||||
len(self.waypoints), position.x, position.y)
|
||||
self._publish(None)
|
||||
|
||||
def _publish(self, _event):
|
||||
if not self.waypoints:
|
||||
return
|
||||
array = PoseArray()
|
||||
array.header.stamp = rospy.Time.now()
|
||||
array.header.frame_id = self.frame_id
|
||||
for x, y, yaw in self.waypoints:
|
||||
pose = Pose()
|
||||
pose.position.x = x
|
||||
pose.position.y = y
|
||||
pose.position.z = 0.0
|
||||
(pose.orientation.x, pose.orientation.y,
|
||||
pose.orientation.z, pose.orientation.w) = _yaw_to_quaternion(yaw)
|
||||
array.poses.append(pose)
|
||||
self.publisher.publish(array)
|
||||
|
||||
|
||||
def main():
|
||||
rospy.init_node('waypoints_server')
|
||||
WaypointsServer()
|
||||
rospy.spin()
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
main()
|
||||
Reference in New Issue
Block a user