The python DDS is too slow!

3 posts / 0 new
Last post
Last seen: 1 day 23 hours ago
Joined: 11/17/2022
Posts: 2
The python DDS is too slow!
my code is follow:
from common.ronovo_topic import *
from common.TopicName import *
import time
from asyncio.coroutines import iscoroutinefunction
def cost_time(func):
   def fun(*args, **kwargs):
   t = time.perf_counter()
    result = func(*args, **kwargs)
   print(f'func {func.__name__} cost time:{time.perf_counter() - t:.8f} s')
  return result


async def func_async(*args, **kwargs):
  t = time.perf_counter()
  result = await func(*args, **kwargs)
   print(f'func {func.__name__} cost time:{time.perf_counter() - t:.8f} s')
   return result


    if iscoroutinefunction(func):
       return func_async
      return fun
class DataReaderListenerImpl(dds.NoOpDataReaderListener):
   def on_data_available(self,t_reader:dds.DataReader):
participant = dds.DomainParticipant(domain_id=0)
topic = dds.Topic(
participant,TopicNames.PatientAct[0], TPC_PatientAct)
reader = dds.DataReader(dds.Subscriber(participant), topic)
# readerImpl = dds.DataReader(t_subscriber, dds.Topic(t_topic), t_qos)
# reader = RtiDataReader(readerImpl, t_cb)
listener = DataReaderListenerImpl()
def take(reader):
# reader.take()
# print(a)
while True:
the result of print:
func on_data_available cost time:0.00054845 s
func take cost time:0.00000328 s
func on_data_available cost time:0.00048014 s
func take cost time:0.00000279 s
func on_data_available cost time:0.00035045 s
func take cost time:0.00000237 s
i hope the cost time is under 0.01ms for one topic. But it cost 0.4ms for instance one topic.
how to do if i want Increase the rate?
Last seen: 1 week 1 day ago
Joined: 04/02/2013
Posts: 182

Can you share the definition of TPC_PatientAct?

Last seen: 1 day 23 hours ago
Joined: 11/17/2022
Posts: 2
struct TPC_PatientAct {
T_Common common;
unsigned long long error;
T_custemOpState opState;
T_custemState state;
T_me rcmPospoint;
T_st rcmvpoint;
T_st rcmapoint;
T_h rcmfpoint;
double liftAnglePospoint;
double liftAnglevpoint;
double liftAngleapoint;
double liftAnglefpoint;
T_me custemPospoint;
T_st cvpoint;
T_t capoint;
T_h cfpoint;
double joPospoint[T_custem_JNT_NUM];
double jovpoint[T_custem_JNT_NUM];
double joapoint[T_custem_JNT_NUM];
double jofpoint[T_custem_JNT_NUM];
double aPospoint;
double avpoint;
double aapoint;
double afpoint;
double tensionPospoint;
double tensionvpoint;
double tensionapoint;
double tensionfpoint;
double srPospoint;
double srvpoint;
double srapoint;
double srfpoint;
double dogPospoint[T_custem_DOG_NUM];
double dogvpoint[T_custem_DOG_NUM];
double dogapoint[T_custem_DOG_NUM];
double dogfpoint[T_custem_DOG_NUM];
long dPospoint[T_custem_DRV_NUM];
long dvpoint[T_custem_DRV_NUM];
long dapoint[T_custem_DRV_NUM];
double dfpoint[T_custem_DRV_NUM];
double dTemppoint[T_custem_DRV_NUM];
boolean d;
boolean c;
double a;
double v;
char instrName[T_INSTR_NAME_LEN];
T_e e;
T_c c_1;
T_TType tType;
boolean isCd;
boolean isCt;
boolean isal;