SaddlebackCollegeRobotics / osiris_science

BSD 3-Clause "New" or "Revised" License
0 stars 0 forks source link

Implement Lowering Platform stepper control with a Raspberry Pi #4

Open parham-sharaf opened 2 years ago

parham-sharaf commented 2 years ago

the lowering platform is electronically wired up. The program for this operation is written and integrated into the science GUI via ROS2

austinlucaslake commented 2 years ago

@max9001 First you will need to build and source the code using the following using the following commands:

cd science_ws colcon build --symlink-install source install/setup.bash cd ..

This setup allows you to edit the python files for rapid prototyping without having to rebuild the ROS2 packages. You would just need to go to the respective python file, edit it, then rerun the commands from the repo's base directory as you would normally.

To get the stepper motor code booted up and initialized, you would run: python stepper_motor.py on the target device (i.e. the RPi controlling the stepper motor).

Then to control it remotely, you need to run the following command: ros2 run science_motor_clients stepper_motor_client.py.

max9001 commented 2 years ago
stepper_motor_controller.stepper_motor_server.get_logger().info(f'{e}')
                                                                     ^
SyntaxError: invalid syntax

line 45 stepper_motor.py

For some reason, every single exception is "invalid syntax". If I comment one out it just throws an error on the next one, so obviously something on my computer isn't right.

max9001 commented 2 years ago
stepper_motor_controller.stepper_motor_server.get_logger().info(f'{e}')
                                                                     ^
SyntaxError: invalid syntax

line 45 stepper_motor.py

For some reason, every single exception is "invalid syntax". If I comment one out it just throws an error on the next one, so obviously something on my computer isn't right.

whoops. f strings were implemented in 3.6

theunkn0wn1 commented 2 years ago

caused by @max9001 's interpreter being 2.7, which is unsupported.

austinlucaslake commented 2 years ago
stepper_motor_controller.stepper_motor_server.get_logger().info(f'{e}')
                                                                     ^
SyntaxError: invalid syntax

line 45 stepper_motor.py

For some reason, every single exception is "invalid syntax". If I comment one out it just throws an error on the next one, so obviously something on my computer isn't right.

Fixed with by adding 'as e' to the following code: except Exception as e: stepper_motor_controller.stepper_motor_server.get_logger().error(f'{e}')

Any exceptions should be able to be read by the logger

max9001 commented 2 years ago

Input:

colcon build --symlink-install

output

Traceback (most recent call last):
  File "/usr/bin/colcon", line 6, in <module>
    from pkg_resources import load_entry_point
  File "/usr/lib/python3/dist-packages/pkg_resources/__init__.py", line 3254, in <module>
    def _initialize_master_working_set():
  File "/usr/lib/python3/dist-packages/pkg_resources/__init__.py", line 3237, in _call_aside
    f(*args, **kwargs)
  File "/usr/lib/python3/dist-packages/pkg_resources/__init__.py", line 3266, in _initialize_master_working_set
    working_set = WorkingSet._build_master()
  File "/usr/lib/python3/dist-packages/pkg_resources/__init__.py", line 584, in _build_master
    ws.require(__requires__)
  File "/usr/lib/python3/dist-packages/pkg_resources/__init__.py", line 901, in require
    needed = self.resolve(parse_requirements(requirements))
  File "/usr/lib/python3/dist-packages/pkg_resources/__init__.py", line 787, in resolve
    raise DistributionNotFound(req, requirers)
pkg_resources.DistributionNotFound: The 'pathlib2>=2.2.0' distribution was not found and is required by pytest

After changing my default python version, this unknown package pytest broke. I changed the defualt python version using:

sudo su
update-alternatives --install /usr/bin/python python /usr/bin/python3 1

I've reinstalled python3_colcon_common_extensions (I think this is where pytest is coming from) but that didn't fix it either. So, I can no longer run colcon to use any ROS2 stuff.

lastly, I changed it so python --version returns Python 2.7.18 like it did before, but pytest still is broken....

jasperdoan commented 1 year ago

Written by @austinlake04 :

I'm running into an error when running the lowering platforn server node one the consolidate_nodes branch. This is refering to the node lowering_platform_server.py in the directiory: src/science_servers/science_servers. The class definition is abstracted and can be found in template_servers.py in the same referred to earlier. This earlier is related to the dependency ticlib and the error occurs when initializing the stepper motor driver's object as shown on line 159 in template_servers.py. The error log can be shown below:

Traceback (most recent call last): File "/home/jasper/dev/osiris_science/install/science_servers/lib/science_servers/lowering_platform_server", line 33, in <module> sys.exit(load_entry_point('science-servers', 'console_scripts', 'lowering_platform_server')()) File "/home/jasper/dev/osiris_science/build/science_servers/science_servers/lowering_platform_server.py", line 8, in main boot(LoweringPlatformServer()) File "/home/jasper/dev/osiris_science/build/science_servers/science_servers/template_servers.py", line 159, in __init__ self.driver = TicUSB() File "/home/jasper/.local/lib/python3.8/site-packages/ticlib/ticlib.py", line 650, in __init__ self.usb.set_configuration() AttributeError: 'generator' object has no attribute 'set_configuration'