I’m using Pozyx&arduino and read Pozyx’s Documentation.
Tutorial 2: Ready to localize
https://www.pozyx.io/documentation/creator/arduino/ready-to-localize
I want to know how to use Extra term void OrientationAcceleration().
but get an error.
#include <Pozyx.h>
#include <Pozyx_definitions.h>
#include <Wire.h>
////////////////////////////////////////////////
////////////////// PARAMETERS //////////////////
////////////////////////////////////////////////
uint16_t remote_id = 0x6000; // set this to the ID of the remote device
bool remote = false; // set this to true to use the remote ID
boolean use_processing = false; // set this to true to output data for the processing sketch
const uint8_t num_anchors = 4; // the number of anchors
uint16_t anchors[num_anchors] = {0x1156, 0x256B, 0x3325, 0x4244}; // the network id of the anchors: change these to the network ids of your anchors.
int32_t anchors_x[num_anchors] = {0, 4500, 500, 4450}; // anchor x-coorindates in mm
int32_t anchors_y[num_anchors] = {0, 0, 3300, 3500}; // anchor y-coordinates in mm
int32_t heights[num_anchors] = {1500, 1800, 1100, 2000}; // anchor z-coordinates in mm
uint8_t algorithm = POZYX_POS_ALG_UWB_ONLY; // positioning algorithm to use. try POZYX_POS_ALG_TRACKING for fast moving objects.
uint8_t dimension = POZYX_3D; // positioning dimension
int32_t height = 1000; // height of device, required in 2.5D positioning
////////////////////////////////////////////////
void setup(){
Serial.begin(115200);
if(Pozyx.begin() == POZYX_FAILURE){
Serial.println(F("ERROR: Unable to connect to POZYX shield"));
Serial.println(F("Reset required"));
delay(100);
abort();
}
if(!remote){
remote_id = NULL;
}
Serial.println(F("----------POZYX POSITIONING V1.1----------"));
Serial.println(F("NOTES:"));
Serial.println(F("- No parameters required."));
Serial.println();
Serial.println(F("- System will auto start anchor configuration"));
Serial.println();
Serial.println(F("- System will auto start positioning"));
Serial.println(F("----------POZYX POSITIONING V1.1----------"));
Serial.println();
Serial.println(F("Performing manual anchor configuration:"));
// clear all previous devices in the device list
Pozyx.clearDevices(remote_id);
// sets the anchor manually
setAnchorsManual();
// sets the positioning algorithm
Pozyx.setPositionAlgorithm(algorithm, dimension, remote_id);
printCalibrationResult();
delay(2000);
Serial.println(F("Starting positioning: "));
}
void loop(){
coordinates_t position;
int status;
if(remote){
status = Pozyx.doRemotePositioning(remote_id, &position, dimension, height, algorithm);
}else{
status = Pozyx.doPositioning(&position, dimension, height, algorithm);
}
if (status == POZYX_SUCCESS){
// prints out the result
printCoordinates(position);
printOrientationAcceleration();
}else{
// prints out the error code
printErrorCode("positioning");
}
}
// prints the coordinates for either humans or for processing
void printCoordinates(coordinates_t coor){
uint16_t network_id = remote_id;
if (network_id == NULL){
network_id = 0;
}
if(!use_processing){
Serial.print("POS ID 0x");
Serial.print(network_id, HEX);
Serial.print(", x(mm): ");
Serial.print(coor.x);
Serial.print(", y(mm): ");
Serial.print(coor.y);
Serial.print(", z(mm): ");
Serial.println(coor.z);
}else{
Serial.print("POS,0x");
Serial.print(network_id,HEX);
Serial.print(",");
Serial.print(coor.x);
Serial.print(",");
Serial.print(coor.y);
Serial.print(",");
Serial.println(coor.z);
}
}
// error printing function for debugging
void printErrorCode(String operation){
uint8_t error_code;
if (remote_id == NULL){
Pozyx.getErrorCode(&error_code);
Serial.print("ERROR ");
Serial.print(operation);
Serial.print(", local error code: 0x");
Serial.println(error_code, HEX);
return;
}
int status = Pozyx.getErrorCode(&error_code, remote_id);
if(status == POZYX_SUCCESS){
Serial.print("ERROR ");
Serial.print(operation);
Serial.print(" on ID 0x");
Serial.print(remote_id, HEX);
Serial.print(", error code: 0x");
Serial.println(error_code, HEX);
}else{
Pozyx.getErrorCode(&error_code);
Serial.print("ERROR ");
Serial.print(operation);
Serial.print(", couldn't retrieve remote error code, local error: 0x");
Serial.println(error_code, HEX);
}
}
// print out the anchor coordinates (also required for the processing sketch)
void printCalibrationResult(){
uint8_t list_size;
int status;
status = Pozyx.getDeviceListSize(&list_size, remote_id);
Serial.print("list size: ");
Serial.println(status*list_size);
if(list_size == 0){
printErrorCode("configuration");
return;
}
uint16_t device_ids[list_size];
status &= Pozyx.getDeviceIds(device_ids, list_size, remote_id);
Serial.println(F("Calibration result:"));
Serial.print(F("Anchors found: "));
Serial.println(list_size);
coordinates_t anchor_coor;
for(int i = 0; i < list_size; i++)
{
Serial.print("ANCHOR,");
Serial.print("0x");
Serial.print(device_ids[i], HEX);
Serial.print(",");
Pozyx.getDeviceCoordinates(device_ids[i], &anchor_coor, remote_id);
Serial.print(anchor_coor.x);
Serial.print(",");
Serial.print(anchor_coor.y);
Serial.print(",");
Serial.println(anchor_coor.z);
}
}
// function to manually set the anchor coordinates
void setAnchorsManual(){
for(int i = 0; i < num_anchors; i++){
device_coordinates_t anchor;
anchor.network_id = anchors[i];
anchor.flag = 0x1;
anchor.pos.x = anchors_x[i];
anchor.pos.y = anchors_y[i];
anchor.pos.z = heights[i];
Pozyx.addDevice(anchor, remote_id);
}
if (num_anchors > 4){
Pozyx.setSelectionOfAnchors(POZYX_ANCHOR_SEL_AUTO, num_anchors, remote_id);
}
}
void printOrientationAcceleration(){
orientation = euler_angles_t;
acceleration = acceleration_t;
Pozyx.getEulerAngles_deg(&orientation, remote_id);
Pozyx.getAcceleration_mg(&acceleration, remote_id);
Serial.print("Orientation: Heading:");
Serial.print(orientation.heading);
Serial.print(", Roll:");
Serial.print(orientation.roll);
Serial.print(", Pitch:");
Serial.print(orientation.pitch);
Serial.print(", acceleration: X:");
Serial.print(acceleration.x);
Serial.print(", Y:");
Serial.print(acceleration.y);
Serial.print(", Z:");
Serial.print(acceleration.z);
}
[error massage]
/tmp/397334755/sketch_jun19a/sketch_jun19a.ino: In function ‘void printOrientationAcceleration()’:
/tmp/397334755/sketch_jun19a/sketch_jun19a.ino:201:3: error: ‘orientation’ was not declared in this scope
orientation = euler_angles_t;
^
/tmp/397334755/sketch_jun19a/sketch_jun19a.ino:201:31: error: expected primary-expression before ‘;’ token
orientation = euler_angles_t;
^
/tmp/397334755/sketch_jun19a/sketch_jun19a.ino:202:3: error: ‘acceleration’ was not declared in this scope
acceleration = acceleration_t;
^
/tmp/397334755/sketch_jun19a/sketch_jun19a.ino:202:32: error: expected primary-expression before ‘;’ token
acceleration = acceleration_t;
^
exit status 1