Implementing Ancestral Navigation 实现原始导航

本文详细介绍了在应用中实现层级导航的概念,特别关注如何通过应用的ActionBar启用向上导航功能,确保无论用户如何到达当前屏幕,按下向上按钮都能始终导航到同一层级的父屏幕。此外,文章还讨论了当当前活动属于不同应用的任务时如何创建新任务,并提供了使用NavUtils和TaskStackBuilder类的正确行为示例。

Ancestral navigation is up the application's information hierarchy, where the top of the hierarchy (or root) is the application's home screen. This navigation concept is described in Designing Effective Navigation. http://blog.youkuaiyun.com/sergeycao

Implement Up Navigation

When implementing ancestral navigation, all screens in your application that aren't the home screen should offer a means of navigating to the immediate parent screen in the hierarchy via the Up button in the action bar.

Regardless of how the current screen was reached, pressing this button should always take the user to the same screen in the hierarchy.

To implement Up, enable it in the action bar in your activity's onCreate() method:

@Override
public void onCreate(Bundle savedInstanceState) {
    ...
    getActionBar().setDisplayHomeAsUpEnabled(true);
    ...
}

You should also handle android.R.id.home in onOptionsItemSelected(). This resource is the menu item ID for the Home (or Up) button. To ensure that a specific parent activity is shown, DO NOT simply call finish(). Instead, use an intent such as the one described below.

@Override
public boolean onOptionsItemSelected(MenuItem item) {
    switch (item.getItemId()) {
        case android.R.id.home:
            // This is called when the Home (Up) button is pressed
            // in the Action Bar.
            Intent parentActivityIntent = new Intent(this, MyParentActivity.class);
            parentActivityIntent.addFlags(
                    Intent.FLAG_ACTIVITY_CLEAR_TOP |
                    Intent.FLAG_ACTIVITY_NEW_TASK);
            startActivity(parentActivityIntent);
            finish();
            return true;
    }
    return super.onOptionsItemSelected(item);
}

When the current activity belongs to a task from a different application—for example if it was reached via an intent from another application—pressing Up should create a new task for the application with a synthesized back stack. This approach is described in Android Design: Navigation and the TaskStackBuilder class reference.

The NavUtils and TaskStackBuilder classes in the Android Support Package provide helpers for implementing this behavior correctly. An example usage of these two helper classes is below:

@Override
public boolean onOptionsItemSelected(MenuItem item) {
    switch (item.getItemId()) {
        case android.R.id.home:
            Intent upIntent = new Intent(this, MyParentActivity.class);
            if (NavUtils.shouldUpRecreateTask(this, upIntent)) {
                // This activity is not part of the application's task, so create a new task
                // with a synthesized back stack.
                TaskStackBuilder.from(this)
                        .addNextIntent(new Intent(this, MyGreatGrandParentActivity.class))
                        .addNextIntent(new Intent(this, MyGrandParentActivity.class))
                        .addNextIntent(upIntent)
                        .startActivities();
                finish();
            } else {
                // This activity is part of the application's task, so simply
                // navigate up to the hierarchical parent activity.
                NavUtils.navigateUpTo(this, upIntent);
            }
            return true;
    }
    return super.onOptionsItemSelected(item);
}

Properly Handle the Application Home Screen

By default, the Home button in the action bar is interactive. Since it does not make much sense to navigate home—or up one level—while on the home screen, you should disable the button like so:

getActionBar().setHomeButtonEnabled(false);
### SLAM 实时建图与导航方法的研究与实现 #### 关键资源汇总 对于希望深入了解SLAM实时建图及其导航方法的应用者而言,GitHub上的Awesome Object SLAM仓库提供了丰富的资料和最新的研究成果[^1]。此仓库不仅包含了多种SLAM算法的具体实现案例,还附带了详细的文档说明以及相关学术论文。 #### 特征检测与匹配的重要性 特征检测与匹配作为SLAM系统的基础组件,在构建环境模型过程中扮演着至关重要的角色。这些技术能够帮助机器人识别周围环境中不变的地标点,并据此调整自身的位姿估计,从而提高定位准确性并减少累积误差的影响[^2]。 #### 扩展卡尔曼滤波器(EKF)应用于三维空间中的SLAM 针对复杂的真实世界场景下的同步定位与地图创建需求,采用扩展卡尔曼滤波器的方法可以在一定程度上解决非线性系统的状态预测问题。具体来说,通过不断更新传感器观测值来修正当前的位置假设,进而逐步完善整个区域的地图结构。此外,结合LQR控制器可以进一步提升路径规划的效果,确保移动平台按照预期轨迹平稳行驶[^3]。 #### ORB-SLAM Atlas框架的优势分析 ORB-SLAM-Atlas作为一种先进的多会话建图解决方案,特别适合于长时间跨度的任务执行场合。它能够在不同时间段内分别建立局部子图,并最终将其融合成一张完整的全球视图。相比于传统的单一连续记录方式,这种方法显著增强了对动态变化环境适应能力的同时也降低了计算成本。特别是在面对遮挡严重或者光照条件恶劣的情况时表现尤为突出[^4]。 ```python import numpy as np from scipy.optimize import least_squares def ekf_slam_update(x, P, z, H, R): """ EKF SLAM update step. :param x: State vector (position and landmarks positions). :param P: Covariance matrix of the state estimate. :param z: Measurement vector from sensors. :param H: Jacobian of measurement function with respect to states. :param R: Measurement noise covariance. :return: Updated state vector and its associated uncertainty. """ y = z - H @ x # Innovation or residual between predicted measurements and actual ones S = H @ P @ H.T + R # Predicted measurement covariance K = P @ H.T @ np.linalg.inv(S) # Kalman gain calculation updated_x = x + K @ y # Update estimated position based on new information I_KH = np.eye(len(x)) - K @ H updated_P = (I_KH @ P @ I_KH.T) + (K @ R @ K.T) return updated_x, updated_P # Example usage demonstrating how one might call this function during an iteration loop within a larger program implementing EKF-based SLAM algorithm. state_vector = ... # Initialize your initial guess for robot pose plus landmark locations here cov_matrix = ... # Set up corresponding uncertainties initially; will be refined over time through updates measurement_data = [...] # Collect sensor readings at each timestep into list form before processing them all together later via batch optimization approach below: for t in range(num_timesteps): ... next_state_estimation, cov_after_measurement = ekf_slam_update(state_vector[t], cov_matrix[t], measurement_data[t], jacobian_of_h_function(t), measurement_noise_covar) ```
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值