-
Notifications
You must be signed in to change notification settings - Fork 158
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
add external properties to SolutionInfo #194
Open
v4hn
wants to merge
12
commits into
moveit:master
Choose a base branch
from
v4hn:pr-external-properties
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from 1 commit
Commits
Show all changes
12 commits
Select commit
Hold shift + click to select a range
7139e99
add properties to SolutionInfo
v4hn 5646ecf
move typed getters to Property & drop fallback interface
v4hn 3277abf
add PropertyMap -> vector<Msg> interface
v4hn ac22156
do not allow write-access to default value
v4hn 476424d
lipstick
v4hn 5d419bd
working implementation for deserialization
v4hn fb0fa19
[POC] add message property as rviz property
v4hn bee6265
Simplify definition of PropertySerializer<T>
rhaschke 09d2978
Skip Base64 encoding
rhaschke 0d3ce1d
Correctly define serialization for std::map<std::string, double>
rhaschke 4b8957c
Back to has*Operator<T>
rhaschke 45935c0
Fix precision issue for floating-point types
rhaschke File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
134 changes: 134 additions & 0 deletions
134
core/include/moveit/task_constructor/properties/base64.hpp
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,134 @@ | ||
/** | ||
* @file base64.h | ||
* @author Basit Ayantunde ([email protected]) | ||
* @brief | ||
* @version 0.1 | ||
* @date 2019-09-08 | ||
* | ||
* @copyright Copyright (c) 2019 | ||
* | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
|
||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
* | ||
*/ | ||
|
||
#ifndef LAMAR_BASE64_H | ||
#define LAMAR_BASE64_H | ||
#include <cstring> | ||
#include <string> | ||
|
||
namespace base64 { | ||
|
||
template <typename T = char> | ||
struct Base64Chars | ||
{ | ||
static constexpr T data[]{ "ABCDEFGHIJKLMNOPQRSTUVWXYZ" | ||
"abcdefghijklmnopqrstuvwxyz" | ||
"0123456789+/" }; | ||
}; | ||
|
||
template <typename T> | ||
constexpr T Base64Chars<T>::data[]; | ||
|
||
template <typename T = char> | ||
inline bool is_base64(T c) { | ||
return (isalnum(c) || (c == '+') || (c == '/')); | ||
} | ||
|
||
template <typename T = char> | ||
std::basic_string<T> encode(const T* bytes_to_encode, uint32_t in_len) { | ||
std::basic_string<T> ret; | ||
int i = 0; | ||
int j = 0; | ||
T char_array_3[3]; | ||
T char_array_4[4]; | ||
|
||
while (in_len--) { | ||
char_array_3[i++] = *(bytes_to_encode++); | ||
if (i == 3) { | ||
char_array_4[0] = (char_array_3[0] & 0xfc) >> 2; | ||
char_array_4[1] = ((char_array_3[0] & 0x03) << 4) + ((char_array_3[1] & 0xf0) >> 4); | ||
char_array_4[2] = ((char_array_3[1] & 0x0f) << 2) + ((char_array_3[2] & 0xc0) >> 6); | ||
char_array_4[3] = char_array_3[2] & 0x3f; | ||
|
||
for (i = 0; (i < 4); i++) | ||
ret += Base64Chars<T>::data[char_array_4[i]]; | ||
i = 0; | ||
} | ||
} | ||
|
||
if (i) { | ||
for (j = i; j < 3; j++) | ||
char_array_3[j] = '\0'; | ||
|
||
char_array_4[0] = (char_array_3[0] & 0xfc) >> 2; | ||
char_array_4[1] = ((char_array_3[0] & 0x03) << 4) + ((char_array_3[1] & 0xf0) >> 4); | ||
char_array_4[2] = ((char_array_3[1] & 0x0f) << 2) + ((char_array_3[2] & 0xc0) >> 6); | ||
char_array_4[3] = char_array_3[2] & 0x3f; | ||
|
||
for (j = 0; (j < i + 1); j++) | ||
ret += Base64Chars<T>::data[char_array_4[j]]; | ||
|
||
while ((i++ < 3)) | ||
ret += '='; | ||
} | ||
|
||
return std::move(ret); | ||
} | ||
|
||
template <typename T = char> | ||
std::basic_string<T> decode(const T* encoded_string, int64_t in_len) { | ||
int i = 0; | ||
int j = 0; | ||
int in_ = 0; | ||
T char_array_4[4], char_array_3[3]; | ||
std::basic_string<T> ret; | ||
|
||
while (in_len-- && (encoded_string[in_] != '=') && is_base64(encoded_string[in_])) { | ||
char_array_4[i++] = encoded_string[in_]; | ||
in_++; | ||
if (i == 4) { | ||
for (i = 0; i < 4; i++) | ||
char_array_4[i] = strchr(Base64Chars<T>::data, char_array_4[i]) - Base64Chars<T>::data; | ||
|
||
char_array_3[0] = (char_array_4[0] << 2) + ((char_array_4[1] & 0x30) >> 4); | ||
char_array_3[1] = ((char_array_4[1] & 0xf) << 4) + ((char_array_4[2] & 0x3c) >> 2); | ||
char_array_3[2] = ((char_array_4[2] & 0x3) << 6) + char_array_4[3]; | ||
|
||
for (i = 0; (i < 3); i++) | ||
ret += char_array_3[i]; | ||
i = 0; | ||
} | ||
} | ||
|
||
if (i) { | ||
for (j = i; j < 4; j++) | ||
char_array_4[j] = 0; | ||
|
||
for (j = 0; j < 4; j++) | ||
char_array_4[j] = strchr(Base64Chars<T>::data, char_array_4[j]) - Base64Chars<T>::data; | ||
|
||
char_array_3[0] = (char_array_4[0] << 2) + ((char_array_4[1] & 0x30) >> 4); | ||
char_array_3[1] = ((char_array_4[1] & 0xf) << 4) + ((char_array_4[2] & 0x3c) >> 2); | ||
char_array_3[2] = ((char_array_4[2] & 0x3) << 6) + char_array_4[3]; | ||
|
||
for (j = 0; (j < i - 1); j++) | ||
ret += char_array_3[j]; | ||
} | ||
|
||
return std::move(ret); | ||
} | ||
|
||
}; // namespace base64 | ||
|
||
#endif |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.