60#ifndef WHITEBOARD_POSTER_STRING_CONVERSION
61#define WHITEBOARD_POSTER_STRING_CONVERSION
72#pragma clang diagnostic push
73#pragma clang diagnostic ignored "-Wunused-macros"
77#elif defined(__APPLE__)
78# include <machine/endian.h>
79# include <architecture/byte_order.h>
80# define bswap_16(x) NXSwapShort(x)
81# define bswap_32(x) NXSwapInt(x)
82# define bswap_64(x) NXSwapLongLong(x)
84# define bswap_16(x) __builtin_bswap16(x)
85# define bswap_32(x) __builtin_bswap32(x)
86# define bswap_64(x) __builtin_bswap64(x)
91#if (!defined(__BYTE_ORDER) && !defined(__LITTLE_ENDIAN)) || (defined(__BYTE_ORDER) && defined(__LITTLE_ENDIAN) && __BYTE_ORDER == __LITTLE_ENDIAN)
92# if !defined(htonll) && !defined(ntohll)
93# define htonll(x) bswap_64(x)
94# define ntohll(x) bswap_64(x)
96# if !defined(htonl) && !defined(ntohl)
97# define htonl(x) bswap_32(x)
98# define ntohl(x) bswap_32(x)
100# if !defined(htons) && !defined(ntohs)
101# define htons(x) bswap_16(x)
102# define ntohs(x) bswap_16(x)
105# if !defined(htonll) && !defined(ntohll)
106# define htonll(x) (x)
107# define ntohll(x) (x)
109# if !defined(htonl) && !defined(ntohl)
113# if !defined(htons) && !defined(ntohs)
118#pragma clang diagnostic pop
127#pragma clang diagnostic push
128#pragma clang diagnostic ignored "-Wunused-variable"
130 if (len >= bufferSize) {
133 switch (self->walkEngineState) {
136 len += snprintf(descString + len, bufferSize - len,
"walkEngineState=wes_Disconnected");
141 len += snprintf(descString + len, bufferSize - len,
"walkEngineState=wes_StoppedReady");
146 len += snprintf(descString + len, bufferSize - len,
"walkEngineState=wes_StoppedStanding");
151 len += snprintf(descString + len, bufferSize - len,
"walkEngineState=wes_Walking");
155 if (len >= bufferSize) {
158 len = gu_strlcat(descString,
", ", bufferSize);
159 if (len >= bufferSize) {
162 len = gu_strlcat(descString,
"odometry={", bufferSize);
163 if (len >= bufferSize) {
167 char* odometry_p = odometry_buffer;
169 len = gu_strlcat(descString, odometry_p, bufferSize);
170 if (len >= bufferSize) {
173 len = gu_strlcat(descString,
"}", bufferSize);
174 if (len >= bufferSize) {
177 len = gu_strlcat(descString,
", ", bufferSize);
178 if (len >= bufferSize) {
181 len += snprintf(descString + len, bufferSize - len,
"odometryResetCounter=%u", self->odometryResetCounter);
183#pragma clang diagnostic pop
191#pragma clang diagnostic push
192#pragma clang diagnostic ignored "-Wunused-variable"
194 if (len >= bufferSize) {
197 switch (self->walkEngineState) {
200 len += snprintf(toString + len, bufferSize - len,
"wes_Disconnected");
205 len += snprintf(toString + len, bufferSize - len,
"wes_StoppedReady");
210 len += snprintf(toString + len, bufferSize - len,
"wes_StoppedStanding");
215 len += snprintf(toString + len, bufferSize - len,
"wes_Walking");
219 if (len >= bufferSize) {
222 len = gu_strlcat(toString,
", ", bufferSize);
223 if (len >= bufferSize) {
226 len = gu_strlcat(toString,
"{", bufferSize);
227 if (len >= bufferSize) {
231 char* odometry_p = odometry_buffer;
233 len = gu_strlcat(toString, odometry_p, bufferSize);
234 if (len >= bufferSize) {
237 len = gu_strlcat(toString,
"}", bufferSize);
238 if (len >= bufferSize) {
241 len = gu_strlcat(toString,
", ", bufferSize);
242 if (len >= bufferSize) {
245 len += snprintf(toString + len, bufferSize - len,
"%u", self->odometryResetCounter);
247#pragma clang diagnostic pop
255 size_t temp_length = strlen(str);
256 int length = (temp_length <= INT_MAX) ? ((
int)((ssize_t)temp_length)) : -1;
261 char* var_str = &var_str_buffer[0];
263 char* key = &key_buffer[0];
270 if (index == 0 && str[0] ==
'{') {
276 for (
int i = index; i < length; i++) {
278 if (bracecount == 0 && str[i] ==
'=') {
283 if (bracecount == 0 && isspace(str[i])) {
290 if (bracecount == 0 && str[i] ==
',') {
300 if (bracecount < 0) {
305 if (i == length - 1) {
309 if (endKey >= startKey && endKey - startKey < length) {
310 strncpy(key, str + startKey, ((
size_t)(endKey - startKey) + 1));
311 key[(endKey - startKey) + 1] = 0;
315 strncpy(var_str, str + startVar, ((
size_t)(index - startVar) + 1));
316 var_str[(index - startVar) + 1] = 0;
322 if (strlen(key) > 0) {
323 if (0 == strcmp(
"walkEngineState", key)) {
325 }
else if (0 == strcmp(
"odometry", key)) {
327 }
else if (0 == strcmp(
"odometryResetCounter", key)) {
337 if (strcmp(
"wes_Disconnected", var_str) == 0) {
338#pragma clang diagnostic push
339#pragma clang diagnostic ignored "-Wbad-function-cast"
341#pragma clang diagnostic pop
342 }
else if (strcmp(
"wes_StoppedReady", var_str) == 0) {
343#pragma clang diagnostic push
344#pragma clang diagnostic ignored "-Wbad-function-cast"
346#pragma clang diagnostic pop
347 }
else if (strcmp(
"wes_StoppedStanding", var_str) == 0) {
348#pragma clang diagnostic push
349#pragma clang diagnostic ignored "-Wbad-function-cast"
351#pragma clang diagnostic pop
352 }
else if (strcmp(
"wes_Walking", var_str) == 0) {
353#pragma clang diagnostic push
354#pragma clang diagnostic ignored "-Wbad-function-cast"
356#pragma clang diagnostic pop
358#pragma clang diagnostic push
359#pragma clang diagnostic ignored "-Wbad-function-cast"
361#pragma clang diagnostic pop
372 self->odometryResetCounter = ((uint8_t)atoi(var_str));
379 }
while(index < length);
390 uint16_t bit_offset = 0;
394 for (b = (32 - 1); b >= 0; b--) {
396 uint16_t
byte = bit_offset / 8;
397 uint16_t bit = 7 - (bit_offset % 8);
398 unsigned long newbit = !!((walkEngineState_nbo >> b) & 1U);
399 dst[byte] ^= (-newbit ^ dst[byte]) & (1UL << bit);
400 bit_offset = bit_offset + 1;
405 uint8_t odometryResetCounter_nbo = (
self->odometryResetCounter);
408 for (b = (8 - 1); b >= 0; b--) {
410 uint16_t
byte = bit_offset / 8;
411 uint16_t bit = 7 - (bit_offset % 8);
412 unsigned long newbit = !!((odometryResetCounter_nbo >> b) & 1U);
413 dst[byte] ^= (-newbit ^ dst[byte]) & (1UL << bit);
414 bit_offset = bit_offset + 1;
429 uint16_t bit_offset = 0;
432 for (b = (32 - 1); b >= 0; b--) {
434 uint16_t
byte = bit_offset / 8;
435 uint16_t bit = 7 - (bit_offset % 8);
436 char dataByte = src[byte];
437 unsigned char bitValue = (dataByte >> bit) & 1U;
439 bit_offset = bit_offset + 1;
447 for (b = (8 - 1); b >= 0; b--) {
449 uint16_t
byte = bit_offset / 8;
450 uint16_t bit = 7 - (bit_offset % 8);
451 char dataByte = src[byte];
452 unsigned char bitValue = (dataByte >> bit) & 1U;
454 bit_offset = bit_offset + 1;
WHITEBOARD_POSTER_STRING_CONVERSION.
enum WalkEngineState walkEngineState
The current state of the walk engine, see enum documentation.
uint8_t odometryResetCounter
A counter used to reset the odometry object, change this value and send it via NaoWalkCommand to trig...
const char * wb_nao_walk_status_description(const struct wb_nao_walk_status *self, char *descString, size_t bufferSize)
Convert to a description string.
size_t wb_nao_walk_status_from_network_serialised(const char *src, struct wb_nao_walk_status *dst)
Convert from a compressed, serialised, network byte order byte stream.
size_t wb_nao_walk_status_to_network_serialised(const struct wb_nao_walk_status *self, char *dst)
Convert to a compressed, serialised, network byte order byte stream.
const char * wb_nao_walk_status_to_string(const struct wb_nao_walk_status *self, char *toString, size_t bufferSize)
Convert to a string.
struct wb_nao_walk_status * wb_nao_walk_status_from_string(struct wb_nao_walk_status *self, const char *str)
Convert from a string.
#define NAOWALKSTATUS_DESC_BUFFER_SIZE
@ wes_StoppedReady
In the Crouched stance, ready to walk again straight away but not currently moving anywhere.
@ wes_StoppedStanding
In the Standing position, this position uses less power than Stopped / Crouched, it is a minimal stif...
@ wes_Walking
Walking around, includes stopping, kicking, transition from Standing etc... basically the walk engine...
@ wes_Disconnected
Not connected to the DCM, does not control any joints in this state.
const char * wb_odometry_to_string(const struct wb_odometry *self, char *toString, size_t bufferSize)
Convert to a string.
const char * wb_odometry_description(const struct wb_odometry *self, char *descString, size_t bufferSize)
Convert to a description string.
struct wb_odometry * wb_odometry_from_string(struct wb_odometry *self, const char *str)
Convert from a string.
#define ODOMETRY_DESC_BUFFER_SIZE
#define ODOMETRY_TO_STRING_BUFFER_SIZE