Huskylens camera and Arduino

Thread Starter

luger123

Joined May 18, 2023
12
Hello,
I am a beginner and learning Arduino programming.
I'm designing an autonomous vehicle and I'm having some minor problems with it.
I use an LCD display and a Huskylens camera. Does anyone have experience with her? Can you advise?

Thanks
 

Thread Starter

luger123

Joined May 18, 2023
12
I would like to send data from the Huskylens (trucking object) and display it on the LCD. The IDE serial monitor shows the correct values (xcenter, ycenter .....) but the LCD shows the value "-1". LCD is I2C, Huskylens UART (RX,TX).
I think my code is correct.
 

Ya’akov

Joined Jan 27, 2019
9,173
I would like to send data from the Huskylens (trucking object) and display it on the LCD. The IDE serial monitor shows the correct values (xcenter, ycenter .....) but the LCD shows the value "-1". LCD is I2C, Huskylens UART (RX,TX).
I think my code is correct.
This is confusing. Help me understand, You have an LCD display that is not the onion the Huskylens and you want to show the numerical data, as text, on a second display?
 

Thread Starter

luger123

Joined May 18, 2023
12
Yes. I need to check the data while the robot car is driving (without cable).
The LCD display is 4x20 characters and works normally. It displays all other data correctly.
 

Thread Starter

luger123

Joined May 18, 2023
12
Thank you for your interest in my problem.
Excerpt from the program code (the entire program code has 450 lines)
I can also send the full code.

C-like:
  #include <LiquidCrystal_I2C.h>

LiquidCrystal_I2C lcd(0x27,20,4);

#include "HUSKYLENS.h"

#include "SoftwareSerial.h"

SoftwareSerial mySerial(10, 11);

HUSKYLENS huskylens;


void setup() {

Serial.begin(115200);

mySerial.begin(9600);


  lcd.init();                      // inicializace LCD displeje

lcd.backlight();                 // zapnutí podsvícení displeje

//huskylens.writeAlgorithm(ALGORITHM_OBJECT_TRACKING);

}

void printResult(HUSKYLENSResult result);


void loop() {

  HUSKYLENSResult result = huskylens.read();

  int aaa=result.xCenter;

  lcd.setCursor(0,2);

  lcd.print("stred X: ");

  lcd.setCursor(9,2);

  lcd.print(aaa);

  }
 
Last edited by a moderator:

Ya’akov

Joined Jan 27, 2019
9,173
Thank you for your interest in my problem.
Excerpt from the program code (the entire program code has 450 lines)
I can also send the full code.

C-like:
  #include <LiquidCrystal_I2C.h>

LiquidCrystal_I2C lcd(0x27,20,4);

#include "HUSKYLENS.h"

#include "SoftwareSerial.h"

SoftwareSerial mySerial(10, 11);

HUSKYLENS huskylens;


void setup() {

Serial.begin(115200);

mySerial.begin(9600);


  lcd.init();                      // inicializace LCD displeje

lcd.backlight();                 // zapnutí podsvícení displeje

//huskylens.writeAlgorithm(ALGORITHM_OBJECT_TRACKING);

}

void printResult(HUSKYLENSResult result);


void loop() {

  HUSKYLENSResult result = huskylens.read();

  int aaa=result.xCenter;

  lcd.setCursor(0,2);

  lcd.print("stred X: ");

  lcd.setCursor(9,2);

  lcd.print(aaa);

  }
When you say that the proper values appear via the serial monitor, do you mean when you print your variable aaa there, or something else?
 

Thread Starter

luger123

Joined May 18, 2023
12
Oops, I didn't think of that. I have not tested the display value "aaa". But, in another part of the program code I control the motors and they don't respond.
For example:
else if(result.xCenter>=200)
{
right(); // engine
}
Result:
engine no action - (changing the value from 200 to any does not affect the result).
 

Ya’akov

Joined Jan 27, 2019
9,173
To debug this, you need to work out what the value of result.xCenter is. You will need to print it via the serial console to determine if it is returning what oyu expect.
 

Thread Starter

luger123

Joined May 18, 2023
12
serial monitor output:

screen vozitko.jpg

The values from the camera are ok. The serial monitor displays them correctly. I think the error is in the code program - conversion of values from "result.xcenter" to the correct value to be displayed on the LCD. But I'm just guessing.
 

Ya’akov

Joined Jan 27, 2019
9,173
You are printing using a function I can’t see. You are not just using Serial.println() to print the variable you are trying to use.
 

Thread Starter

luger123

Joined May 18, 2023
12
Code for output to the serial monitor:

void printResult(HUSKYLENSResult result){
if (result.command == COMMAND_RETURN_BLOCK){
Serial.println(String()+F("Block:xCenter=")+result.xCenter+F(",yCenter=")+result.yCenter+F(",width=")+result.width+F(",height=")+result.height+F(",ID=")+result.ID);
delay(1);
}
else if (result.command == COMMAND_RETURN_ARROW){
Serial.println(String()+F("Arrow:xOrigin=")+result.xOrigin+F(",yOrigin=")+result.yOrigin+F(",xTarget=")+result.xTarget+F(",yTarget=")+result.yTarget+F(",ID=")+result.ID);
delay(1);
}
else{
Serial.println("Object unknown!");
}
delay(2);
}

Print on the LCD display:

HUSKYLENSResult result = huskylens.read();
int aaa=result.xCenter;

//------------------- souradnice objektu -------------------------------------------
lcd.setCursor(0,2);
lcd.print("stred X: ");
lcd.setCursor(9,2);
lcd.print(aaa);

lcd.setCursor(14,2);
lcd.print("Y: ");
lcd.setCursor(17,2);
lcd.print(result.yCenter);
 

Ya’akov

Joined Jan 27, 2019
9,173
Where is this from?

HUSKYLENSResult result = huskylens.read();

I can’t find anything like it in the API documentation, though there is a HUSKYLENSResult read()
It isn’t what the function that is working is doing.
 

Ya’akov

Joined Jan 27, 2019
9,173
Try putting your LCD code in here:

C++:
void printResult(HUSKYLENSResult result){
    if (result.command == COMMAND_RETURN_BLOCK){
        Serial.println(String()+F("Block:xCenter=")+result.xCenter+F(",yCenter=")+result.yCenter+F(",width=")+result.width+F(",height=")+result.height+F(",ID=")+result.ID);
    // LCD code here, using result.xCenter
    }
    else if (result.command == COMMAND_RETURN_ARROW){
        Serial.println(String()+F("Arrow:xOrigin=")+result.xOrigin+F(",yOrigin=")+result.yOrigin+F(",xTarget=")+result.xTarget+F(",yTarget=")+result.yTarget+F(",ID=")+result.ID);
    }
    else{
        Serial.println("Object unknown!");
    }
}
 

Thread Starter

luger123

Joined May 18, 2023
12
Hi,
I solved the problem with the data output to the LCD display. Thanks everyone for the advice.
But I have another question and I am asking for your advice. Is it possible to transfer an image (or video) from the Husky to a PC via Bluetooth?
 
Last edited:
Top