Skip to content

Commit 9e986d7

Browse files
author
Taiju Yamada
committed
Merge remote-tracking branch 'origin/master' into githubaction
2 parents ff29a3e + a7995ce commit 9e986d7

8 files changed

+44
-20
lines changed

CHANELOG.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,13 @@
11
# Changelog
22

3+
## 0.72.0 (2024-04-27)
4+
5+
- change `CreateLogEntries` to use `vector<LogEntry>` for memory optimization
6+
7+
## 0.71.0 (2024-03-26)
8+
9+
- Add objectType field in RegisterMinViableRegionInfo
10+
311
## 0.70.2 (2023-11-21)
412

513
- Fix memory leak by incorrect usage of `curl_formfree`.

CMakeLists.txt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,8 @@ set( CMAKE_ALLOW_LOOSE_LOOP_CONSTRUCTS TRUE )
1818
# Define here the needed parameters
1919
# make sure to change the version in docs/Makefile
2020
set (MUJINCLIENT_VERSION_MAJOR 0)
21-
set (MUJINCLIENT_VERSION_MINOR 70)
22-
set (MUJINCLIENT_VERSION_PATCH 2)
21+
set (MUJINCLIENT_VERSION_MINOR 72)
22+
set (MUJINCLIENT_VERSION_PATCH 0)
2323
set (MUJINCLIENT_VERSION ${MUJINCLIENT_VERSION_MAJOR}.${MUJINCLIENT_VERSION_MINOR}.${MUJINCLIENT_VERSION_PATCH})
2424
set (MUJINCLIENT_SOVERSION ${MUJINCLIENT_VERSION_MAJOR}.${MUJINCLIENT_VERSION_MINOR})
2525
set (CLIENT_SOVERSION ${MUJINCLIENT_VERSION_MAJOR}.${MUJINCLIENT_VERSION_MINOR})

include/mujincontrollerclient/binpickingtask.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -217,6 +217,7 @@ class MUJINCLIENT_API BinPickingTaskResource : public TaskResource
217217
std::array<double, 3> translation; ///< Translation of the 2D MVR plane (height = 0)
218218
std::array<double, 4> quaternion; ///< Rotation of the 2D MVR plane (height = 0)
219219
double objectWeight; ///< If non-zero, use this weight fo registration. unit is kg. zero means unknown.
220+
std::string objectType; ///< The type of the object
220221
uint64_t sensorTimeStampMS; ///< Same as DetectedObject's timestamp sent to planning
221222
double robotDepartStopTimestamp; ///< Force capture after robot stops
222223
std::array<double, 3> liftedWorldOffset; ///< [dx, dy, dz], mm in world frame

include/mujincontrollerclient/mujincontrollerclient.h

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -144,6 +144,13 @@ struct LogEntryAttachment
144144
{
145145
std::string filename; // filename
146146
std::vector<unsigned char> data; // data for the attachment
147+
148+
// default constructor
149+
LogEntryAttachment() = default;
150+
151+
// move constructor (delete copy constructor)
152+
LogEntryAttachment(LogEntryAttachment&& other) = default;
153+
LogEntryAttachment& operator=(LogEntryAttachment&& other) = default;
147154
};
148155

149156
typedef boost::shared_ptr<LogEntryAttachment> LogEntryAttachmentPtr;
@@ -154,7 +161,7 @@ struct LogEntry
154161
{
155162
rapidjson::Value rEntry; // log entry data in JSON format
156163
std::string logType; // log type
157-
std::vector<LogEntryAttachmentPtr> attachments; // a list of related attachments
164+
std::vector<LogEntryAttachment> attachments; // a list of related attachments
158165
};
159166

160167
typedef boost::shared_ptr<LogEntry> LogEntryPtr;
@@ -724,7 +731,7 @@ class MUJINCLIENT_API ControllerClient
724731
/// \param logEntries a vector of log entries to upload
725732
/// \param createdLogEntryIds an optional vector for storing the created log entry ids
726733
/// \param timeout timeout of uploading log entries in seconds
727-
virtual void CreateLogEntries(const std::vector<LogEntryPtr>& logEntries, std::vector<std::string>& createdLogEntryIds, double timeout = 5) = 0;
734+
virtual void CreateLogEntries(const std::vector<LogEntry>& logEntries, std::vector<std::string>& createdLogEntryIds, double timeout = 5) = 0;
728735
};
729736

730737
class MUJINCLIENT_API WebResource

include/mujincontrollerclient/mujinjson.h

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -293,6 +293,18 @@ inline void LoadJsonValue(const rapidjson::Value& v, int& t) {
293293
}
294294
}
295295

296+
inline void LoadJsonValue(const rapidjson::Value& v, int16_t& t) {
297+
if (v.IsInt()) {
298+
t = v.GetInt();
299+
} else if (v.IsString()) {
300+
t = boost::lexical_cast<int16_t>(v.GetString());
301+
} else if (v.IsBool()) {
302+
t = v.GetBool() ? 1 : 0;
303+
} else {
304+
throw MujinJSONException("Cannot convert JSON type %s to Int" + GetJsonString(v));
305+
}
306+
}
307+
296308
inline void LoadJsonValue(const rapidjson::Value& v, int8_t& t) {
297309
if (v.IsInt()) {
298310
t = v.GetInt();

src/binpickingtask.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,7 @@ BinPickingTaskResource::ResultGetBinpickingState::RegisterMinViableRegionInfo& B
8383
translation = rhs.translation;
8484
quaternion = rhs.quaternion;
8585
objectWeight = rhs.objectWeight;
86+
objectType = rhs.objectType;
8687
sensorTimeStampMS = rhs.sensorTimeStampMS;
8788
robotDepartStopTimestamp = rhs.robotDepartStopTimestamp;
8889
liftedWorldOffset = rhs.liftedWorldOffset;
@@ -124,6 +125,7 @@ void BinPickingTaskResource::ResultGetBinpickingState::RegisterMinViableRegionIn
124125
SetJsonValueByKey(rInfo, "translation", translation, alloc);
125126
SetJsonValueByKey(rInfo, "quaternion", quaternion, alloc);
126127
SetJsonValueByKey(rInfo, "objectWeight", objectWeight, alloc);
128+
SetJsonValueByKey(rInfo, "objectType", objectType, alloc);
127129
SetJsonValueByKey(rInfo, "sensorTimeStampMS", sensorTimeStampMS, alloc);
128130
SetJsonValueByKey(rInfo, "robotDepartStopTimestamp", robotDepartStopTimestamp, alloc);
129131

@@ -171,6 +173,7 @@ void BinPickingTaskResource::ResultGetBinpickingState::RegisterMinViableRegionIn
171173
LoadJsonValueByKey(rInfo, "translation", translation);
172174
LoadJsonValueByKey(rInfo, "quaternion", quaternion);
173175
objectWeight = GetJsonValueByKey<double>(rInfo, "objectWeight", 0);
176+
LoadJsonValueByKey(rInfo, "objectType", objectType);
174177
sensorTimeStampMS = GetJsonValueByKey<uint64_t>(rInfo, "sensorTimeStampMS", 0);
175178
robotDepartStopTimestamp = GetJsonValueByKey<double>(rInfo, "robotDepartStopTimestamp", 0);
176179

src/controllerclientimpl.cpp

Lines changed: 8 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -2078,7 +2078,7 @@ void ControllerClientImpl::ListFilesInController(std::vector<FileEntry>& fileent
20782078
}
20792079
}
20802080

2081-
void ControllerClientImpl::CreateLogEntries(const std::vector<LogEntryPtr>& logEntries, std::vector<std::string>& createdLogEntryIds, double timeout)
2081+
void ControllerClientImpl::CreateLogEntries(const std::vector<LogEntry>& logEntries, std::vector<std::string>& createdLogEntryIds, double timeout)
20822082
{
20832083
if (logEntries.empty()) {
20842084
return;
@@ -2104,32 +2104,25 @@ void ControllerClientImpl::CreateLogEntries(const std::vector<LogEntryPtr>& logE
21042104
rapidjson::StringBuffer& rRequestStringBuffer = _rRequestStringBufferCache;
21052105
rapidjson::Writer<rapidjson::StringBuffer> writer(rRequestStringBuffer);
21062106

2107-
for (const LogEntryPtr logEntry : logEntries) {
2108-
if (!logEntry) {
2109-
continue;
2110-
}
2111-
2107+
for (const LogEntry &logEntry : logEntries) {
21122108
// add log entry content
21132109
rRequestStringBuffer.Clear();
21142110
writer.Reset(rRequestStringBuffer);
2115-
logEntry->rEntry.Accept(writer);
2116-
std::string formName = "logEntry/" + logEntry->logType;
2111+
logEntry.rEntry.Accept(writer);
2112+
std::string formName = "logEntry/" + logEntry.logType;
21172113
curl_formadd(&formpost, &lastptr,
21182114
CURLFORM_COPYNAME, formName.c_str(),
21192115
CURLFORM_COPYCONTENTS, rRequestStringBuffer.GetString(),
21202116
CURLFORM_CONTENTTYPE, "application/json",
21212117
CURLFORM_END);
21222118

21232119
// add attachments
2124-
for (const LogEntryAttachmentPtr attachment : logEntry->attachments) {
2125-
if (!attachment) {
2126-
continue;
2127-
}
2120+
for (const LogEntryAttachment &attachment : logEntry.attachments) {
21282121
curl_formadd(&formpost, &lastptr,
21292122
CURLFORM_COPYNAME, "attachment",
2130-
CURLFORM_BUFFER, attachment->filename.c_str(),
2131-
CURLFORM_BUFFERPTR, attachment->data.data(),
2132-
CURLFORM_BUFFERLENGTH, (long)(attachment->data.size()),
2123+
CURLFORM_BUFFER, attachment.filename.c_str(),
2124+
CURLFORM_BUFFERPTR, attachment.data.data(),
2125+
CURLFORM_BUFFERLENGTH, (long)(attachment.data.size()),
21332126
CURLFORM_END);
21342127
}
21352128
}

src/controllerclientimpl.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -172,7 +172,7 @@ class ControllerClientImpl : public ControllerClient, public boost::enable_share
172172
/// \param logEntries a vector of log entries to upload
173173
/// \param createdLogEntryIds an optional vector for storing the created log entry ids
174174
/// \param timeout timeout of uploading log entries in seconds
175-
void CreateLogEntries(const std::vector<LogEntryPtr>& logEntries, std::vector<std::string>& createdLogEntryIds, double timeout = 5) override;
175+
void CreateLogEntries(const std::vector<LogEntry>& logEntries, std::vector<std::string>& createdLogEntryIds, double timeout = 5) override;
176176

177177
inline std::string GetBaseUri() const
178178
{

0 commit comments

Comments
 (0)