feagi_agent/sdk/sensory/video/
config.rs1use crate::core::{AgentConfig, AgentType, SdkError};
4use feagi_io::{MotorUnit, SensoryUnit};
5
6#[derive(Debug, Clone, Copy, PartialEq, Eq)]
8pub enum VideoEncodingStrategy {
9 SimpleVision,
11 SegmentedVision,
13}
14
15#[derive(Debug, Clone)]
17pub struct VideoEncoderConfig {
18 pub agent_id: String,
19 pub cortical_unit_id: u8,
20 pub encoding_strategy: VideoEncodingStrategy,
21 pub source_width: u32,
22 pub source_height: u32,
23 pub feagi_host: String,
24 pub feagi_api_port: u16,
25 pub feagi_zmq_registration_port: u16,
26 pub feagi_zmq_sensory_port: u16,
27 pub feagi_zmq_motor_port: u16,
28 pub feagi_tick_hz: u32,
29 pub feagi_heartbeat_interval_s: f64,
30 pub feagi_connection_timeout_ms: u64,
31 pub feagi_registration_retries: u32,
32 pub sensory_send_hwm: i32,
33 pub sensory_linger_ms: i32,
34 pub sensory_immediate: bool,
35 pub diff_threshold: u8,
36 pub brightness: i32,
37 pub contrast: f32,
38}
39
40impl VideoEncoderConfig {
41 pub fn to_agent_config(&self) -> Result<AgentConfig, SdkError> {
43 let registration_endpoint = format!(
44 "tcp://{}:{}",
45 self.feagi_host, self.feagi_zmq_registration_port
46 );
47 let sensory_endpoint = format!("tcp://{}:{}", self.feagi_host, self.feagi_zmq_sensory_port);
48 let motor_endpoint = format!("tcp://{}:{}", self.feagi_host, self.feagi_zmq_motor_port);
49
50 let agent_type = AgentType::Sensory;
51 Ok(AgentConfig::new(self.agent_id.clone(), agent_type)
52 .with_vision_unit(
53 "vision",
54 (self.source_width as usize, self.source_height as usize),
55 3,
56 SensoryUnit::Vision,
57 self.cortical_unit_id,
58 )
59 .with_sensory_socket_config(
60 self.sensory_send_hwm,
61 self.sensory_linger_ms,
62 self.sensory_immediate,
63 )
64 .with_registration_endpoint(registration_endpoint)
65 .with_sensory_endpoint(sensory_endpoint)
66 .with_motor_endpoint(motor_endpoint)
67 .with_heartbeat_interval(self.feagi_heartbeat_interval_s)
68 .with_connection_timeout_ms(self.feagi_connection_timeout_ms)
69 .with_registration_retries(self.feagi_registration_retries))
70 }
71
72 pub fn to_agent_config_with_motor_feedback(&self) -> Result<AgentConfig, SdkError> {
74 let registration_endpoint = format!(
75 "tcp://{}:{}",
76 self.feagi_host, self.feagi_zmq_registration_port
77 );
78 let sensory_endpoint = format!("tcp://{}:{}", self.feagi_host, self.feagi_zmq_sensory_port);
79 let motor_endpoint = format!("tcp://{}:{}", self.feagi_host, self.feagi_zmq_motor_port);
80
81 let agent_type = AgentType::Both;
82 Ok(AgentConfig::new(self.agent_id.clone(), agent_type)
83 .with_vision_unit(
84 "segmented-vision",
85 (self.source_width as usize, self.source_height as usize),
86 3,
87 SensoryUnit::SegmentedVision,
88 self.cortical_unit_id,
89 )
90 .with_motor_unit("gaze", 2, MotorUnit::Gaze, self.cortical_unit_id)
91 .with_sensory_socket_config(
92 self.sensory_send_hwm,
93 self.sensory_linger_ms,
94 self.sensory_immediate,
95 )
96 .with_registration_endpoint(registration_endpoint)
97 .with_sensory_endpoint(sensory_endpoint)
98 .with_motor_endpoint(motor_endpoint)
99 .with_heartbeat_interval(self.feagi_heartbeat_interval_s)
100 .with_connection_timeout_ms(self.feagi_connection_timeout_ms)
101 .with_registration_retries(self.feagi_registration_retries))
102 }
103}