Skip to content
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

updated code for robot movement #3

Open
wants to merge 38 commits into
base: paul-antoine
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
38 commits
Select commit Hold shift + click to select a range
ef3f85e
pathplanning works
nathmo Nov 16, 2024
362449f
only require the scale of the pixel as an argument
nathmo Nov 16, 2024
13a0626
housekeeping
nathmo Nov 16, 2024
6779021
housekeeping
nathmo Nov 16, 2024
58c7ca1
housekeeping
nathmo Nov 16, 2024
49f3cd3
housekeeping
nathmo Nov 16, 2024
b1c8781
added conversion to connect to the robot + make the robot move at a d…
nathmo Nov 17, 2024
0191446
added function to read robot sensor, but sensor value only update if …
nathmo Nov 17, 2024
bbd6845
Update robotmovement.py
SeifLabib Nov 19, 2024
51f0905
Update robotmovement.py
SeifLabib Nov 19, 2024
598e4ab
Update robotmovement.py
nathmo Nov 20, 2024
431d1fe
Update robotmovement.py
nathmo Nov 20, 2024
2d88adb
code from common test
SeifLabib Nov 19, 2024
beedbcd
Merge remote-tracking branch 'origin/main'
nathmo Nov 22, 2024
5a497a1
implemented update to follow a simple path defined by a list of waypoint
nathmo Nov 22, 2024
17a3ce9
Merge branch 'main' into NathannTest
nathmo Nov 22, 2024
56214d2
fixed sign issue when computing angle
nathmo Nov 22, 2024
bcaae5f
Merge pull request #2 from nathmo/paul-antoine
nathmo Nov 23, 2024
6aa429a
fixed some small detail to improve testing and debugging
nathmo Nov 25, 2024
89e3503
Liste des bug observer :
nathmo Nov 26, 2024
57e1e66
added more picture
nathmo Nov 26, 2024
11bb0c5
fixed a bug in pathplanner that didnt take the pixel scale into account
nathmo Nov 26, 2024
22c0914
Update robotmovement.py with the local avoidance algorithm
SeifLabib Nov 26, 2024
f738cbf
attempting to fix bug where y coordinate is flipped
nathmo Nov 26, 2024
311124d
removed result to clean the folder
nathmo Nov 26, 2024
914b389
made a "live" visualisation.
nathmo Nov 27, 2024
f002de1
trying to fix visualisation overlay of image
nathmo Nov 29, 2024
be9e952
trying to fix visu
nathmo Nov 29, 2024
371e3ab
debugging flip origin
Nov 29, 2024
83a3585
Auto stash before merge of "NathannTest" and "origin/NathannTest"
nathmo Nov 29, 2024
ba180e4
Fixed flipping in GUI
nathmo Nov 29, 2024
80f2bb1
fixed small details
Fel36 Nov 29, 2024
bc8b566
test
nathmo Nov 29, 2024
1cc6d96
Merge remote-tracking branch 'origin/NathannTest' into NathannTest
nathmo Nov 29, 2024
958fcce
Auto stash before merge of "NathannTest" and "origin/NathannTest"
Fel36 Nov 29, 2024
2543bf5
modification test en DLL
Fel36 Nov 30, 2024
e42afdf
added jupyter notebook for report.ipynb
nathmo Dec 3, 2024
4a10758
added some testData
nathmo Dec 3, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
.*
_*
venv*
venv*
result*
Binary file added ARUCO_ROBOT.pdf
Binary file not shown.
Binary file added ARUCO_TARGET.pdf
Binary file not shown.
Binary file removed Marqueur 0.png
Binary file not shown.
Binary file removed Marqueur 1.png
Binary file not shown.
Binary file removed Marqueur 2.png
Binary file not shown.
Binary file removed Marqueur 3.png
Binary file not shown.
Binary file removed Marqueur 4.png
Binary file not shown.
Binary file removed Marqueur 5.png
Binary file not shown.
72 changes: 0 additions & 72 deletions OccupancyMapGeneratorFromImage.py

This file was deleted.

54 changes: 0 additions & 54 deletions helper.py

This file was deleted.

43 changes: 25 additions & 18 deletions main.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,12 @@
from sensorfusion import SensorFusion
from pathplanner import PathPlanner
import numpy as np
from visualisation import Visualisation
import os

def update_loop(robot):
"""Function to run robot.update() in a separate thread at ~100 Hz."""
interval = 0.01 # 10 ms interval (100 Hz)
"""Function to run robot.update() in a separate thread at ~1 Hz."""
interval = 1 # 1000 ms interval (1 Hz)

while True:
start_time = time.perf_counter() # Record the start time
Expand All @@ -25,16 +27,29 @@ def update_loop(robot):

def main():
#
robot = RobotMovement()
vision = VisionSystem()
robot = RobotMovement(debug=False) # debug=True -> dont need robot for simulation
robot.connect()
vision = VisionSystem(use_camera=True, cameraID=1, image_path=os.path.join("testData", "test.jpg"))
sensorfusion = SensorFusion()
pathplanner = PathPlanner(pixel_size_mm=vision.get_pixel_side_mm())
# Start a separate thread for the update loop
update_thread = threading.Thread(target=update_loop, args=(robot,))
update_thread.daemon = True # Daemonize thread to exit when main program exits
update_thread.start()
visualizer = Visualisation(vision.get_pixel_side_mm())
fameA = vision.generate_occupancy_grid()
fameB = vision.get_frame()
#visualizer.update_background(fameA, fameB)
interval = 5 # 5000 ms interval (0.2 Hz)

interval = 1 # 1000 ms interval (1 Hz)
robotPosFromCamera = vision.get_robot_position()
goalPosFromCamera = vision.get_goal_position()
occupancyGrid = vision.generate_occupancy_grid()
waypoints = pathplanner.get_waypoints(occupancyGrid, robotPosFromCamera, goalPosFromCamera)
robot.set_waypoints(waypoints)
robot.set_position(robotPosFromCamera)

# compute only once the waypoints.
while True:
start_time = time.perf_counter() # Record the start time
'''
Expand All @@ -50,23 +65,15 @@ def main():
# add a line to set pixel scale to the path finder
robotPosFromCamera = vision.get_robot_position()
goalPosFromCamera = vision.get_goal_position()
occupancyGrid = vision.generate_occupancy_grid()
robotPosFromEncoder = robot.get_position()
robotSpeedFromEncoder = robot.get_speed()
robotPosFromFusion = sensorfusion.get_estimated_position(robotPosFromEncoder, robotSpeedFromEncoder, robotPosFromCamera)
waypoints = pathplanner.get_waypoints(occupancyGrid, robotPosFromFusion, goalPosFromCamera)
robot.set_position(robotPosFromFusion)
robot.set_waypoints(waypoints)
print("Main ran and have the following intermediate value : ")
print("waypoints : " + str(waypoints))
print("number of waypoints : " + str(len(waypoints)))
print("robotPosFromCamera : "+str(robotPosFromCamera))
print(" + robotPosFromEncoder : " + str(robotPosFromEncoder))
print(" = robotPosFromFusion : " + str(robotPosFromFusion))
print("robotSpeedFromEncoder : " + str(robotSpeedFromEncoder))
print("goalPosFromCamera : " + str(goalPosFromCamera))
print("---------------------------------------------------------")
#robot.set_position(robotPosFromFusion)

# Update plot dynamically
visualizer.update_plot(fameA, fameB, robotPosFromEncoder, robotPosFromCamera, robotPosFromFusion, goalPosFromCamera, waypoints)
#visualizer.update_background(fameA, fameB)

# Calculate the elapsed time and sleep for the remainder of the interval
elapsed_time = time.perf_counter() - start_time
sleep_time = max(0, interval - elapsed_time) # Ensure non-negative sleep time
Expand Down
Loading