Skip to content

Rename FloatValue to FloatSeqValue and such... #30

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion behavior/behavior.scm
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@
(cog-new-stv 1 1))))

; set some deault values
(cog-set-value! Aey Apos_h (FloatValue 0 0))
(cog-set-value! Aey Apos_h (FloatSeqValue 0 0))

; look at a salient point
(define-public (look-salient-point atom)
Expand Down
12 changes: 6 additions & 6 deletions behavior/functions.scm
Original file line number Diff line number Diff line change
Expand Up @@ -16,14 +16,14 @@
;; Value
;; PredicateNode "emotion"
;; ConceptNode "face_0"
;; StringValue "angry"
;; StringSeqValue "angry"
;;
;; The same thing for the other sensors.
;;
;; The "sense" and "rate" nodes are used to set the delay for
;; each loop of the sensors. Setting the following delays each
;; sensor iteration by 1000 us
;; (cog-set-value sen_h rate_h (FloatValue 1000))
;; (cog-set-value sen_h rate_h (FloatSeqValue 1000))

(define-public Afs (ConceptNode "face"))
(define-public Asm (PredicateNode "smile"))
Expand All @@ -40,8 +40,8 @@
; some default values
(define-public IMAGE_WIDTH 320)
(define-public IMAGE_HEIGHT 240)
(cog-set-value! Afs Anof (FloatValue 0))
(cog-set-value! Aey Apos_h (FloatValue 0 0))
(cog-set-value! Afs Anof (FloatSeqValue 0))
(cog-set-value! Aey Apos_h (FloatSeqValue 0 0))

; A function which always returns false
(define-public (func-false)
Expand Down Expand Up @@ -82,8 +82,8 @@
(define-public (wordlist-to-str wrdlst)
(string-concatenate (map append-space (map cog-name wrdlst))))

; function to convert a FloatValue to exact number
; only the first of the FloatValue array
; function to convert a FloatSeqValue to exact number
; only the first of the FloatSeqValue array
(define-public (cog-value->exact cv)
(if (cog-value? cv)
(inexact->exact (car (cog-value->list cv)))
Expand Down
38 changes: 19 additions & 19 deletions dr-roboto/dr-roboto.cpp.in
Original file line number Diff line number Diff line change
Expand Up @@ -48,9 +48,9 @@
#include <opencog/atoms/truthvalue/TruthValue.h>
#include <opencog/atoms/truthvalue/AttentionValue.h>

#include <opencog/atoms/value/FloatValue.h>
#include <opencog/atoms/value/LinkValue.h>
#include <opencog/atoms/value/StringValue.h>
#include <opencog/atoms/value/FloatSeqValue.h>
#include <opencog/atoms/value/SeqValue.h>
#include <opencog/atoms/value/StringSeqValue.h>

#include <opencog/guile/SchemePrimitive.h>

Expand Down Expand Up @@ -166,7 +166,7 @@ void DrRoboto::sensor_loop(DrRoboto *dr)
Handle pos_h = dr->_as->add_node(CONCEPT_NODE, "position");
Handle sen_h = dr->_as->add_node(CONCEPT_NODE, "sense");
Handle rate_h = dr->_as->add_node(CONCEPT_NODE, "rate");
//sen_h->setValue(rate_h, createFloatValue(1000)); //u-secs to delay sensor
//sen_h->setValue(rate_h, createFloatSeqValue(1000)); //u-secs to delay sensor

ValuePtr pap;

Expand All @@ -186,30 +186,30 @@ void DrRoboto::sensor_loop(DrRoboto *dr)
Value
ConceptNode "position"
ConceptNode "face_x"
FloatValue X Y
FloatSeqValue X Y
*/
faces = dr->fcd.Transform(he);
for(idx = 0; idx < faces.size(); idx++) {
str = "face_" + std::to_string(idx+1);
h = dr->_as->add_node(CONCEPT_NODE, str.c_str());

pap = createFloatValue(std::vector<double>({(double) faces[idx].x + faces[idx].width/2,
pap = createFloatSeqValue(std::vector<double>({(double) faces[idx].x + faces[idx].width/2,
(double) faces[idx].y + faces[idx].height/2}));
h->setValue(pos_h, pap);

img = he(faces[idx]);
smile = dr->smd.Transform(img); //only check on the smaller face region
if(!smile.empty())
pap = createFloatValue(1.0);
pap = createFloatSeqValue(1.0);
else
pap = createFloatValue(0.0);
pap = createFloatSeqValue(0.0);
h->setValue(sm, pap);
/*
^ this is
Valuation
PredicateNode "smile"
ConceptNode "face_x"
FloatValue x.x
FloatSeqValue x.x
*/

#ifdef _DEBUG_ //XXX REMOVE WHEN DONE
Expand All @@ -235,11 +235,11 @@ void DrRoboto::sensor_loop(DrRoboto *dr)
Value
PredicateNode "emotion"
ConceptNode "face_x"
StringValue "emotion_x"
StringSeqValue "emotion_x"
*/
if(dr->ferpc.detect_emotion(img, emo_preds, emo_boxes)) {
if(emo_preds.size() == 1) {
pap = createStringValue(emo_preds[0]);
pap = createStringSeqValue(emo_preds[0]);
h->setValue(em, pap);
#ifdef _DEBUG_ //XXX REMOVE WHEN DONE
cv::putText(_dbg_img, emo_preds[0],
Expand All @@ -259,20 +259,20 @@ void DrRoboto::sensor_loop(DrRoboto *dr)
Value
ConceptNode "face"
PredicateNode "number_of"
FloatValue X
FloatSeqValue X

*/
fs->setValue(nof, createFloatValue((double)faces.size()));
fs->setValue(nof, createFloatSeqValue((double)faces.size()));

/*
salient point
Valuation
PredicateNode "look"
ConceptNode "eyes"
FloatValue X Y
FloatSeqValue X Y
*/
cent = dr->sal_d.sal_point(gr, gr);
pap = createFloatValue(std::vector<double>({(double)cent.x, (double)cent.y}));
pap = createFloatSeqValue(std::vector<double>({(double)cent.x, (double)cent.y}));
ey->setValue(lk, pap);

#ifdef _DEBUG_ //XXX REMOVE WHEN DONE
Expand All @@ -286,13 +286,13 @@ void DrRoboto::sensor_loop(DrRoboto *dr)
Valuation
PredicateNode "position"
ConceptNode "hand"
FloatValue X Y
FloatSeqValue X Y

** finger count ** XXX not sure if this is the right way
Valuation
ConceptNode "fingers"
ConceptNode "hand_x"
FloatValue X
FloatSeqValue X
*/
cv::threshold(he, he, 70, 255, CV_THRESH_BINARY_INV | CV_THRESH_OTSU);
hands = dr->dh.Transform(he);
Expand All @@ -304,12 +304,12 @@ void DrRoboto::sensor_loop(DrRoboto *dr)

str = "hand_" + std::to_string(idx);
h = dr->_as->add_node(CONCEPT_NODE, str.c_str());
pap = createFloatValue(std::vector<double>({
pap = createFloatSeqValue(std::vector<double>({
(double)hands[idx].x+(hands[idx].width/2),
(double)hands[idx].y+(hands[idx].height/2)}));
h->setValue(pos_h, pap);

pap = createFloatValue((float)dr->fc.num_fingers(img));
pap = createFloatSeqValue((float)dr->fc.num_fingers(img));
h->setValue(fi, pap);

#ifdef _DEBUG_ //XXX REMOVE WHEN DONE
Expand Down