repo_name
stringlengths
1
62
dataset
stringclasses
1 value
lang
stringclasses
11 values
pr_id
int64
1
20.1k
owner
stringlengths
2
34
reviewer
stringlengths
2
39
diff_hunk
stringlengths
15
262k
code_review_comment
stringlengths
1
99.6k
vectordb
github_2023
cpp
52
epsilla-cloud
richard-epsilla
@@ -0,0 +1,537 @@ +#include <iostream> +#include <sstream> +#include <algorithm> +#include <regex> +#include <stack> +#include <queue> +#include <unordered_map> +#include <vector> +#include <boost/algorithm/string/join.hpp> + +#include "db/catalog/meta_types.hpp" +#include "logger/logger.hpp" +#include "utils/status.hp...
Wrong indentation
vectordb
github_2023
cpp
52
epsilla-cloud
richard-epsilla
@@ -0,0 +1,537 @@ +#include <iostream> +#include <sstream> +#include <algorithm> +#include <regex> +#include <stack> +#include <queue> +#include <unordered_map> +#include <vector> +#include <boost/algorithm/string/join.hpp> + +#include "db/catalog/meta_types.hpp" +#include "logger/logger.hpp" +#include "utils/status.hp...
Rename to node_stack
vectordb
github_2023
cpp
52
epsilla-cloud
richard-epsilla
@@ -0,0 +1,537 @@ +#include <iostream> +#include <sstream> +#include <algorithm> +#include <regex> +#include <stack> +#include <queue> +#include <unordered_map> +#include <vector> +#include <boost/algorithm/string/join.hpp> + +#include "db/catalog/meta_types.hpp" +#include "logger/logger.hpp" +#include "utils/status.hp...
rename to operator_stack
vectordb
github_2023
cpp
52
epsilla-cloud
richard-epsilla
@@ -1,12 +1,14 @@ -#pragma once
Why removed this line? It is important to avoid duplicated include causing compiler issues
vectordb
github_2023
cpp
52
epsilla-cloud
richard-epsilla
@@ -718,15 +726,30 @@ bool VecSearchExecutor::BruteForceSearch(const float *query_data, const int64_t return true; } -Status VecSearchExecutor::Search(const float *query_data, const ConcurrentBitset &deleted, const size_t limit, const int64_t total_vector, int64_t &result_size) { +Status VecSearchExecutor::Search...
Forgot to tell TopKeyboard to remove this comment, let's comment it out or change it into debug log
vectordb
github_2023
cpp
52
epsilla-cloud
richard-epsilla
@@ -0,0 +1,44 @@ +#include <any> +#include <unordered_map> +#include <vector> + +#include "expr_types.hpp" + +namespace vectordb { +namespace query { +namespace expr { + +class ExprEvaluator { + public: + explicit ExprEvaluator( + std::vector<ExprNodePtr>& nodes, + std::unordered_map<std::string, size_t>& fi...
No need to use & here for a primitive type field, as the copy is very cheap
vectordb
github_2023
cpp
52
epsilla-cloud
richard-epsilla
@@ -0,0 +1,193 @@ +#include "expr_evaluator.hpp" + +#include <cmath> +#include <iostream> + +namespace vectordb { +namespace query { +namespace expr { + +ExprEvaluator::ExprEvaluator( + std::vector<ExprNodePtr>& nodes, + std::unordered_map<std::string, size_t>& field_name_mem_offset_map, + int64_t& primitive_o...
Can make the function name GetRealNumberFieldValue to cover double and float
vectordb
github_2023
python
50
epsilla-cloud
richard-epsilla
@@ -34,6 +34,22 @@ limit=2, with_distance=True ) + +print(code, response) + +pk_to_delete = [1, 2, 3, 4] +print("deleting pk ", pk_to_delete) +code = epsilla.delete_by_pk(table_name="MyTable", primary_keys=pk_to_delete)
Can we call this just delete? And use primary_keys and future filter condition as positional parameters to distinguish which underneath function to call?
vectordb
github_2023
cpp
50
epsilla-cloud
richard-epsilla
@@ -334,6 +334,39 @@ class WebController : public oatpp::web::server::api::ApiController { return createDtoResponse(Status::CODE_200, status_dto); } + ADD_CORS(DeleteRecordsByPK) + + ENDPOINT("POST", "/api/{db_name}/data/delete/pk", DeleteRecordsByPK,
Can we just use ""/api/{db_name}/data/delete"? Later we can use whether primaryKeys exist and whether filter condition exists to distinguish which underneath function to call
vectordb
github_2023
cpp
50
epsilla-cloud
richard-epsilla
@@ -189,6 +195,11 @@ TableSegmentMVP::TableSegmentMVP(meta::TableSchema& table_schema, const std::str // Read the string table for (auto i = 0; i < record_number_; ++i) { + // skip deleted entry + if (deleted_->test(i)) {
Can we skip? If we skip reading the file, the file cursor will messed up?
vectordb
github_2023
cpp
50
epsilla-cloud
richard-epsilla
@@ -133,6 +134,57 @@ Status DBServer::Insert(const std::string& db_name, return table->Insert(records); } +Status DBServer::DeleteByPK(const std::string& db_name, const std::string& table_name, vectordb::Json& pkList) { + auto db = GetDB(db_name); + if (db == nullptr) { + return Status(DB_UNEXPECTED_ERROR, "...
"Primary key not found"
vectordb
github_2023
cpp
50
epsilla-cloud
richard-epsilla
@@ -133,6 +134,57 @@ Status DBServer::Insert(const std::string& db_name, return table->Insert(records); } +Status DBServer::DeleteByPK(const std::string& db_name, const std::string& table_name, vectordb::Json& pkList) { + auto db = GetDB(db_name); + if (db == nullptr) { + return Status(DB_UNEXPECTED_ERROR, "...
PK -> Primary key pos -> field position
vectordb
github_2023
cpp
50
epsilla-cloud
richard-epsilla
@@ -133,6 +134,57 @@ Status DBServer::Insert(const std::string& db_name, return table->Insert(records); } +Status DBServer::DeleteByPK(const std::string& db_name, const std::string& table_name, vectordb::Json& pkList) { + auto db = GetDB(db_name); + if (db == nullptr) { + return Status(DB_UNEXPECTED_ERROR, "...
Same here
vectordb
github_2023
cpp
50
epsilla-cloud
richard-epsilla
@@ -133,6 +134,57 @@ Status DBServer::Insert(const std::string& db_name, return table->Insert(records); } +Status DBServer::DeleteByPK(const std::string& db_name, const std::string& table_name, vectordb::Json& pkList) { + auto db = GetDB(db_name); + if (db == nullptr) { + return Status(DB_UNEXPECTED_ERROR, "...
Unexpected primary key type
vectordb
github_2023
cpp
50
epsilla-cloud
richard-epsilla
@@ -694,32 +695,43 @@ bool VecSearchExecutor::BruteForceSearch(const float *query_data, const int64_t float dist = fstdistfunc_(vector_table_ + dimension_ * v_id, query_data, dist_func_param_); brute_force_queue_[v_id - start] = Candidate(v_id, dist, false); } + + // compacting the result with 2 pointers ...
Does frequent resize have performance problem?
vectordb
github_2023
cpp
50
epsilla-cloud
ricki-epsilla
@@ -334,38 +334,38 @@ class WebController : public oatpp::web::server::api::ApiController { return createDtoResponse(Status::CODE_200, status_dto); } - // TODO: implement with corresponding function later. - ADD_CORS(DeleteRecordsByID) + ADD_CORS(DeleteRecordsByPK) - ENDPOINT("POST", "/api/{db_name}/dat...
add payload validation check. ```suggestion auto valid = requestBody.LoadFromString(body); if (!valid) { status_dto->statusCode = Status::CODE_400.code; status_dto->message = "Invalid payload."; return createDtoResponse(Status::CODE_400, status_dto); } ```
vectordb
github_2023
cpp
42
epsilla-cloud
richard-epsilla
@@ -52,6 +52,10 @@ Status TableSegmentMVP::Init(meta::TableSchema& table_schema, int64_t size_limit if (field_schema.field_type_ == meta::FieldType::STRING) { field_id_mem_offset_map_[field_schema.id_] = string_num_; field_name_mem_offset_map_[field_schema.name_] = string_num_; + if (field_schem...
Assert will crash the engine. Can we use semantic check during schema creation to avoid it?
vectordb
github_2023
cpp
42
epsilla-cloud
richard-epsilla
@@ -306,9 +393,17 @@ Status TableSegmentMVP::Insert(meta::TableSchema& table_schema, Json& records, i } } ++cursor; + + LOOP_END : {} + // nothing should be done at the end of block } record_number_.store(cursor); - return Status::OK(); + auto msg = std::string("loading done. added entries:...
auto msg = "Successfully inserted " + std::to_string(new_record_size - skipped_entry) + records." if (skipped_entry > 0) { msg += "Skipped " + std::to_string(skipped_entry) + " records with primary key values that already exist." }
vectordb
github_2023
cpp
28
epsilla-cloud
richard-epsilla
@@ -58,7 +58,7 @@ class WriteAheadLog { RotateFile(); } int64_t next = global_counter_.IncrementAndGet(); - fprintf(file_, "%lld %d %s\n", next, type, entry.c_str()); + fprintf(file_, "%ld %d %s\n", next, type, entry.c_str());
This part is interesting. lld will not warning on macos. ld will not warning on linux. Cannot satisfy both
vectordb
github_2023
cpp
28
epsilla-cloud
richard-epsilla
@@ -0,0 +1,34 @@ +#define PY_SSIZE_T_CLEAN +#include <Python.h> +#include <string> +#include <memory> +#include "db/db_server.hpp" +static PyObject *EpsillaError; + +static PyObject *spam_system(PyObject *self, PyObject *args); +static PyObject *load_db(PyObject *self, PyObject *args); +static PyObject *use_db(PyObject...
There is also drop_table and unload_db
vectordb
github_2023
cpp
28
epsilla-cloud
richard-epsilla
@@ -0,0 +1,34 @@ +#define PY_SSIZE_T_CLEAN +#include <Python.h> +#include <string> +#include <memory> +#include "db/db_server.hpp" +static PyObject *EpsillaError; + +static PyObject *spam_system(PyObject *self, PyObject *args); +static PyObject *load_db(PyObject *self, PyObject *args); +static PyObject *use_db(PyObject...
Why not all functions above exposed here?
vectordb
github_2023
cpp
28
epsilla-cloud
richard-epsilla
@@ -68,6 +55,101 @@ static PyObject *use_db(PyObject *self, PyObject *args) db_name = namePtr; return PyLong_FromLong(0); } -static PyObject *create_table(PyObject *self, PyObject *args) {} +static PyObject *create_table(PyObject *self, PyObject *args)
does this mean we will need reimplement the interface and keep the native C++ and python binding implementation in sync from now on?
vectordb
github_2023
cpp
23
epsilla-cloud
richard-epsilla
@@ -183,6 +184,10 @@ Status BasicMetaImpl::LoadDatabase(std::string& db_catalog_path, const std::stri if (databases_.find(db_name) != databases_.end()) { return Status(DB_UNEXPECTED_ERROR, "DB already exists: " + db_name); } + std::regex pattern("[A-Za-z_][A-Za-z_0-9]*");
Can we have a validator function like isValidName for all name checks?
vectordb
github_2023
cpp
23
epsilla-cloud
richard-epsilla
@@ -259,6 +264,77 @@ Status BasicMetaImpl::DropDatabase(const std::string& db_name) { return Status::OK(); } +Status ValidateSchema(TableSchema& table_schema) { + // 1. Check table name + std::regex pattern("[A-Za-z_][A-Za-z_0-9]*");
Same here
vectordb
github_2023
cpp
23
epsilla-cloud
richard-epsilla
@@ -259,6 +264,77 @@ Status BasicMetaImpl::DropDatabase(const std::string& db_name) { return Status::OK(); } +Status ValidateSchema(TableSchema& table_schema) { + // 1. Check table name + std::regex pattern("[A-Za-z_][A-Za-z_0-9]*"); + if (!std::regex_match(table_schema.name_, pattern)) { + return Status(DB...
Typo: duplicated
vectordb
github_2023
cpp
23
epsilla-cloud
richard-epsilla
@@ -259,6 +264,77 @@ Status BasicMetaImpl::DropDatabase(const std::string& db_name) { return Status::OK(); } +Status ValidateSchema(TableSchema& table_schema) { + // 1. Check table name + std::regex pattern("[A-Za-z_][A-Za-z_0-9]*"); + if (!std::regex_match(table_schema.name_, pattern)) { + return Status(DB...
field -> fields
vectordb
github_2023
cpp
23
epsilla-cloud
richard-epsilla
@@ -259,6 +264,77 @@ Status BasicMetaImpl::DropDatabase(const std::string& db_name) { return Status::OK(); } +Status ValidateSchema(TableSchema& table_schema) { + // 1. Check table name + std::regex pattern("[A-Za-z_][A-Za-z_0-9]*"); + if (!std::regex_match(table_schema.name_, pattern)) { + return Status(DB...
Same here
NetAdmin
github_2023
csharp
177
nsnail
nsnail
@@ -0,0 +1,32 @@ +namespace NetAdmin.Domain.DbMaps.Adm; + +/// <summary> +/// 女朋友表 +/// </summary> +[Table(Name = Chars.FLG_DB_TABLE_NAME_PREFIX + nameof(Adm_GirlFriends))] +public record Adm_GirlFriends : VersionEntity +{ + /// <summary> + /// 姓名 + /// </summary> + [Column(DbType = Chars.FLG_DB_FIELD_T...
很好,有个小细节 ; 每个字段上请打上这两个特性, 因为dto都是继承于table entity类, 未避免字段暴露到客户端, 默认启用json忽略,csv导出忽略。 [CsvIgnore] [JsonIgnore] #################################### 如需要输出到客户端,或接收客户端输入,才在Rsp或者Req 对象override时,取消忽略 [JsonIgnore(Condition = JsonIgnoreCondition.Never)] 或 [JsonIgnore(Condition = JsonIgnoreCondition.WhenWritin...
quic
github_2023
c
18
lxin
lxin
@@ -5,26 +5,63 @@ #include <stdlib.h> #include <stdio.h> #include <errno.h> - +#include <netdb.h> #include <netinet/quic.h> +static const char *parse_address( + char const *address, char const *port, struct sockaddr_storage *sas) +{ + struct addrinfo hints = {0}; + struct addrinfo *res; + int rc; + + hints.ai_fla...
You can simplify: get_port() -> return ntohs(((struct sockaddr_in *)sas)->sin_port) set_port() -> ((struct sockaddr_in *)sas)->sin_port = htons(port); as sin_port in struct sockaddr_in and sin6_port in struct sockaddr_in6 are located at the same offset. also, please add a blank line between functions. same...
quic
github_2023
c
18
lxin
lxin
@@ -227,10 +268,10 @@ static int do_server(int argc, char *argv[]) printf("socket getsockname error %d\n", errno); return -1; } - printf("LOCAL PORT %d\n", ntohs(sa.sin_port)); - if (preferred_port != ntohs(sa.sin_port)) { + printf("LOCAL PORT %d\n", get_port(&sa)); + if (preferred_port != get_port(&sa))...
any reason why this line is commented out?
quic
github_2023
c
18
lxin
lxin
@@ -5,15 +5,34 @@ #include <stdlib.h> #include <stdio.h> #include <errno.h> - +#include <netdb.h> #include <netinet/quic.h> +static const char *parse_address( + char const *address, char const *port, struct sockaddr_storage *sas) +{ + struct addrinfo hints = {0}; + struct addrinfo *res; + int rc; + + hints.ai_fla...
same here, please add a blank line.
quic
github_2023
c
5
lxin
lxin
@@ -380,12 +381,12 @@ void quic_outq_retransmit(struct sock *sk) } next: - skb = outq->retransmit_skb ?: skb_peek(head); + skb = outq->retransmit_skb ?: __skb_dequeue(head); if (!skb) return quic_outq_flush(sk); - __skb_unlink(skb, head);
nice change
quic
github_2023
c
5
lxin
lxin
@@ -499,6 +502,9 @@ int quic_crypto_decrypt(struct quic_crypto *crypto, struct sk_buff *skb, u8 *key, *iv, *hp_key; int err; + if (!crypto->recv_ready) + return -EINVAL; + hp_key = crypto->rx_hp_key;
the packets shouldn't arrive here if crypto->recv_ready is false, as in quic_packet_process()/quic_packet_handshake_process(), it will be put into a backlog_list: APP DATA: ``` if (!quic_crypto(sk, QUIC_CRYPTO_APP)->recv_ready) { __skb_queue_tail(&quic_inq(sk)->backlog_list, skb); ...
quic
github_2023
c
5
lxin
lxin
@@ -474,6 +474,9 @@ int quic_crypto_encrypt(struct quic_crypto *crypto, struct sk_buff *skb, u8 *key, *iv, *hp_key; int err; + if (!crypto->send_ready) + return -EINVAL; +
the design is to dequeue and transmit packets only when crypto->send_ready is set, and the packet shouldn't arrive here if it's not set. The check is in quic_outq_transmit_data(): ``` if (!quic_crypto(sk, level)->send_ready) return; ``` so for APP DATA, it will stay in the sk_write_queue ...
quic
github_2023
c
5
lxin
lxin
@@ -395,9 +396,11 @@ void quic_outq_retransmit(struct sock *sk) goto next; } - quic_packet_config(sk, snd_cb->level); - quic_packet_tail(sk, skb); - quic_packet_flush(sk); + if (quic_crypto(sk, level)->send_ready) { + quic_packet_config(sk, level); + quic_packet_tail(sk, skb); + quic_packet_flush(sk); + }
0-RTT DATA is special. According to rfc9000: 1. Packets that a client sends with 0-RTT packet protection MUST be acknowledged by the server in packets protected by 1-RTT keys. 2. All 0-RTT and 1-RTT (APP) packets are sharing Application data space (quic_pnmap(sk, QUIC_CRYPTO_APP) in this repo), but they're using ...
quic
github_2023
c
5
lxin
lxin
@@ -509,6 +510,7 @@ static struct sk_buff *quic_packet_create(struct sock *sk, struct quic_packet_in continue; } quic_outq_rtx_tail(sk, fskb); + QUIC_SND_CB(fskb)->level = packet->level;
Never change QUIC_SND_CB(fskb)->level once fskb was created. For 0-RTT DATA, it will be ACKed by 1-RTT packet, for which it needs to match both QUIC_SND_CB(fskb)->level and packet_number in quic_outq_retransmit_check(). In fact, here in quic_packet_create() `packet->level` is always QUIC_CRYPTO_APP, in quic_packet_...
quic
github_2023
c
4
lxin
lxin
@@ -1639,18 +1637,18 @@ static void quic_shutdown(struct sock *sk, int how) inet_sk_set_state(sk, QUIC_SS_CLOSED); } -static int quic_ioctl(struct sock *sk, int cmd, int *karg) +static int quic_ioctl(struct sock *sk, int cmd, unsigned long arg) {
I was using the latest upstream kernel, it has been changed to "int (*ioctl)(struct sock *sk, int cmd, int *karg)" in kernel 6.4 in this commit: https://lore.kernel.org/lkml/20230609200010.27991-1-kuniyu@amazon.com/T/ This quic implementation is not in the upstream kernel yet and for now we expect this to be used...
serl_franka_controllers
github_2023
others
1
rail-berkeley
youliangtan
@@ -0,0 +1,115 @@ +cmake_minimum_required(VERSION 3.4) +project(serl_franka_controllers) + +set(CMAKE_BUILD_TYPE Release) +set(CMAKE_CXX_STANDARD 14)
does this work with higher CXXX version (e.g. 17 or 20), for forward compatibility
serl_franka_controllers
github_2023
others
1
rail-berkeley
youliangtan
@@ -0,0 +1,44 @@ +<?xml version="1.0"?> +<package format="2"> + <name>serl_franka_controllers</name> + <version>0.8.0</version> + <description>serl_franka_controllers provides example code for controlling Franka Emika research robots with ros_control</description> + <maintainer email="support@franka.de">Franka Emik...
Clean this, remove unessasary lines. and maybe add the license to this repo too
serl
github_2023
python
65
rail-berkeley
jianlanluo
@@ -223,10 +226,15 @@ def compute_reward(self, obs) -> bool: current_pose = np.hstack([current_pose[:3], euler_angles]) delta = np.abs(current_pose - self._TARGET_POSE) if np.all(delta < self._REWARD_THRESHOLD): - return True + reward = 1 else: # pr...
we should make a flag if enabling this reward or not, otherwise it'll apply this thing across the board even you don't need a gripper
serl
github_2023
python
38
rail-berkeley
jianlanluo
@@ -94,3 +94,12 @@ def transform_action(self, action: np.ndarray): action = np.array(action) # in case action is a jax read-only array action[:6] = self.adjoint_matrix @ action[:6] return action + + def transform_action_inv(self, action: np.ndarray): + """
can you add description that this assumes last dimension is gripper open/close?
serl
github_2023
python
38
rail-berkeley
jianlanluo
@@ -49,8 +49,10 @@ raise PermissionError(f"No permission to write to {file_dir}") while success_count < success_needed: - next_obs, rew, done, truncated, info = env.step(action=np.zeros((6,))) - actions = info["intervene_action"] + actions = np.zeros((6,)) + next_obs, rew, do...
how does this code run correctly without issues previously? if "intervene_action" is None, the previous code always assumes `actions = info["intervene_action"]` and this doesn't throw out errors?
serl
github_2023
python
38
rail-berkeley
jianlanluo
@@ -44,7 +44,7 @@ def step(self, action: np.ndarray): # this is to convert the spacemouse intervention action if "intervene_action" in info: - info["intervene_action"] = self.transform_action(info["intervene_action"]) + info["intervene_action"] = self.transform_action_inv(info[...
same for other function in this class, please indicate in function docstring the leading six dimension are [\delta x, \delta y, ...] last one is gripper open/close (discrete?)
serl
github_2023
python
38
rail-berkeley
jianlanluo
@@ -202,14 +202,17 @@ def action(self, action: np.ndarray) -> np.ndarray: expert_a = np.concatenate((expert_a, gripper_action), axis=0) if time.time() - self.last_intervene < 0.5: - return expert_a + return expert_a, True - return action + return action, Fal...
`replaced` is always False?
serl
github_2023
python
32
rail-berkeley
youliangtan
@@ -88,13 +91,43 @@ def print_green(x): return print("\033[92m {}\033[00m".format(x)) +SHOULD_PAUSE = False # flag to pause actor/learner agents
For proper impl of this, I would use: ``` from threading import Lock mutex = Lock() ```
serl
github_2023
python
32
rail-berkeley
youliangtan
@@ -88,13 +91,43 @@ def print_green(x): return print("\033[92m {}\033[00m".format(x)) +SHOULD_PAUSE = False # flag to pause actor/learner agents + + +def pause_client(a, b): + """Set flag to pause actor/learner agents at next iteration""" + global SHOULD_PAUSE + SHOULD_PAUSE = True + print("Reques...
I didnt try it on my pc. can we just have a single keyboard listener for this. It seems that we can simplify the code without having both `pause_client` and `on_press` fn. It would be good to just have a single `on_press_pause` function. Also, what is the exact keyboard key to pause this operation?
serl
github_2023
python
32
rail-berkeley
youliangtan
@@ -92,31 +92,26 @@ def print_green(x): SHOULD_PAUSE = False # flag to pause actor/learner agents +PAUSE_LOCK = threading.Lock()
Oh srry, i meant using [`threading Event`](https://docs.python.org/3/library/threading.html#event-objects), which is easier than having 2 variables. Also, can rename it to `PAUSE_EVENT_FLAG`. Personally i dont like using global, but i think this should be okay since it mainly serves as an example. Thanks
serl
github_2023
python
28
rail-berkeley
youliangtan
@@ -53,13 +54,28 @@ obs = next_obs if done: - print(rew) success_count += rew + total_count += 1 + print( + f"{rew}\tGot {success_count} successes of {total_count} trials. {success_needed} successes needed." + ) pba...
Is it easier if we check the dir exists beforehand? else create the dir if it doesnt exist. something like ```py if os.path.exists(DATA_DIRECTORY): shutil.rmtree(DATA_DIRECTORY) os.makedirs(DATA_DIRECTORY) ```
serl
github_2023
python
23
rail-berkeley
jianlanluo
@@ -0,0 +1,21 @@ +""" Test the spacemouse output. """ + +import time +import numpy as np +from serl_robot_infra.franka_env.spacemouse.spacemouse_expert import SpaceMouseExpert +np.set_printoptions(precision=3, suppress=True)
can you move this to test_spacemouse() ? this should be only locally valid
serl
github_2023
python
23
rail-berkeley
jianlanluo
@@ -0,0 +1,21 @@ +""" Test the spacemouse output. """ + +import time +import numpy as np +from serl_robot_infra.franka_env.spacemouse.spacemouse_expert import SpaceMouseExpert +np.set_printoptions(precision=3, suppress=True) + +def test_spacemouse(): + """ Test the SpaceMouseExpert class. """
can you add detailed descriptions?
serl
github_2023
python
23
rail-berkeley
jianlanluo
@@ -0,0 +1,33 @@ +""" Test the spacemouse output. """ + + +def test_spacemouse(): + """Test the SpaceMouseExpert class. + + This interactive test prints the action and buttons of the spacemouse at a rate of 10Hz. + The user is expected to move the spacemouse and press its buttons while the test is running. + ...
import should be on top of the file
serl
github_2023
python
5
rail-berkeley
jianlanluo
@@ -0,0 +1,447 @@ +""" +This file starts a control server running on the real time PC connected to the franka robot. +In a screen run `python franka_server.py` +""" +import os +import sys +from flask import Flask, request, jsonify +import numpy as np +import rospy +import time +import subprocess +from scipy.spatial.tra...
this is assume 10HZ, so 10s ? probably don't use this hardcoding
serl
github_2023
python
5
rail-berkeley
jianlanluo
@@ -0,0 +1,447 @@ +""" +This file starts a control server running on the real time PC connected to the franka robot. +In a screen run `python franka_server.py` +""" +import os +import sys +from flask import Flask, request, jsonify +import numpy as np +import rospy +import time +import subprocess +from scipy.spatial.tra...
change the variable name to make it more informative
serl
github_2023
python
5
rail-berkeley
jianlanluo
@@ -0,0 +1,447 @@ +""" +This file starts a control server running on the real time PC connected to the franka robot. +In a screen run `python franka_server.py` +""" +import os +import sys +from flask import Flask, request, jsonify +import numpy as np +import rospy +import time +import subprocess +from scipy.spatial.tra...
can you reorganize this block of code ? make it a function and move to main >?
serl
github_2023
python
5
rail-berkeley
jianlanluo
@@ -0,0 +1,447 @@ +""" +This file starts a control server running on the real time PC connected to the franka robot. +In a screen run `python franka_server.py` +""" +import os +import sys +from flask import Flask, request, jsonify +import numpy as np +import rospy +import time +import subprocess +from scipy.spatial.tra...
are these even used ? delete if not used
serl
github_2023
python
5
rail-berkeley
jianlanluo
@@ -0,0 +1,300 @@ +import gym +from gym import spaces +import numpy as np +from franka_robotiq_env import FrankaRobotiq +import time +from scipy.spatial.transform import Rotation +import requests +import copy +import cv2 +from camera.video_capture import VideoCapture +from camera.rs_capture import RSCapture +import que...
rewrite this function 1) make timeout an argument 2) make required precision an argument
serl
github_2023
python
5
rail-berkeley
jianlanluo
@@ -0,0 +1,300 @@ +import gym +from gym import spaces +import numpy as np +from franka_robotiq_env import FrankaRobotiq +import time +from scipy.spatial.transform import Rotation +import requests +import copy +import cv2 +from camera.video_capture import VideoCapture +from camera.rs_capture import RSCapture +import que...
make this configurable
serl
github_2023
python
5
rail-berkeley
jianlanluo
@@ -0,0 +1,300 @@ +import gym +from gym import spaces +import numpy as np +from franka_robotiq_env import FrankaRobotiq +import time +from scipy.spatial.transform import Rotation +import requests +import copy +import cv2 +from camera.video_capture import VideoCapture +from camera.rs_capture import RSCapture +import que...
rewrite , removing hardcoding
serl
github_2023
python
5
rail-berkeley
jianlanluo
@@ -0,0 +1,300 @@ +import gym +from gym import spaces +import numpy as np +from franka_robotiq_env import FrankaRobotiq +import time +from scipy.spatial.transform import Rotation +import requests +import copy +import cv2 +from camera.video_capture import VideoCapture +from camera.rs_capture import RSCapture +import que...
is this even used after UR5 cable routing ?
serl
github_2023
python
5
rail-berkeley
jianlanluo
@@ -0,0 +1,300 @@ +import gym +from gym import spaces +import numpy as np +from franka_robotiq_env import FrankaRobotiq +import time +from scipy.spatial.transform import Rotation +import requests +import copy +import cv2 +from camera.video_capture import VideoCapture +from camera.rs_capture import RSCapture +import que...
clean up
serl
github_2023
python
5
rail-berkeley
jianlanluo
@@ -0,0 +1,247 @@ +import gym +from gym import spaces +import numpy as np +from franka_robotiq_env import FrankaRobotiq +import time +from scipy.spatial.transform import Rotation +import requests +import copy +import cv2 +from camera.video_capture import VideoCapture +from camera.rs_capture import RSCapture +import que...
same redo this function
serl
github_2023
python
5
rail-berkeley
jianlanluo
@@ -0,0 +1,130 @@ +import gym +from gym import spaces +import numpy as np +# from franka.scripts.spacemouse_teleop import SpaceMouseExpert +import time +from franka_robotiq_env import FrankaRobotiq +import copy +import requests + +class PCBEnv(FrankaRobotiq): + def __init__(self): + + super().__init__() + ...
if reset / get img was called across all envs, should make another file, and import those from that file in env.py
serl
github_2023
python
5
rail-berkeley
jianlanluo
@@ -0,0 +1,267 @@ +import time +from gym import Env, spaces +import gym +import numpy as np +from gym.spaces import Box +import copy +from robot_infra.spacemouse.spacemouse_teleop import SpaceMouseExpert +from scipy.spatial.transform import Rotation as R + + +class ProxyEnv(Env): + def __init__(self, wrapped_env): +...
clean up
serl
github_2023
python
5
rail-berkeley
jianlanluo
@@ -0,0 +1,267 @@ +import time +from gym import Env, spaces +import gym +import numpy as np +from gym.spaces import Box +import copy +from robot_infra.spacemouse.spacemouse_teleop import SpaceMouseExpert +from scipy.spatial.transform import Rotation as R + + +class ProxyEnv(Env): + def __init__(self, wrapped_env): +...
we should probably do this in the env side
serl
github_2023
python
5
rail-berkeley
jianlanluo
@@ -0,0 +1,267 @@ +import time +from gym import Env, spaces +import gym +import numpy as np +from gym.spaces import Box +import copy +from robot_infra.spacemouse.spacemouse_teleop import SpaceMouseExpert +from scipy.spatial.transform import Rotation as R + + +class ProxyEnv(Env): + def __init__(self, wrapped_env): +...
what are you doing here? F/T is always in EE frame
serl
github_2023
python
5
rail-berkeley
youliangtan
@@ -0,0 +1,472 @@ +"""Gym Interface for Franka""" +import numpy as np +import gym +from pyquaternion import Quaternion +import cv2 +import copy +from scipy.spatial.transform import Rotation +import time +import requests +from gym import core, spaces +from camera.video_capture import VideoCapture +from camera.rs_capture...
Rename this `FrankaRobotiqEnv`
serl
github_2023
python
5
rail-berkeley
youliangtan
@@ -0,0 +1,472 @@ +"""Gym Interface for Franka""" +import numpy as np +import gym +from pyquaternion import Quaternion +import cv2 +import copy +from scipy.spatial.transform import Rotation +import time +import requests +from gym import core, spaces +from camera.video_capture import VideoCapture +from camera.rs_capture...
Move `euler_2_quat` and `quat_2_euler` to a `utils.py`
serl
github_2023
python
5
rail-berkeley
youliangtan
@@ -0,0 +1,472 @@ +"""Gym Interface for Franka""" +import numpy as np +import gym +from pyquaternion import Quaternion +import cv2 +import copy +from scipy.spatial.transform import Rotation +import time +import requests +from gym import core, spaces +from camera.video_capture import VideoCapture +from camera.rs_capture...
This entire code block is quite unreadable. Requires more cleanup (e.g. what is jpos). Add those val (retry_count, tolerance, thresh, etc.) as configs/params and also add comments. type cast `jpos: np.narray` is always recommended
serl
github_2023
python
5
rail-berkeley
youliangtan
@@ -0,0 +1,447 @@ +""" +This file starts a control server running on the real time PC connected to the franka robot. +In a screen run `python franka_server.py` +""" +import os +import sys +from flask import Flask, request, jsonify +import numpy as np +import rospy +import time +import subprocess +from scipy.spatial.tra...
use `argparser`
serl
github_2023
python
5
rail-berkeley
youliangtan
@@ -0,0 +1,17 @@ +from setuptools import setup +setup(name='franka_env',
Now `serl` is organized as - serl - `franka_sim` - `serl_launcher` - `examples` - `franka_env` (TODO, or other names, serl_franka_infra) Thus, if it make sense try to organize the robot code into a separate pkg, and add executables to `examples` or `scripts`
serl
github_2023
python
5
rail-berkeley
youliangtan
@@ -0,0 +1,472 @@ +"""Gym Interface for Franka""" +import numpy as np +import gym +from pyquaternion import Quaternion +import cv2 +import copy +from scipy.spatial.transform import Rotation +import time +import requests +from gym import core, spaces +from camera.video_capture import VideoCapture +from camera.rs_capture...
Hard coded `serial_num` again. should have all these in a init_rs() function. All these detailed impl of getting the cam can be placed in `rs_capture.py` too
serl
github_2023
python
5
rail-berkeley
youliangtan
@@ -0,0 +1,447 @@ +""" +This file starts a control server running on the real time PC connected to the franka robot. +In a screen run `python franka_server.py` +""" +import os +import sys +from flask import Flask, request, jsonify +import numpy as np +import rospy +import time +import subprocess +from scipy.spatial.tra...
have all these being placed within `if __name__ == '__main__':`? Also, if this script `flask` server script is getting too long, would split both the flask server and "robot ros server" into 2 different scripts. I would also `rospy.init_node()` the node in the class init.
serl
github_2023
python
5
rail-berkeley
youliangtan
@@ -0,0 +1,447 @@ +""" +This file starts a control server running on the real time PC connected to the franka robot. +In a screen run `python franka_server.py` +""" +import os +import sys +from flask import Flask, request, jsonify +import numpy as np +import rospy +import time +import subprocess +from scipy.spatial.tra...
if these print out is getting overwhelming, can consider use `logging.debug()`
serl
github_2023
python
12
rail-berkeley
youliangtan
@@ -0,0 +1,104 @@ +import gymnasium as gym +from tqdm import tqdm +import numpy as np +import copy +import pickle as pkl +import datetime + +import franka_env + +from franka_env.envs.relative_env import RelativeFrame +from franka_env.envs.wrappers import ( + SpacemouseIntervention, + Quat2EulerWrapper, +) + +from...
use `serl_launcher`
serl
github_2023
python
12
rail-berkeley
youliangtan
@@ -0,0 +1,110 @@ +import gymnasium as gym +from tqdm import tqdm +import numpy as np +import copy +import pickle as pkl +import datetime + +import franka_env + +from franka_env.envs.relative_env import RelativeFrame +from franka_env.envs.wrappers import ( + SpacemouseIntervention, + Quat2EulerWrapper, + FWBWF...
same, use `serl_launcher`, same for all imports in this PR
serl
github_2023
python
12
rail-berkeley
youliangtan
@@ -0,0 +1,110 @@ +import gymnasium as gym +from tqdm import tqdm +import numpy as np +import copy +import pickle as pkl +import datetime + +import franka_env + +from franka_env.envs.relative_env import RelativeFrame +from franka_env.envs.wrappers import ( + SpacemouseIntervention, + Quat2EulerWrapper, + FWBWF...
Do we need to provide these demos pkl files in the release?
serl
github_2023
python
12
rail-berkeley
youliangtan
@@ -0,0 +1,170 @@ +import numpy as np +import time +import requests +import copy +import cv2 +import queue +import gymnasium as gym + +from franka_env.envs.franka_env import FrankaEnv +from franka_env.utils.rotations import euler_2_quat +from franka_env.envs.bin_relocation_env.config import BinEnvConfig + + +class Fran...
hardcoded, use config.ypy
serl
github_2023
python
12
rail-berkeley
youliangtan
@@ -0,0 +1,110 @@ +import gymnasium as gym +from tqdm import tqdm +import numpy as np +import copy +import pickle as pkl +import datetime + +import franka_env + +from franka_env.envs.relative_env import RelativeFrame +from franka_env.envs.wrappers import ( + SpacemouseIntervention, + Quat2EulerWrapper, + FWBWF...
both `checkpoint_path` not used
serl
github_2023
python
12
rail-berkeley
youliangtan
@@ -0,0 +1,68 @@ +import gymnasium as gym +from tqdm import tqdm +import numpy as np +import copy + +import franka_env + +from franka_env.envs.relative_env import RelativeFrame +from franka_env.envs.wrappers import ( + SpacemouseIntervention, + Quat2EulerWrapper, + FWBWFrontCameraBinaryRewardClassifierWrapper,...
same, unused checkpoint path
serl
github_2023
python
12
rail-berkeley
youliangtan
@@ -0,0 +1,26 @@ +import gymnasium as gym +from gymnasium.core import Env +from copy import deepcopy + + +class FrontCameraWrapper(gym.ObservationWrapper): + def __init__(self, env: Env): + super().__init__(env) + front_obs_space = { + k: space for k, space in self.observation_space.items() ...
Does the `async_drq_randomized.py` for bin reloc just uses front img as obs space? If so, is it better if directly overload the `self.observation_space` with `self.front_observation_space`? and update observation?
serl
github_2023
python
12
rail-berkeley
youliangtan
@@ -7,6 +7,47 @@ from franka_env.spacemouse.spacemouse_expert import SpaceMouseExpert from franka_env.utils.rotations import quat_2_euler +sigmoid = lambda x: 1 / (1 + np.exp(-x)) + + +class FWBWFrontCameraBinaryRewardClassifierWrapper(gym.Wrapper): + """ + This wrapper uses the front camera images to compute...
add a simple comment indicates reward classifier for forward-backward reward cls
serl
github_2023
python
12
rail-berkeley
youliangtan
@@ -0,0 +1,127 @@ +import gymnasium as gym +from tqdm import tqdm +import numpy as np +import copy +import pickle as pkl +import datetime + +import franka_env + +from franka_env.envs.relative_env import RelativeFrame +from franka_env.envs.wrappers import ( + SpacemouseIntervention, + Quat2EulerWrapper, +) + +from...
Here it is also recording failed transitions? I think we can combine `record_goals_images.py` and `record_failed_images.py`
serl
github_2023
python
12
rail-berkeley
youliangtan
@@ -0,0 +1,159 @@ +import pickle as pkl +import jax +from jax import numpy as jnp +import flax.linen as nn +from flax.training.train_state import TrainState +from flax.core import frozen_dict +from flax.training import checkpoints +import optax +from tqdm import tqdm +import gymnasium as gym +import os +from absl impor...
is okay to hardcode for now, but at least make the path configurable as `DEFINE_string()` flag
serl
github_2023
others
7
rail-berkeley
youliangtan
@@ -0,0 +1,25 @@ +# SERL Robot Infra + +All robot code is structured as follows: +There is a Flask server which sends commands to the robot via ROS. There is a gym env for the robot which communicates with the Flask server via post requests. + +- `robot_server`: hosts a Flask server which sends commands to the robot vi...
Update this to use: `serl_franka_controllers` https://github.com/rail-berkeley/serl_franka_controllers
serl
github_2023
others
7
rail-berkeley
youliangtan
@@ -0,0 +1,25 @@ +# SERL Robot Infra + +All robot code is structured as follows: +There is a Flask server which sends commands to the robot via ROS. There is a gym env for the robot which communicates with the Flask server via post requests. + +- `robot_server`: hosts a Flask server which sends commands to the robot vi...
Can add this: ```mermaid graph LR A[Robot] <-- ROS --> B[Robot Server] B <-- HTTP --> C[Gym Env] C <-- Lib --> D[RL Policy] ```
serl
github_2023
python
7
rail-berkeley
youliangtan
@@ -0,0 +1,362 @@ +"""Gym Interface for Franka""" +import numpy as np +import gymnasium as gym +import cv2 +import copy +from scipy.spatial.transform import Rotation +import time +import requests +from gymnasium import spaces +import queue +import threading +from datetime import datetime + +from franka_env.camera.video...
I added a `DefaultEnvConfig` in the base env class here. I'm still thinking of the best way for users to configure this. ideally, they should be a separate config or --flags.
serl
github_2023
python
7
rail-berkeley
jianlanluo
@@ -0,0 +1,28 @@ +import threading +import pyspacemouse +import numpy as np + + +class SpaceMouseExpert: + def __init__(self): + pyspacemouse.open() + + self.state_lock = threading.Lock() + self.latest_data = {"action": np.zeros(6), "buttons": [0, 0]} + # Start a thread to continuously re...
can we add a justification here? it looks this is very specific to the way how we use our spacemouse
serl
github_2023
python
7
rail-berkeley
jianlanluo
@@ -0,0 +1,83 @@ +import numpy as np +import gymnasium as gym +from gymnasium import spaces +import time +import requests +import copy + +from franka_env.envs.franka_robotiq_env import FrankaRobotiqEnv +from franka_env.utils.rotations import euler_2_quat + + +class FrankaRobotiqPCBInsert(FrankaRobotiqEnv): + def __i...
crop_image() should be optional
serl
github_2023
python
7
rail-berkeley
jianlanluo
@@ -0,0 +1,83 @@ +import numpy as np +import gymnasium as gym +from gymnasium import spaces +import time +import requests +import copy + +from franka_env.envs.franka_robotiq_env import FrankaRobotiqEnv +from franka_env.utils.rotations import euler_2_quat + + +class FrankaRobotiqPCBInsert(FrankaRobotiqEnv): + def __i...
like i said in the PR comments, we should probably get another python file and use a ConfigDict to encompass all experiment-related parameters, when we launch our experiments, we should only need python --config xxx.py
serl
github_2023
python
7
rail-berkeley
jianlanluo
@@ -0,0 +1,83 @@ +import numpy as np +import gymnasium as gym +from gymnasium import spaces +import time +import requests +import copy + +from franka_env.envs.franka_robotiq_env import FrankaRobotiqEnv +from franka_env.utils.rotations import euler_2_quat + + +class FrankaRobotiqPCBInsert(FrankaRobotiqEnv): + def __i...
fix this
serl
github_2023
python
7
rail-berkeley
jianlanluo
@@ -0,0 +1,40 @@ +import numpy as np +import gymnasium as gym +from gymnasium import spaces + +from franka_env.envs.franka_robotiq_env import FrankaRobotiqEnv +from franka_env.utils.rotations import euler_2_quat + + +class FrankaRobotiqPegInsert(FrankaRobotiqEnv): + def __init__(self, **kwargs): + super().__i...
abstract this away in config file
serl
github_2023
python
7
rail-berkeley
jianlanluo
@@ -0,0 +1,362 @@ +"""Gym Interface for Franka""" +import numpy as np +import gymnasium as gym +import cv2 +import copy +from scipy.spatial.transform import Rotation +import time +import requests +from gymnasium import spaces +import queue +import threading +from datetime import datetime + +from franka_env.camera.video...
configurable in a py file
serl
github_2023
python
7
rail-berkeley
jianlanluo
@@ -0,0 +1,362 @@ +"""Gym Interface for Franka""" +import numpy as np +import gymnasium as gym +import cv2 +import copy +from scipy.spatial.transform import Rotation +import time +import requests +from gymnasium import spaces +import queue +import threading +from datetime import datetime + +from franka_env.camera.video...
what is old_sign doing here ?
serl
github_2023
python
7
rail-berkeley
jianlanluo
@@ -0,0 +1,362 @@ +"""Gym Interface for Franka""" +import numpy as np +import gymnasium as gym +import cv2 +import copy +from scipy.spatial.transform import Rotation +import time +import requests +from gymnasium import spaces +import queue +import threading +from datetime import datetime + +from franka_env.camera.video...
why can't we just clip rotation all at once?
serl
github_2023
python
7
rail-berkeley
jianlanluo
@@ -0,0 +1,362 @@ +"""Gym Interface for Franka""" +import numpy as np +import gymnasium as gym +import cv2 +import copy +from scipy.spatial.transform import Rotation +import time +import requests +from gymnasium import spaces +import queue +import threading +from datetime import datetime + +from franka_env.camera.video...
optional
serl
github_2023
python
7
rail-berkeley
jianlanluo
@@ -0,0 +1,135 @@ +from scipy.spatial.transform import Rotation as R +import gymnasium as gym +import numpy as np +from gym import Env + + +class RelativeFrame(gym.Wrapper): + """ + This wrapper makes the observation and action relative to the end-effector frame. + This wrapper is expected to be used on top of...
delete
serl
github_2023
python
7
rail-berkeley
jianlanluo
@@ -0,0 +1,135 @@ +from scipy.spatial.transform import Rotation as R +import gymnasium as gym +import numpy as np +from gym import Env + + +class RelativeFrame(gym.Wrapper): + """ + This wrapper makes the observation and action relative to the end-effector frame. + This wrapper is expected to be used on top of...
you can do this with together with homogenous transformation
serl
github_2023
python
7
rail-berkeley
jianlanluo
@@ -0,0 +1,135 @@ +from scipy.spatial.transform import Rotation as R +import gymnasium as gym +import numpy as np +from gym import Env + + +class RelativeFrame(gym.Wrapper): + """ + This wrapper makes the observation and action relative to the end-effector frame. + This wrapper is expected to be used on top of...
if it's a jax read-only array, can you convert to np array anyway?
serl
github_2023
python
7
rail-berkeley
jianlanluo
@@ -0,0 +1,135 @@ +from scipy.spatial.transform import Rotation as R +import gymnasium as gym +import numpy as np +from gym import Env + + +class RelativeFrame(gym.Wrapper): + """ + This wrapper makes the observation and action relative to the end-effector frame. + This wrapper is expected to be used on top of...
what is T matrix? make the name more informative
serl
github_2023
python
7
rail-berkeley
jianlanluo
@@ -0,0 +1,135 @@ +from scipy.spatial.transform import Rotation as R +import gymnasium as gym +import numpy as np +from gym import Env + + +class RelativeFrame(gym.Wrapper): + """ + This wrapper makes the observation and action relative to the end-effector frame. + This wrapper is expected to be used on top of...
do you really need to write a function of this ?