Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
M
MicroCART
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Deploy
Releases
Model registry
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Distributed Autonomous Networked Control Lab
MicroCART
Commits
3b7a748d
Commit
3b7a748d
authored
6 years ago
by
Tina Li
Browse files
Options
Downloads
Patches
Plain Diff
added debug flag functionality
parent
8bcfdbd6
No related branches found
No related tags found
1 merge request
!43
Resolve "Transition current hardware platform to Vivado"
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
quad/src/quad_app/debug_rt.c
+152
-0
152 additions, 0 deletions
quad/src/quad_app/debug_rt.c
quad/src/quad_app/debug_rt.h
+29
-0
29 additions, 0 deletions
quad/src/quad_app/debug_rt.h
quad/src/quad_app/quad_app.c
+8
-0
8 additions, 0 deletions
quad/src/quad_app/quad_app.c
with
189 additions
and
0 deletions
quad/src/quad_app/debug_rt.c
+
152
−
0
View file @
3b7a748d
#include
<stdio.h>
#include
<stdlib.h>
#include
<string.h>
#include
<stdarg.h>
#include
"PID.h"
#include
"type_def.h"
#include
"debug_rt.h"
#include
"communication.h"
#include
"computation_graph.h"
#include
"timer.h"
//use int send_data(struct UARTDriver *uart, u16 type_id, u16 msg_id, u8* data, size_t size) to send information to the via uart to the wifi chip
//the uart driver is in the comm driver
//send_data(comm->uart, LOG_ID, 0, (u8*)buf.str, buf.size);
//where is LOG ID? Maybe it will compile any if I just write it as is?
//typedef struct hardware_t : this is where you access the comm driver
/*
typedef struct hardware_t {
struct I2CDriver i2c_0;
struct I2CDriver i2c_1;
struct RCReceiverDriver rc_receiver;
struct MotorDriver motors;
struct UARTDriver uart_0;
struct UARTDriver uart_1;
struct GPSDriver gps;
struct CommDriver comm;
struct TimerDriver global_timer;
struct TimerDriver axi_timer;
struct LEDDriver mio7_led;
struct SystemDriver sys;
struct IMUDriver imu;
struct LidarDriver lidar;
struct OpticalFlowDriver of;
} hardware_t;
struct CommDriver {
struct UARTDriver *uart; <-- ???
};
*/
/*
typedef struct modular_structs {
user_input_t user_input_struct;
log_t log_struct;
raw_sensor_t raw_sensor_struct;
sensor_t sensor_struct;
setpoint_t setpoint_struct;
parameter_t parameter_struct;
user_defined_t user_defined_struct;
raw_actuator_t raw_actuator_struct;
actuator_command_t actuator_command_struct;
hardware_t hardware_struct;
} modular_structs_t;
*/
/*
int send_actuator_commands(struct MotorDriver *motors, log_t* log_struct, actuator_command_t* actuator_command_struct) {
int i;
// write the PWMs to the motors
for (i = 0; i < 4; i++) {
motors->write(motors, i, actuator_command_struct->motor_magnitudes[i]);
}
return 0;
}
*/
int
set_debug_level
(
enum
debug_data_types
type
,
int
state
){
switch
(
type
)
{
case
CAMERA
:
flags
->
camera
=
state
;
break
;
case
GYRO
:
flags
->
gyro
=
state
;
break
;
case
ACCELEROMETER
:
flags
->
accelerometer
=
state
;
break
;
case
LIDAR
:
flags
->
lidar
=
state
;
break
;
case
OPT_FLOW
:
flags
->
optical_flow
=
state
;
break
;
case
GPS
:
flags
->
GPS
=
state
;
break
;
case
PID
:
flags
->
PID
=
state
;
break
;
case
RC_TRANS
:
flags
->
RC_transmitter
=
state
;
break
;
case
ACTUATOR
:
flags
->
actuator
=
state
;
break
;
case
default
:
break
;
}
}
char
get_debug_level
(
enum
debug_data_types
type
){
switch
(
type
)
{
case
CAMERA
:
return
flags
->
camera
;
break
;
case
GYRO
:
return
flags
->
gyro
;
break
;
case
ACCELEROMETER
:
return
flags
->
accelerometer
;
break
;
case
LIDAR
:
return
flags
->
lidar
;
break
;
case
OPT_FLOW
:
return
flags
->
optical_flow
;
break
;
case
GPS
:
return
flags
->
GPS
;
break
;
case
PID
:
return
flags
->
PID
;
break
;
case
RC_TRANS
:
return
flags
->
RC_transmitter
;
break
;
case
ACTUATOR
:
return
flags
->
actuator
;
break
;
case
default
:
break
;
}
}
This diff is collapsed.
Click to expand it.
quad/src/quad_app/debug_rt.h
+
29
−
0
View file @
3b7a748d
#include
<stdio.h>
#define ON 1
#define OFF 0
#define ERROR -1
typedef
enum
debug_data_types
{
CAMERA
,
GYRO
,
ACCELEROMETER
,
LIDAR
,
OPT_FLOW
,
GPS
,
PID
,
RC_TRANS
,
ACTUATOR
}
typedef
struct
debug_level_flags
{
char
camera
;
char
gyro
;
char
accelerometer
;
char
lidar
;
char
optical_flow
;
char
GPS
;
char
PID
;
char
RC_transmitter
;
char
actuator
;
}
debug_flags
;
debug_flags
flags
;
int
set_debug_level
(
enum
debug_data_types
type
,
int
state
);
char
get_debug_level
(
enum
debug_data_types
type
);
This diff is collapsed.
Click to expand it.
quad/src/quad_app/quad_app.c
+
8
−
0
View file @
3b7a748d
...
...
@@ -38,6 +38,10 @@ int quad_main(int (*setup_hardware)(hardware_t *hardware_struct))
int
last_kill_condition
=
kill_condition
(
&
(
structs
.
user_input_struct
));
//find debug level
// Main control loop
while
(
1
)
{
...
...
@@ -58,6 +62,8 @@ int quad_main(int (*setup_hardware)(hardware_t *hardware_struct))
// Process the sensor data and put it into sensor_struct
sensor_processing
(
&
(
structs
.
log_struct
),
&
(
structs
.
user_input_struct
),
&
(
structs
.
raw_sensor_struct
),
&
(
structs
.
sensor_struct
));
//Send the sensor data in RT
if
(
!
this_kill_condition
)
{
// Run the control algorithm
...
...
@@ -66,6 +72,8 @@ int quad_main(int (*setup_hardware)(hardware_t *hardware_struct))
// send the actuator commands
send_actuator_commands
(
&
(
structs
.
hardware_struct
.
motors
),
&
(
structs
.
log_struct
),
&
(
structs
.
actuator_command_struct
));
// send actuator to
}
else
{
kill_motors
(
&
(
structs
.
hardware_struct
.
motors
));
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment