Sitl ap camera#32680
Conversation
| @@ -54,6 +54,7 @@ void SITL_State::_sitl_setup() | |||
| #endif | |||
|
|
|||
| sitl_model->set_buzzer(&_sitl->buzzer_sim); | |||
| sitl_model->set_camera(&_sitl->camera_sim); | |||
There was a problem hiding this comment.
Please make this add_camera - we support multiple cameras in the main firmware, we should support it out here, too.
There was a problem hiding this comment.
I made the necessary changes. I wasn't sure about how many cameras to support. From what I saw from AP_Camera.h, added support for 2 cameras. Let me know if anytthing needs to be changed. Thanks!
| @@ -1106,6 +1106,11 @@ void Aircraft::update_external_payload(const struct sitl_input &input) | |||
| { | |||
| external_payload_mass = 0; | |||
|
|
|||
| // update camera | |||
| if (camera && camera->is_enabled()) { | |||
There was a problem hiding this comment.
This should become iteration over an array.
Please note our fondness of continue in these loops when putting the enabled() check in
| @@ -655,6 +655,10 @@ const AP_Param::GroupInfo SIM::var_info3[] = { | |||
| AP_SUBGROUPINFO(vicon, "VICON_", 56, SIM, ViconParms), | |||
| #endif // AP_SIM_VICON_ENABLED | |||
|
|
|||
| // @Group: CAM_ | |||
There was a problem hiding this comment.
| // @Group: CAM_ | |
| #if AP_SIM_CAM_ENABLED | |
| // @Group: CAM_ |
add the define to SIM_config.h
Obviously add this everywhere :-)
38d1797 to
f468f7e
Compare
|
Updated to support multiple cameras using add_camera() and array iteration, with compile-time guards via AP_SIM_CAM_ENABLED. Also added handling for when camera slots are full. |
|
I'll fix the rest of the issues and push again. |
f468f7e to
cd5d181
Compare
Add a new SIM_Camera object to SITL, similar to existing Sprayer and Gripper payload simulations. The camera simulation can be enabled via SIM_CAM_ENABLE and supports triggering image capture via: - servo output (TRIG_SRV + TRIG_PWM) - GPIO pin (GPIO) When triggered, the camera increments an internal image counter and sends a GCS message indicating capture.
Add a new SIM_Camera object to SITL, similar to existing Sprayer and Gripper payload simulations. The camera simulation can be enabled via SIM_CAM_ENABLE and supports triggering image capture via: - servo output (TRIG_SRV + TRIG_PWM) - GPIO pin (GPIO) When triggered, the camera increments an internal image counter and sends a GCS message indicating capture.
cd5d181 to
8045b0b
Compare
Summary
Add a new SITL camera simulation object (SIM_Camera) similar to
existing payload simulations (e.g. sprayer and gripper). The camera
can be triggered via servo output or GPIO and logs image capture events.
Fixes #9396
Classification & Testing (check all that apply and add your own)
Tested in SITL using ArduPlane.
Steps:
Trigger via servo:
Assign a servo output to camera trigger
Increase PWM above threshold (SIM_CAM_SRV_PWM)
Observe GCS output:
SITL: Camera image N
Trigger via GPIO:
Set GPIO pin using SIM_CAM_GPIO
Toggle the corresponding SITL GPIO bit
Verify image capture message is generated
SITL runs normally and camera trigger events are detected correctly.
Description
This PR introduces a new SIM_Camera object in the SITL framework of ArduPilot.
Features:
New SITL camera simulation class (SIM_Camera)
Enable/disable via SIM_CAM_ENABLE
Trigger mechanisms:
Edge-triggered capture detection
Logs image capture events to GCS
Notes:
Edit: