ajout coordonnées X et Y

This commit is contained in:
dd060606
2025-04-01 16:58:34 +02:00
parent 46db4c4582
commit f598892bb3
4 changed files with 40 additions and 18 deletions

8
Core/Src/.idea/.gitignore generated vendored Normal file
View File

@@ -0,0 +1,8 @@
# Default ignored files
/shelf/
/workspace.xml
# Editor-based HTTP Client requests
/httpRequests/
# Datasource local storage ignored files
/dataSources/
/dataSources.local.xml

View File

@@ -6,6 +6,9 @@
<option name="/Default/Housekeeping/FeatureSuggestion/FeatureSuggestionManager/DisabledSuggesters/=SwitchToGoToActionSuggester/@EntryIndexedValue" value="true" type="bool" />
<option name="/Default/Housekeeping/FeatureSuggestion/FeatureSuggestionManager/DisabledSuggesters/=SwitchToGoToActionSuggester/@EntryIndexRemoved" />
</component>
<component name="CMakeProjectFlavorService">
<option name="flavorId" value="CMakePlainProjectFlavor" />
</component>
<component name="ChangeListManager">
<list default="true" id="9c5961ff-4964-42f5-a9a6-60421faaeed1" name="Changes" comment="" />
<option name="SHOW_DIALOG" value="false" />
@@ -30,18 +33,19 @@
<option name="hideEmptyMiddlePackages" value="true" />
<option name="showLibraryContents" value="true" />
</component>
<component name="PropertiesComponent">{
&quot;keyToString&quot;: {
&quot;RunOnceActivity.RadMigrateCodeStyle&quot;: &quot;true&quot;,
&quot;RunOnceActivity.ShowReadmeOnStart&quot;: &quot;true&quot;,
&quot;RunOnceActivity.cidr.known.project.marker&quot;: &quot;true&quot;,
&quot;RunOnceActivity.readMode.enableVisualFormatting&quot;: &quot;true&quot;,
&quot;cf.first.check.clang-format&quot;: &quot;false&quot;,
&quot;cidr.known.project.marker&quot;: &quot;true&quot;,
&quot;nodejs_package_manager_path&quot;: &quot;npm&quot;,
&quot;vue.rearranger.settings.migration&quot;: &quot;true&quot;
<component name="PropertiesComponent"><![CDATA[{
"keyToString": {
"RunOnceActivity.RadMigrateCodeStyle": "true",
"RunOnceActivity.ShowReadmeOnStart": "true",
"RunOnceActivity.cidr.known.project.marker": "true",
"RunOnceActivity.readMode.enableVisualFormatting": "true",
"cf.first.check.clang-format": "false",
"cidr.known.project.marker": "true",
"last_opened_file_path": "C:/Users/doria/Desktop/Dev/C/Cours/TPs/DS_LISTE_CHAINE",
"nodejs_package_manager_path": "npm",
"vue.rearranger.settings.migration": "true"
}
}</component>
}]]></component>
<component name="SpellCheckerSettings" RuntimeDictionaries="0" Folders="0" CustomDictionaries="0" DefaultDictionary="application-level" UseSingleDictionary="true" transferred="true" />
<component name="TaskManager">
<task active="true" id="Default" summary="Default task">
@@ -52,6 +56,7 @@
<updated>1743082598937</updated>
<workItem from="1743082600720" duration="8000" />
<workItem from="1743082851630" duration="4000" />
<workItem from="1743173529460" duration="32000" />
</task>
<servers />
</component>

View File

@@ -58,7 +58,8 @@ void SystemClock_Config(void);
/* Private user code ---------------------------------------------------------*/
/* USER CODE BEGIN 0 */
int counter1=0;
int counter2=0;
/* USER CODE END 0 */
/**

View File

@@ -22,7 +22,7 @@ extern UART_HandleTypeDef huart2;
Motor motor(TIM3);
// Données odométriques
volatile int32_t lastPosRight = 0, lastPosLeft = 0;
volatile int lastPosRight = 0, lastPosLeft = 0;
volatile float totalDistance = 0.0f;
volatile float posX = 0.0f, posY = 0.0f, theta = 0.0f;
@@ -42,11 +42,11 @@ void ModelecOdometrySetup() {
}
void ModelecOdometryUpdate() {
int32_t posRight = __HAL_TIM_GET_COUNTER(&htim2);
int32_t posLeft = __HAL_TIM_GET_COUNTER(&htim21);
int posRight = __HAL_TIM_GET_COUNTER(&htim2);
int posLeft = __HAL_TIM_GET_COUNTER(&htim21);
int32_t deltaP_right = posRight - lastPosRight;
int32_t deltaP_left = posLeft - lastPosLeft;
int deltaP_right = posRight - lastPosRight;
int deltaP_left = posLeft - lastPosLeft;
if (deltaP_right > MAX_COUNT / 2) deltaP_right -= MAX_COUNT;
if (deltaP_right < -MAX_COUNT / 2) deltaP_right += MAX_COUNT;
@@ -60,10 +60,18 @@ void ModelecOdometryUpdate() {
//Calcul de l'angle theta
float deltaTheta = (deltaS_right - deltaS_left) / WHEEL_BASE;
if (fabs(deltaP_right - deltaP_left) < 5) { // Seulement si on est "presque" en ligne droite
if (fabs(deltaTheta) > 0.1) {
deltaTheta = 0;
}
}
//On met à jour la distance parcourue totale
totalDistance += fabs(deltaS);
theta += deltaTheta;
// Normalisation de theta dans [-π, π]
theta = fmod(theta + M_PI, 2 * M_PI) - M_PI;
float deltaX = deltaS * cos(theta);
float deltaY = deltaS * sin(theta);
@@ -86,7 +94,7 @@ void ModelecOdometryLoop() {
if (isDelayPassed(10)) {
ModelecOdometryUpdate();
motor.update();
if (totalDistance >= 150) {
if (posX >= 200) {
motor.stop();
}
}