I have a file (furniture.lisp) that looks basically like this (with lots of entries):
(addgv :furniture 'stove
(make-instance 'stove
:pose (tf:make-pose-stamped
"map" ; frame-id
0.0
(tf:make-3d-vector -3.1 -0.9 0) ; translation/origin
(tf:euler->quaternion :az 0))))
(addgv :furniture 'drawers-cupboard
(make-instance 'cupboard
:pose (tf:make-pose-stamped
"map"
0.0
(tf:make-3d-vector -3.1 0.1 0)
(tf:euler->quaternion :az 0))))
Now I would like to have a function (get-locations "furniture.lisp" "locations.txt")that extracts the coordinates of objects in a 3d vector and writes its output to a file:
(location stove -3.1 -0.9 9)
(location drawers-cupboard -3.1 0.1 0)
...
I started by writing an expression that reads in a file (so far without parameterization) in turn:
(ql:quickload "split-sequence")
(with-open-file (stream "furniture.lisp")
(do ((line (read-line stream nil)
(read-line stream nil)))
((null line))
(princ (split-sequence::split-sequence
))
But I realized that I have no chance / idea to "connect" the name of the object (for example, a stove) and its coordinates. I will need the second character after "(addgv" for the name and the variable "word distance" for coordinates. Therefore, I tried to read the file into one large list:
(defun make-list-from-text (fn)
(with-open-file (stream fn)
(loop for line = (read-line stream nil nil)
while line
collect
(split-sequence::split-sequence
( , , , "" ). . , , - .
EDIT:
Svante ! , (, :export :make-3d-vector). , :key #'car , "" , (, (make-instance ...)) (, addgv). :
(defun find-helper (list-or-symbol)
(if (listp list-or-symbol)
(car list-or-symbol)
list-or-symbol))
#'car #'find-helper.