-
Notifications
You must be signed in to change notification settings - Fork 51
Change System ID and Component ID defaults and update logic #166
Conversation
Following is the logic: 1. Read ID from the conf file ( 1<id<255 : use as it is, do not read from vehicle id<=0 or id>=255 : use 1 till read from vehicle) 2. If conf file is not there, use default value 1 till valid ID read from vehicle 3. If ID has to be read from vehicle, a. Start sending camera heartbeat with default system ID 1 b. On receiving autopilot heartbeat, send camera heartbeat with updated system ID. c. On receiving heartbeats from multiple autopilots, stick to the first one
When running CSD with gazebo, default is set to MAV_COMP_ID_CAMERA2 to avoid clash with Gazebo Camera running with PX4-SITL. When running without gazebo, default can be set to MAV_COMP_ID_CAMERA.
@hamishwillee @shakthi-prashanth-m Kindly review |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This looks good to me "by inspection". If you have tested it then happy for it to be merged.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I added few comments. Please check.
@@ -68,20 +68,17 @@ MavlinkServer::MavlinkServer(const ConfFile &conf, std::vector<std::unique_ptr<S | |||
_broadcast_addr.sin_port = htons(DEFAULT_MAVLINK_PORT); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Wrong Indentation
src/mavlink_server.cpp
Outdated
if (heartbeat.autopilot == 12) | ||
_system_id = msg->sysid; | ||
|
||
if (heartbeat.autopilot == 12) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's highly recommended to use the corresponding macro over a literal.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed.
src/mavlink_server.cpp
Outdated
log_error("Invalid System ID for MAVLink communication (%d)", opt.sysid); | ||
log_info("Use System ID 1, till heartbeat received from Vehicle"); | ||
_system_id = 1; | ||
_is_sys_id_found = false; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It was false
to to start with, isn't it ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed.
src/mavlink_server.cpp
Outdated
compid = MAV_COMP_ID_CAMERA; | ||
#endif | ||
|
||
while (compid < MAV_COMP_ID_CAMERA6 + 1) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think, while (compid <= MAV_COMP_ID_CAMERA6)
is better in readability.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed.
src/mavlink_server.cpp
Outdated
, _system_id(-1) | ||
, _comp_id(MAV_COMP_ID_CAMERA2) | ||
, _is_sys_id_found(false) | ||
, _system_id(1) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A const
initializer for default system ID would be better.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed.
src/mavlink_server.cpp
Outdated
, _comp_id(MAV_COMP_ID_CAMERA2) | ||
, _is_sys_id_found(false) | ||
, _system_id(1) | ||
, _comp_id(MAV_COMP_ID_CAMERA) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do you initialize this in cases with or without Gazebo ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is an unused variable, need to be removed later
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good, except a minor comment.
src/mavlink_server.cpp
Outdated
@@ -75,10 +76,11 @@ MavlinkServer::MavlinkServer(const ConfFile &conf, std::vector<std::unique_ptr<S | |||
|
|||
} else { | |||
log_error("Invalid System ID for MAVLink communication (%d)", opt.sysid); | |||
log_info("Use System ID 1, till heartbeat received from Vehicle"); | |||
log_info("Use System ID %d, till heartbeat received from Vehicle", DEFAULT_SYSTEM_ID); | |||
_system_id = 1; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Shouldn't this be
_system_id = DEFAULT_SYSTEM_ID;
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed.
StreamManager is not using mavlink_server
06ac84e
to
9e27a20
Compare
The changes are to update the system id and component id defaults and update logic to fix following issues -