Skip to content

Commit

Permalink
Client update Call methods, add jsonize types
Browse files Browse the repository at this point in the history
  • Loading branch information
holiray committed Dec 31, 2024
1 parent 77ad559 commit 70c6f57
Show file tree
Hide file tree
Showing 5 changed files with 27 additions and 7 deletions.
16 changes: 16 additions & 0 deletions include/unitree/common/json/jsonize.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,14 @@ class Jsonize
virtual void fromJson(JsonMap& a) = 0;
};

void FromAny(const Any& a, int8_t& value);

void FromAny(const Any& a, uint8_t& value);

void FromAny(const Any& a, int16_t& value);

void FromAny(const Any& a, uint16_t& value);

void FromAny(const Any& a, int32_t& value);

void FromAny(const Any& a, uint32_t& value);
Expand Down Expand Up @@ -153,6 +161,14 @@ void FromJson(const Any& a, T& t)
FromAny(a, t);
}

void ToAny(const int8_t& value, Any& a);

void ToAny(const uint8_t& value, Any& a);

void ToAny(const int16_t& value, Any& a);

void ToAny(const uint16_t& value, Any& a);

void ToAny(const int32_t& value, Any& a);

void ToAny(const uint32_t& value, Any& a);
Expand Down
10 changes: 6 additions & 4 deletions include/unitree/robot/client/client.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@
#define UT_ROBOT_CLIENT_REG_API_NO_PROI(apiId) \
UT_ROBOT_CLIENT_REG_API(apiId, 0)

#define UT_ROBOT_CLIENT_REG_API(apiId, proirity) \
RegistApi(apiId, proirity)
#define UT_ROBOT_CLIENT_REG_API(apiId, priority) \
RegistApi(apiId, priority)

namespace unitree
{
Expand Down Expand Up @@ -41,8 +41,10 @@ class Client: public ClientBase
int32_t Call(int32_t apiId, const std::vector<uint8_t>& parameter, std::vector<uint8_t>& data);
int32_t Call(int32_t apiId, const std::vector<uint8_t>& parameter);

void RegistApi(int32_t apiId, int32_t proirity = 0);
int32_t CheckApi(int32_t apiId, int32_t& proirity, int64_t& leaseId);
int32_t Call(int32_t apiId, const std::string& parameter, const std::vector<uint8_t>& binary);

void RegistApi(int32_t apiId, int32_t priority = 0);
int32_t CheckApi(int32_t apiId, int32_t& priority, int64_t& leaseId);

private:
bool mEnableLease;
Expand Down
8 changes: 5 additions & 3 deletions include/unitree/robot/client/client_base.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -29,13 +29,15 @@ class ClientBase
void SetTimeout(float timeout);

protected:
int32_t Call(int32_t apiId, const std::string& parameter, std::string& data, int32_t proirity, int64_t leaseId);
int32_t Call(int32_t apiId, const std::string& parameter, std::string& data, int32_t priority, int64_t leaseId);
int32_t Call(int32_t apiId, const std::string& parameter, int32_t priority, int64_t leaseId);

int32_t Call(int32_t apiId, const std::vector<uint8_t>& parameter, std::vector<uint8_t>& bin_data, int32_t proirity, int64_t leaseId);
int32_t Call(int32_t apiId, const std::vector<uint8_t>& parameter, std::vector<uint8_t>& bin_data, int32_t priority, int64_t leaseId);
int32_t Call(int32_t apiId, const std::vector<uint8_t>& parameter, int32_t priority, int64_t leaseId);

int32_t Call(int32_t apiId, const std::string& parameter, std::string& data, int32_t proirity, int64_t leaseId, int64_t timeout);
int32_t Call(int32_t apiId, const std::string& parameter, const std::vector<uint8_t>& binary, int32_t priority, int64_t leaseId);

int32_t Call(int32_t apiId, const std::string& parameter, std::string& data, int32_t priority, int64_t leaseId, int64_t timeout);

void SetHeader(RequestHeader& header, int32_t apiId, int64_t leaseId, int32_t priority, bool noReply);

Expand Down
Binary file modified lib/aarch64/libunitree_sdk2.a
Binary file not shown.
Binary file modified lib/x86_64/libunitree_sdk2.a
Binary file not shown.

0 comments on commit 70c6f57

Please sign in to comment.