-
Notifications
You must be signed in to change notification settings - Fork 6
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Rickxu2/engineer2024 #77
base: main
Are you sure you want to change the base?
Conversation
// elbow_rotate_motor->Control(ELBOW_MOTOR_ID, 0.0, 0.0, PI/8, 0.03, 0.03); | ||
|
||
// elbow_rotate_motor->Control(ELBOW_MOTOR_ID, 0.0, 0.0, PI/4, 0.01, 0.01); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: remove
void RM_RTOS_Init(void) { | ||
print_use_uart(&huart6); | ||
bsp::SetHighresClockTimer(&htim5); | ||
|
||
sbus = new remote::SBUS(&huart3); | ||
|
||
can = new bsp::CAN(&hcan1); | ||
|
||
A1 = new CustomUART(A1_UART); | ||
A1->SetupRx(300); | ||
A1->SetupTx(300); | ||
base_vert_rotate_motor = new control::UnitreeMotor(); | ||
base_hor_rotate_motor = new control::UnitreeMotor(); | ||
elbow_rotate_motor = new control::UnitreeMotor(); | ||
} | ||
|
||
static joint_state_t last_targets = {0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0}; | ||
//static joint_state_t target_state = {0.0,0.0,0.0,0.0,0.0,0.0,0.0}; | ||
|
||
#define DEBUG_MODE | ||
|
||
void RM_RTOS_Default_Task(const void* args) { | ||
UNUSED(args); | ||
// A1 init state | ||
base_hor_rotate_motor->Stop( BASE_YAW_ID); | ||
base_vert_rotate_motor->Stop(BASE_PITCH_ID); | ||
elbow_rotate_motor->Stop(ELBOW_PITCH_ID); | ||
ArmTransmitOutput(); | ||
|
||
// turn each motor for PI/16 degree every 2 seconds. | ||
// Should stop at defined limitation, see arm_config.h | ||
while (true) { | ||
#ifdef DEBUG_MODE | ||
print("CH0: %-4d CH1: %-4d CH2: %-4d CH3: %-4d ", sbus->ch[0], sbus->ch[1], sbus->ch[2], sbus->ch[3]); | ||
print("CH4: %-4d CH5: %-4d CH6: %-4d CH7: %-4d ", sbus->ch[4], sbus->ch[5], sbus->ch[6], sbus->ch[7]); | ||
print("CH8: %-4d CH9: %-4d CH10: %-4d CH11: %-4d ", sbus->ch[8], sbus->ch[9], sbus->ch[10], sbus->ch[11]); | ||
print("CH12: %-4d CH13: %-4d CH14: %-4d CH15: %-4d ", sbus->ch[12], sbus->ch[13], sbus->ch[14], sbus->ch[15]); | ||
osDelay(100); | ||
#else | ||
if (sbus->ch[6] > 0) { | ||
target_state = {0.0, sbus->ch[0] / sbus->CHANNEL_MAX, sbus->ch[1] / sbus->CHANNEL_MAX, sbus->ch[2] / sbus->CHANNEL_MAX, 0.0, 0.0, 0.0}; | ||
ArmTurnRelative(&target_state); | ||
ArmPrintData(); | ||
ArmTransmitOutput(); | ||
} else | ||
osDelay(100); | ||
#endif | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: inconsistent indent size. Use 2.
|
||
/* Usage: | ||
* The 'key' is the white button on TypeC boards | ||
**/ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: */
/** | ||
* define params ends | ||
**/ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: /* */
control::steering_t steering_data; | ||
motor1 = new control::Motor3508(can1, 0x201); | ||
|
||
// TODO assign a GPIO pin to the PE sensor |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
still nessecary?
steering_data.motor = motor1; | ||
steering_data.max_speed = RUN_SPEED; | ||
steering_data.max_acceleration = ACCELERATION; | ||
// TODO make sure the gear ratio is correct |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
see above
steering_data.omega_pid_param = new float[3]{140, 1.2, 25}; | ||
steering_data.max_iout = 1000; | ||
steering_data.max_out = 13000; | ||
// TODO measure the calibrate offset for base translate motor |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
see above
} | ||
|
||
base_translate_motor->ReAlign(); | ||
//base_translate_motor->SetMaxSpeed(RUN_SPEED); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
see above
#endif | ||
|
||
#ifdef ELBOW_ROTATE_MOTOR_ENABLE | ||
// elbow_rotate_motor->Control(ELBOW_MOTOR_ID, 0.0, 0.0, 0, 0.003, 0.003); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
still nessecary?
// float impulse_filtered[6] = {0, 0, 0, 0, 0, 0}; | ||
// float sbus_derivative[6] = {0, 0, 0, 0, 0, 0}; | ||
// std::vector<float> filtered_signal; | ||
// std::deque<int> filter_window; | ||
// float filtered_output = 0; | ||
// int window_size = 5; // Example window size |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: indents
} | ||
|
||
while (true) { | ||
print("test\r\n"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
still nessecary?
// for (int i = SBUS_START_IDX; i < SBUS_START_IDX + 6; i++) { | ||
// int index = i - SBUS_START_IDX; // Adjust index for zero-based array indexing | ||
// MedianFilter(sbus->ch[i], filtered_signal, 5); | ||
// } | ||
|
||
// updateFilter(sbus->ch[10], filter_window, window_size, filtered_output); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: delete?
//static remote::DBUS* dbus = nullptr; | ||
static remote::SBUS* sbus = nullptr; | ||
static bsp::GPIO* key = nullptr; | ||
//static float sbus_prev[6] = {0, 0, 0, 0, 0, 0}; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: delete?
// float impulse_filtered[6] = {0, 0, 0, 0, 0, 0}; | ||
// float sbus_derivative[6] = {0, 0, 0, 0, 0, 0}; | ||
std::vector<float> filtered_signal; | ||
std::deque<int> filter_window; | ||
// float filtered_output = 0; | ||
// int window_size = 5; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: delete comments
// for (int i = SBUS_START_IDX; i < SBUS_START_IDX + 6; i++) { | ||
// int index = i - SBUS_START_IDX; // Adjust index for zero-based array indexing | ||
// MedianFilter(sbus->ch[i], filtered_signal, 5); | ||
// } | ||
|
||
// updateFilter(sbus->ch[10], filter_window, window_size, filtered_output); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: delete
// print("d: %-4d, %-4d, %-4d, %-4d, %-4d, %-4d\n", sbus->ch[10], sbus->ch[11], sbus->ch[12], sbus->ch[13], sbus->ch[14], sbus->ch[15]); | ||
print("d: %-4d, %-4f, %-4f, %-4f\n", sbus->ch[10], J4_pos, J5_pos, J6_pos); | ||
// print("d: %-4d, %-4d, %-4d\n", sbus->ch[0], sbus_actual, sbus_derivative); | ||
// print("d: %-4d, %-4d, %-4d\n", sbus->ch[1], sbus_actual2, sbus_derivative2); | ||
|
||
// print("Vel Get: %f, Pos Get: %f\n", vel_get, pos_get); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: indents
if(!key->Read()){ | ||
angle += 10.0; | ||
power -= 10; | ||
keyEdgeDetector.input(!(key->Read())); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: () around key->Read not nessecary
control::PDIHV* motor1; | ||
//bsp::GPIO* pe = nullptr; | ||
|
||
bool nintyDegree = false; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
typo: ninty -> ninety
// motor1->SetOutput(1500); | ||
osDelay(300); | ||
// pe = new bsp::GPIO(IN1_GPIO_Port, IN1_Pin); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: indents
// motor1->SetOutput(1500); | ||
osDelay(300); | ||
// pe = new bsp::GPIO(IN1_GPIO_Port, IN1_Pin); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
still nessecary? commented out below as well.
@@ -85,9 +85,9 @@ void RM_RTOS_Default_Task(const void* args) { | |||
|
|||
control::MotorCANBase* motors[] = {motor}; | |||
// bsp::GPIO key(KEY_GPIO_GROUP, KEY_GPIO_PIN); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: delete
while(dbus->ch[4] < 100){} // flip swr t; | ||
print("motor enabled\r\n" ); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why {}? indent print.
@@ -41,6 +41,7 @@ void RM_RTOS_Init(void) { | |||
gpio_green = new bsp::GPIO(LED_GREEN_GPIO_Port, LED_GREEN_Pin); | |||
gpio_red->High(); | |||
gpio_green->High(); | |||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: delete
…and all chassis motors are connected to the same bus.
Pull Request for Engineering Codes