-
Notifications
You must be signed in to change notification settings - Fork 14
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
8ec8f85
commit 9cbdcb7
Showing
4 changed files
with
101 additions
and
35 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
// | ||
// Created by Wu Feiyang on 2023/7/11. | ||
// | ||
#include "user_dart.h" | ||
UserDart::UserThread UserDart::userThread; | ||
void UserDart::start(tprio_t user_thd_prio) { | ||
userThread.start(user_thd_prio); | ||
} | ||
|
||
void UserDart::UserThread::main(){ | ||
setName("RemoteControl"); | ||
static float angle; | ||
feedback = CANMotorIF::motor_feedback[CANMotorCFG::MOTOR_ONE]; | ||
angle = feedback.accumulate_angle(); | ||
while(!shouldTerminate()){ | ||
chSysLock(); | ||
if(Remote::rc.s1 == Remote::S_UP){ | ||
CANMotorCFG::enable_v2i[CANMotorCFG::MOTOR_ONE] = false; | ||
CANMotorCFG::enable_a2v[CANMotorCFG::MOTOR_ONE] = false; | ||
CANMotorController::set_target_current(CANMotorCFG::MOTOR_ONE,0); | ||
}else if(Remote::rc.s1 == Remote::S_MIDDLE){ | ||
CANMotorCFG::enable_v2i[CANMotorCFG::MOTOR_ONE] = true; | ||
CANMotorCFG::enable_a2v[CANMotorCFG::MOTOR_ONE] = false; | ||
CANMotorController::set_target_vel(CANMotorCFG::MOTOR_ONE, 200*Remote::rc.ch0); | ||
}else if(Remote::rc.s1 == Remote::S_DOWN){ | ||
CANMotorCFG::enable_v2i[CANMotorCFG::MOTOR_ONE] = true; | ||
CANMotorCFG::enable_a2v[CANMotorCFG::MOTOR_ONE] = true; | ||
CANMotorController::set_target_angle(CANMotorCFG::MOTOR_ONE,angle); | ||
} | ||
|
||
chSysUnlock(); | ||
feedback = CANMotorIF::motor_feedback[CANMotorCFG::MOTOR_ONE]; | ||
LOG("initial angle: %f, current angle: %f\r\n",angle,feedback.accumulate_angle()); | ||
chThdSleepMilliseconds(100); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
// | ||
// Created by Wu Feiyang on 2023/7/11. | ||
// | ||
#ifndef META_EMBEDDED_USER_DART_H | ||
#define META_EMBEDDED_USER_DART_H | ||
#include "ch.hpp" | ||
#include "can_interface.h" | ||
#include "can_motor_interface.h" | ||
#include "can_motor_feedback.h" | ||
#include "can_motor_controller.h" | ||
#include "remote_interpreter.h" | ||
|
||
|
||
class UserDart{ | ||
public: | ||
static void start(tprio_t user_thd_prio); | ||
private: | ||
class UserThread:public BaseStaticThread<512>{ | ||
private: | ||
void main() final; | ||
CANMotorFeedback feedback; | ||
}; | ||
static UserThread userThread; | ||
}; | ||
|
||
|
||
#endif //META_EMBEDDED_USER_DART_H |