Skip to content

Commit

Permalink
Merge branch 'develop' of github.com:shbang91/rpc into develop
Browse files Browse the repository at this point in the history
  • Loading branch information
shbang91 committed Sep 6, 2024
2 parents a01e0ae + f997b34 commit 2ae8df1
Show file tree
Hide file tree
Showing 75 changed files with 9,618 additions and 6,526 deletions.
4 changes: 2 additions & 2 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,11 @@ repos:
- id: clang-format
types_or: [c++]
- repo: https://github.com/astral-sh/ruff-pre-commit
rev: v0.5.5
rev: v0.6.3
hooks:
- id: ruff
# ignore import-star and import-star-usage
args: [--fix, --ignore, F403, --ignore, F405]
args: [--fix, --ignore, F403, --ignore, F405, --ignore, E402]
- id: ruff-format
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.6.0
Expand Down
23 changes: 18 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,18 +7,23 @@ rpc is a software framework designed for generating task trajectories (planning)
Software Framework is developed by Seung Hyeon Bang based on the [PnC](https://github.com/junhyeokahn/PnC) Repository.<br/>

## Dependencies
The controller has been tested on Ubuntu 18.04, Ubuntu 20.04, and Mac OSX Ventura. It builds on the shoulders of the following software:<br/>
The controller has been tested on Ubuntu 18.04, Ubuntu 20.04, Ubuntu 23.04, and Mac OSX Ventura. It builds on the shoulders of the following software:<br/>
- [anaconda](https://docs.anaconda.com/anaconda/install/): For Pybullet simulator<br/>
- python dependencies:
```
$ conda env create -f rpc.yml
```
- [conan](https://github.com/conan-io/conan): package manager for C/C++
```
$ pip install conan
```
- [pinocchio](https://github.com/shbang91/pinocchio): rigid body dynamics

###### optional dependencies
- [MatLogger2](https://github.com/shbang91/MatLogger2): logging numeric data (cpp to MAT-files)
- [zmq](https://github.com/shbang91/rpc/blob/main/dependency/scripts/install_zmq.sh): logging numeric data
- [protobuf](https://github.com/shbang91/rpc/blob/main/dependency/scripts/install_protobuf.sh): logging numeric data
- [Foxglove](https://github.com/foxglove): websocket & schema protocols for robot visualization and parameter operations

## Usage
- Source conda environment:<br/>
Expand All @@ -27,7 +32,7 @@ $ conda activate rpc
```
- Compile:<br/>
```
$ mkdir build
$ conan install conanfile.txt --build=missing
$ cd build
$ cmake ..
$ make -j4
Expand All @@ -36,12 +41,20 @@ $ make -j4
```
python simulator/pybullet/draco_main.py
```
###### optional
- visualization:<br/>
###### Foxglove (optional)
- Project should be built with the following flags:
```
BUILD_WITH_FOXGLOVE ON
BUILD_WITH_ZMQ_PROTOBUF ON
```
- Run Foxglove:<br/>
```
$ conda env create -f visualize.yml
$ conda activate visualize
$ python plot/draco/draco_data_manager.py --b_visualize=true
$ python UI/foxglove/UI_launcher.py --visualizer=foxglove
```
- Access Foxglove server via either:<br/>
1) [Foxglove webservice](https://app.foxglove.dev/)
2) [Foxglove application](https://foxglove.dev/download)
###### Hardware Usage
- Please refer to this [repository](https://github.com/shbang91/draco3_nodelet) using rpc library
48 changes: 30 additions & 18 deletions UI/convert_pkl2mcap.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
This assumes a specific set of parameters available in the pkl file,
such as time, base_pos, base_ori, joint_positions, icp_est, icp_des, etc.
"""

import os
import sys
import argparse
Expand Down Expand Up @@ -44,7 +45,7 @@ def main():
b_using_kf_estimator = args.b_using_kf_estimator

# variables in pkl file
time =[]
time = []
base_pos, base_ori, joint_positions = [], [], []
vis_2d_object_names = ["icp_est", "icp_des"]
vis_3d_object_names = ["lf_pos", "rf_pos"]
Expand Down Expand Up @@ -97,7 +98,9 @@ def main():
icp_des_scene = create_sphere_scene("icp_des", [0.0, 1.0, 0.0, 0.5])

# send data to mcap file
with open(cwd + "/experiment_data/draco3_foxglove.mcap", "wb") as f, Writer(f) as mcap_writer:
with open(cwd + "/experiment_data/draco3_foxglove.mcap", "wb") as f, Writer(
f
) as mcap_writer:
for i in range(len(time)):
# Update all transforms (to visualize URDF)
vis_q[0:3] = np.array(base_pos[i])
Expand All @@ -109,41 +112,50 @@ def main():
pin.updateGeometryPlacements(model, data, visual_model, visual_data)
for visual in visual_model.geometryObjects:
update_robot_transform(visual, visual_data, visual_model, transform)
mcap_writer.write_message("transforms", transform, int(time[i] * 1e9), int(time[i] * 1e9))
mcap_writer.write_message(
"transforms", transform, int(time[i] * 1e9), int(time[i] * 1e9)
)
transform.rotation.Clear()
transform.translation.Clear()
# -------------------------------------------
# update transform of ADDITIONAL visual elements
for vname, vval in vis_2d_dict.items():
update_2d_transform(vname, vval[i], transform)
mcap_writer.write_message( "transforms", transform,
int(time[i] * 1e9), int(time[i] * 1e9))
mcap_writer.write_message(
"transforms", transform, int(time[i] * 1e9), int(time[i] * 1e9)
)
transform.rotation.Clear()
transform.translation.Clear()
# ===========================================
# ICP visuals (est / des)
icp_est_scene.entities[0].timestamp.FromNanoseconds(int(time[i] * 1e9))
mcap_writer.write_message( "icp_est_viz", icp_est_scene,
int(time[i] * 1e9), int(time[i] * 1e9))
mcap_writer.write_message(
"icp_est_viz", icp_est_scene, int(time[i] * 1e9), int(time[i] * 1e9)
)
# -------------------------------------------
icp_des_scene.entities[0].timestamp.FromNanoseconds(int(time[i] * 1e9))
mcap_writer.write_message( "icp_des_viz", icp_des_scene,
int(time[i] * 1e9), int(time[i] * 1e9))
mcap_writer.write_message(
"icp_des_viz", icp_des_scene, int(time[i] * 1e9), int(time[i] * 1e9)
)
# ===========================================
# ICP plots (est / des)
for vname, vval in vis_2d_dict.items():
mcap_writer.write_message(vname,
Point2(x=vval[i][0], y=vval[i][1]),
int(time[i] * 1e9),
int(time[i] * 1e9))
mcap_writer.write_message(
vname,
Point2(x=vval[i][0], y=vval[i][1]),
int(time[i] * 1e9),
int(time[i] * 1e9),
)
# Feet position plots (left / right)
for vname, vval in vis_3d_dict.items():
mcap_writer.write_message(vname,
Point3(x=vval[i][0], y=vval[i][1], z=vval[i][2]),
int(time[i] * 1e9),
int(time[i] * 1e9))
mcap_writer.write_message(
vname,
Point3(x=vval[i][0], y=vval[i][1], z=vval[i][2]),
int(time[i] * 1e9),
int(time[i] * 1e9),
)
mcap_writer.finish()


if __name__ == "__main__":
main()
main()
Loading

0 comments on commit 2ae8df1

Please sign in to comment.