Making C++ module support variable number of input C messages

36 views
Skip to first unread message

Clément Jonglez

unread,
Nov 11, 2022, 11:57:25 AM11/11/22
to Basilisk Forum
Hi folks,

I am having trouble writing a new module whose input is a variable number of
IMUSensorBodyMsgPayload messages. I've read the documentation on how to do that, and I've read the eclipse example, but still I am getting an error message about the module getting a IMUSensorBodyMsg_C pointer instead of a IMUSensorBodyMsgPayload pointer.

The C++ module is in the attached ZIP file.

The Python code calling the external module is the following:
from Basilisk.ExternalModules import VectorVoter_bsk
vector_voter = VectorVoter_bsk.VectorVoter_bsk()
vector_voter.ModelTag = "IMU Voter"
for i_imu, imu_defs in imu_df.iterrows():
     vector_voter.addSensorToVoter(imu_defs['imuCommConfig'].imuSensorOutMsg)
scSim.AddModelToTask(att_det_task_name, vector_voter)
gives
--------------------------------------------------------------------------- TypeError Traceback (most recent call last) Cell In [19], line 5 3 vector_voter.ModelTag = "IMU Voter" 4 for i_imu, imu_defs in imu_df.iterrows(): ----> 5 vector_voter.addSensorToVoter(imu_defs['imuCommConfig'].imuSensorOutMsg) 6 scSim.AddModelToTask(att_det_task_name, vector_voter) File /media/ssd/git/basilisk/dist3/Basilisk/ExternalModules/VectorVoter_bsk.py:109, in VectorVoter_bsk.addSensorToVoter(self, tmpVecMsg) 108 def addSensorToVoter(self, tmpVecMsg): --> 109 return _VectorVoter_bsk.VectorVoter_bsk_addSensorToVoter(self, tmpVecMsg) TypeError: in method 'VectorVoter_bsk_addSensorToVoter', argument 2 of type 'Message< IMUSensorBodyMsgPayload > *'

where
print(imu_defs['imuCommConfig'].imuSensorOutMsg)
gives
<Basilisk.architecture.messaging.IMUSensorBodyMsgPayload.IMUSensorBodyMsg_C; proxy of <Swig Object of type 'IMUSensorBodyMsg_C *' at 0x7fbaffb7e010> >

I suspect that it's because ImuComm is a C module. If I understood correctly (I am still a Basilisk beginner), when calling subscribeTo, it does not matter if it's a C or C++ module, it's hidden in messaging.h. However, this seems not to be the case when subscribing manually to the multiple input messages in my module's cpp file (method
addSensorToVoter).

Cheers
Clément
VectorVoter_bsk.zip
Reply all
Reply to author
Forward
0 new messages