Browse Source

Add derivation fo rpython ros2 bridge

tags/v0.3.5
haixuanTao 1 year ago
parent
commit
42dcb07237
6 changed files with 18 additions and 9 deletions
  1. +3
    -2
      Cargo.lock
  2. +1
    -1
      apis/python/node/Cargo.toml
  3. +2
    -2
      apis/python/node/src/lib.rs
  4. +1
    -0
      libraries/extensions/ros2-bridge/python/Cargo.toml
  5. +7
    -1
      libraries/extensions/ros2-bridge/python/src/lib.rs
  6. +4
    -3
      libraries/extensions/ros2-bridge/python/src/qos.rs

+ 3
- 2
Cargo.lock View File

@@ -2588,6 +2588,7 @@ dependencies = [
"eyre",
"futures",
"pyo3",
"pyo3_special_method_derive",
"serde",
"serde_assert",
]
@@ -6556,9 +6557,9 @@ dependencies = [

[[package]]
name = "pyo3_special_method_derive"
version = "0.1.0"
version = "0.2.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "6ba8f52c03a4a510534a6cea6a44e3872a7287392e7c9b8ffe9a9409d736f10a"
checksum = "e831c9f620de245243f105f2d764c59c32a853bd1c9fb34504116e0d6d094fad"
dependencies = [
"proc-macro2",
"pyo3",


+ 1
- 1
apis/python/node/Cargo.toml View File

@@ -25,7 +25,7 @@ arrow = { workspace = true, features = ["pyarrow"] }
pythonize = { workspace = true }
futures = "0.3.28"
dora-ros2-bridge-python = { workspace = true }
pyo3_special_method_derive = "0.1.0"
pyo3_special_method_derive = "0.2.1"

[lib]
name = "dora"


+ 2
- 2
apis/python/node/src/lib.rs View File

@@ -11,7 +11,7 @@ use eyre::Context;
use futures::{Stream, StreamExt};
use pyo3::prelude::*;
use pyo3::types::{PyBytes, PyDict};
use pyo3_special_method_derive::DirHelper;
use pyo3_special_method_derive::Dir;

/// The custom node API lets you integrate `dora` into your application.
/// It allows you to retrieve input and send output in any fashion you want.
@@ -25,7 +25,7 @@ use pyo3_special_method_derive::DirHelper;
/// ```
///
#[pyclass]
#[derive(DirHelper)]
#[derive(Dir)]
pub struct Node {
events: Events,
pub node: DoraNode,


+ 1
- 0
libraries/extensions/ros2-bridge/python/Cargo.toml View File

@@ -12,6 +12,7 @@ eyre = "0.6"
serde = "1.0.166"
arrow = { workspace = true, features = ["pyarrow"] }
futures = "0.3.28"
pyo3_special_method_derive = "0.2.1"

[dev-dependencies]
serde_assert = "0.7.1"

+ 7
- 1
libraries/extensions/ros2-bridge/python/src/lib.rs View File

@@ -18,6 +18,7 @@ use pyo3::{
types::{PyAnyMethods, PyDict, PyList, PyModule, PyModuleMethods},
Bound, PyAny, PyObject, PyResult, Python,
};
use pyo3_special_method_derive::{Dict, Dir, Repr, Str};
use typed::{deserialize::StructDeserializer, TypeInfo, TypedValue};

pub mod qos;
@@ -45,6 +46,7 @@ pub mod typed;
/// :type ros_paths: typing.List[str], optional
///
#[pyclass]
#[derive(Str, Repr, Dir, Dict)]
pub struct Ros2Context {
context: ros2_client::Context,
messages: Arc<HashMap<String, HashMap<String, Message>>>,
@@ -147,6 +149,7 @@ impl Ros2Context {
/// See: https://github.com/jhelovuo/ros2-client/issues/4
///
#[pyclass]
#[derive(Str, Repr, Dir, Dict)]
pub struct Ros2Node {
node: ros2_client::Node,
messages: Arc<HashMap<String, HashMap<String, Message>>>,
@@ -251,7 +254,7 @@ impl Ros2Node {
/// ROS2 Node Options
/// :type rosout: bool, optional
///
#[derive(Debug, Clone, Default)]
#[derive(Clone, Default, Str, Repr, Dir, Dict)]
#[pyclass]
#[non_exhaustive]
pub struct Ros2NodeOptions {
@@ -281,6 +284,7 @@ impl From<Ros2NodeOptions> for ros2_client::NodeOptions {
/// - dora Ros2 bridge functionality is considered **unstable**. It may be changed
/// at any point without it being considered a breaking change.
#[pyclass]
#[derive(Str, Repr, Dir, Dict)]
#[non_exhaustive]
pub struct Ros2Topic {
topic: rustdds::Topic,
@@ -293,6 +297,7 @@ pub struct Ros2Topic {
/// - dora Ros2 bridge functionality is considered **unstable**. It may be changed
/// at any point without it being considered a breaking change.
#[pyclass]
#[derive(Str, Repr, Dir, Dict)]
#[non_exhaustive]
pub struct Ros2Publisher {
publisher: ros2_client::Publisher<TypedValue<'static>>,
@@ -363,6 +368,7 @@ impl Ros2Publisher {
/// - dora Ros2 bridge functionality is considered **unstable**. It may be changed
/// at any point without it being considered a breaking change.
#[pyclass]
#[derive(Str, Repr, Dir, Dict)]
#[non_exhaustive]
pub struct Ros2Subscription {
deserializer: StructDeserializer<'static>,


+ 4
- 3
libraries/extensions/ros2-bridge/python/src/qos.rs View File

@@ -1,5 +1,6 @@
use ::dora_ros2_bridge::rustdds::{self, policy};
use pyo3::prelude::{pyclass, pymethods};
use pyo3_special_method_derive::{Dict, Dir, Repr, Str};

/// ROS2 QoS Policy
///
@@ -12,7 +13,7 @@ use pyo3::prelude::{pyclass, pymethods};
/// :type keep_last: int, optional
/// :rtype: dora.Ros2QoSPolicies
///
#[derive(Debug, Clone)]
#[derive(Clone, Str, Repr, Dir, Dict)]
#[pyclass]
#[non_exhaustive]
pub struct Ros2QosPolicies {
@@ -77,7 +78,7 @@ impl From<Ros2QosPolicies> for rustdds::QosPolicies {
/// DDS 2.2.3.4 DURABILITY
///
/// :rtype: dora.Ros2Durability
#[derive(Copy, Clone, Debug, PartialEq, Eq, PartialOrd, Ord, Hash)]
#[derive(Copy, Clone, PartialEq, Eq, PartialOrd, Ord, Hash, Str, Repr, Dir, Dict)]
#[pyclass]
pub enum Ros2Durability {
Volatile,
@@ -103,7 +104,7 @@ impl From<Ros2Durability> for policy::Durability {

/// DDS 2.2.3.11 LIVELINESS
/// :rtype: dora.Ros2Liveliness
#[derive(Copy, Clone, Debug, PartialEq)]
#[derive(Copy, Clone, PartialEq, Str, Repr, Dir, Dict)]
#[pyclass]
pub enum Ros2Liveliness {
Automatic,


Loading…
Cancel
Save