xiaoxiang781216 commented on code in PR #2113: URL: https://github.com/apache/nuttx-apps/pull/2113#discussion_r1355461856
########## examples/sensor_fusion/sensor_fusion_main.c: ########## @@ -0,0 +1,157 @@ +/**************************************************************************** + * apps/examples/sensor_fusion/sensor_fusion_main.c + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. The + * ASF licenses this file to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance with the + * License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the + * License for the specific language governing permissions and limitations + * under the License. + * + ****************************************************************************/ + +/**************************************************************************** + * Included Files + ****************************************************************************/ +#include <nuttx/config.h> +#include <stdio.h> +#include <fcntl.h> +#include <unistd.h> +#include <nuttx/sensors/sensor.h> +#include "Fusion/Fusion.h" + Review Comment: add predefine section ########## examples/sensor_fusion/sensor_fusion_main.c: ########## @@ -0,0 +1,157 @@ +/**************************************************************************** + * apps/examples/sensor_fusion/sensor_fusion_main.c + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. The + * ASF licenses this file to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance with the + * License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the + * License for the specific language governing permissions and limitations + * under the License. + * + ****************************************************************************/ + +/**************************************************************************** + * Included Files + ****************************************************************************/ Review Comment: add blank line after the comment ########## examples/sensor_fusion/sensor_fusion_main.c: ########## @@ -0,0 +1,157 @@ +/**************************************************************************** + * apps/examples/sensor_fusion/sensor_fusion_main.c + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. The + * ASF licenses this file to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance with the + * License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the + * License for the specific language governing permissions and limitations + * under the License. + * + ****************************************************************************/ + +/**************************************************************************** + * Included Files + ****************************************************************************/ +#include <nuttx/config.h> +#include <stdio.h> +#include <fcntl.h> +#include <unistd.h> +#include <nuttx/sensors/sensor.h> +#include "Fusion/Fusion.h" + +#define REG_LOW_MASK 0xFF00 +#define REG_HIGH_MASK 0x00FF +#define MPU6050_FS_SEL 65.5f +#define MPU6050_AFS_SEL 4096.0f + +/**************************************************************************** + * Public Data + ****************************************************************************/ + +struct mpu6050_imu_msg +{ + int16_t acc_x; + int16_t acc_y; + int16_t acc_z; + int16_t temp; + int16_t gyro_x; + int16_t gyro_y; + int16_t gyro_z; +}; + +/**************************************************************************** + * Public Functions + ****************************************************************************/ + +void read_mpu6050(int fd, struct sensor_accel *acc_data, + struct sensor_gyro *gyro_data); + +/**************************************************************************** + * sensor_fusion_main + ****************************************************************************/ + +int main(int argc, FAR char *argv[]) +{ + int fd; + int iterations = CONFIG_EXAMPLES_SENSOR_FUSION_SAMPLES; + float acq_period = CONFIG_EXAMPLES_SENSOR_FUSION_SAMPLE_RATE / 1000.0f; + + printf("Sensor Fusion example\n"); + printf("Sample Rate: %.2f Hz\n", 1.0 / acq_period); + + /* Minimal required data for Fusion library. Use of magnetometer data + * is optional and can improve performance. + */ + + struct sensor_accel imu_acc_data; + struct sensor_gyro imu_gyro_data; Review Comment: ALL local variable need be declared at the begin of function ########## examples/sensor_fusion/sensor_fusion_main.c: ########## @@ -0,0 +1,157 @@ +/**************************************************************************** + * apps/examples/sensor_fusion/sensor_fusion_main.c + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. The + * ASF licenses this file to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance with the + * License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the + * License for the specific language governing permissions and limitations + * under the License. + * + ****************************************************************************/ + +/**************************************************************************** + * Included Files + ****************************************************************************/ +#include <nuttx/config.h> +#include <stdio.h> +#include <fcntl.h> +#include <unistd.h> +#include <nuttx/sensors/sensor.h> +#include "Fusion/Fusion.h" + +#define REG_LOW_MASK 0xFF00 +#define REG_HIGH_MASK 0x00FF +#define MPU6050_FS_SEL 65.5f +#define MPU6050_AFS_SEL 4096.0f + +/**************************************************************************** + * Public Data Review Comment: Types not Data ########## inertial/Kconfig: ########## @@ -0,0 +1,10 @@ +# +# For a description of the syntax of this configuration file, +# see the file kconfig-language.txt in the NuttX tools repository. +# +# This file is autogenerated, do not edit. +# + +menu "Inertial Libraries Support" +source "/root/nuttxspace/nuttx-apps/inertial/madgwick/Kconfig" Review Comment: wrong source -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: commits-unsubscr...@nuttx.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org