Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add USB to Serial Config for MicroDDS #21233

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

AlexKlimaj
Copy link
Member

@AlexKlimaj AlexKlimaj commented Mar 2, 2023

This PR adds USB to the serial port configurations in order to use USB for microdds.

Starting Micro XRCE-DDS on /dev/ttyACM0
nsh> INFO  [microdds_client] synchronized with time offset 1677716912048491us
INFO  [microdds_client] successfully created rt/fmu/out/failsafe_flags data writer, topic id: 84
INFO  [microdds_client] successfully created rt/fmu/out/sensor_combined data writer, topic id: 170
INFO  [microdds_client] successfully created rt/fmu/out/timesync_status data writer, topic id: 190
INFO  [microdds_client] successfully created rt/fmu/out/vehicle_attitude data writer, topic id: 207
INFO  [microdds_client] successfully created rt/fmu/out/vehicle_control_mode data writer, topic id: 213
INFO  [microdds_client] successfully created rt/fmu/out/vehicle_local_position data writer, topic id: 220
INFO  [microdds_client] successfully created rt/fmu/out/vehicle_odometry data writer, topic id: 225
INFO  [microdds_client] successfully created rt/fmu/out/vehicle_status data writer, topic id: 230
INFO  [microdds_client] successfully created rt/fmu/out/sensor_accel_fifo data writer, topic id: 168
INFO  [microdds_client] successfully created rt/fmu/out/sensor_gyro_fifo data writer, topic id: 176
INFO  [microdds_client] successfully created rt/fmu/out/sensor_mag data writer, topic id: 178
INFO  [microdds_client] successfully created rt/fmu/out/sensor_baro data writer, topic id: 169
INFO  [microdds_client] successfully created rt/fmu/out/sensor_accel data writer, topic id: 167
INFO  [microdds_client] successfully created rt/fmu/out/sensor_gyro data writer, topic id: 174
INFO  [microdds_client] successfully created rt/fmu/out/actuator_armed data writer, topic id: 1
INFO  [microdds_client] successfully created rt/fmu/out/actuator_controls_0 data writer, topic id: 2
INFO  [microdds_client] successfully created rt/fmu/out/actuator_motors data writer, topic id: 9
INFO  [microdds_client] successfully created rt/fmu/out/vehicle_thrust_setpoint data writer, topic id: 231
INFO  [microdds_client] successfully created rt/fmu/out/vehicle_torque_setpoint data writer, topic id: 232
INFO  [microdds_client] successfully created rt/fmu/out/vehicle_rates_setpoint data writer, topic id: 228
INFO  [microdds_client] successfully created rt/fmu/out/vehicle_imu data writer, topic id: 217
INFO  [microdds_client] successfully created rt/fmu/out/vehicle_angular_velocity data writer, topic id: 205

nsh> microdds_client status
INFO  [microdds_client] Running, connected
INFO  [microdds_client] Payload tx: 381804 B/s
INFO  [microdds_client] Payload rx: 0 B/s
nsh>

On the Jetson
image

@beniaminopozzan
Copy link
Member

Thanks @AlexKlimaj !
Is it possible to extend it to other boards?

@AlexKlimaj
Copy link
Member Author

Thanks @AlexKlimaj ! Is it possible to extend it to other boards?

Yeah, I don't see why not.

@dagar
Copy link
Member

dagar commented Mar 2, 2023

I think this is the right direction, but needs to be coordinated with the existing autostart stuff.

@AlexKlimaj
Copy link
Member Author

It appears to play nice with the mavlink usb auto start.

Copy link
Member

@dagar dagar left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I believe to do this properly we need to slip in sercon somewhere to start NuttX CDCACM, and then in the autostart code have it skip if sercon already start or /dev/ttyACM0 exists.

case UsbAutoStartState::disconnected:
if (vbus_present && vbus_present_prev) {
if (sercon_main(0, nullptr) == EXIT_SUCCESS) {
usb_auto_start_state = UsbAutoStartState::connecting;
rescheduled = work_queue(LPWORK, &usb_serial_work, mavlink_usb_check, nullptr, USEC2TICK(100000));
}

It's also critical that we don't perform the disconnect cleanup because most of these apps will not fail gracefully if /dev/ttyACM0 disappears.

case UsbAutoStartState::disconnecting:
// serial disconnect if unused
serdis_main(0, NULL);
usb_auto_start_state = UsbAutoStartState::disconnected;
break;

@DronecodeBot
Copy link

This pull request has been mentioned on Discussion Forum for PX4, Pixhawk, QGroundControl, MAVSDK, MAVLink. There might be relevant details there:

https://discuss.px4.io/t/setting-up-the-px4-fast-rtps-dds-bridge-with-real-hardware/29876/3

@junwoo091400
Copy link
Contributor

Maybe dumb question, but we can't connect the QGC or HITL interface through the USB port when the DDS is in use right?

I ended up in a situation where I can't connect to the FC anymore because the DDS is running 😆. Did you run into this problem too? If so, how did you access the FC to change the config (e.g. disable DDS on USB) @AlexKlimaj ?

@carbide2004
Copy link

I tried this method, but it still didn't work. I use CUAV x7 pro with px4 firmware, set UXRCE_DDS_CFG "TELEM1", and have disabled MAVLink. The baud rate "SER_TEL1_BAUD" is set the same as the value after "-b". I also start Micro XRCE-DDS on /dev/ttyACM0. I'm wondering what happened.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

6 participants