### Install Executables and Libraries Source: https://github.com/quanser/quanser_academic_resources/blob/dev-windows/5_research/sdcs/qcar/hardware/ros1_python/src/rplidar_ros/CMakeLists.txt Installs the built executables and libraries to their designated destinations. ```cmake install(TARGETS rplidarNode rplidarNodeClient ARCHIVE DESTINATION ${CATKIN_PACKAGE_LIB_DESTINATION} LIBRARY DESTINATION ${CATKIN_PACKAGE_LIB_DESTINATION} RUNTIME DESTINATION ${CATKIN_PACKAGE_BIN_DESTINATION} ) ``` -------------------------------- ### Install Data Directories Source: https://github.com/quanser/quanser_academic_resources/blob/dev-windows/5_research/sdcs/qcar/hardware/ros1_python/src/rplidar_ros/CMakeLists.txt Installs data directories like launch, rviz, and sdk to the share destination. ```cmake install(DIRECTORY launch rviz sdk DESTINATION ${CATKIN_PACKAGE_SHARE_DESTINATION} USE_SOURCE_PERMISSIONS ) ``` -------------------------------- ### Download Python 3.14.2 Installer (Windows 64-bit) Source: https://github.com/quanser/quanser_academic_resources/blob/dev-windows/docs/pc_setup.md Download the standalone installer for Python 3.14.2, recommended for Windows 64-bit systems. Ensure 'Add Python to PATH' is selected during installation. ```bash https://www.python.org/ftp/python/3.14.2/python-3.14.2-amd64.exe ``` -------------------------------- ### Download Python 3.13.11 Installer (Windows 64-bit) Source: https://github.com/quanser/quanser_academic_resources/blob/dev-windows/docs/pc_setup.md Download the standalone installer for Python 3.13.11, recommended for Windows 64-bit systems. Ensure 'Add Python to PATH' is selected during installation. ```bash https://www.python.org/ftp/python/3.13.11/python-3.13.11-amd64.exe ``` -------------------------------- ### Download Python 3.11.9 Installer (Windows 64-bit) Source: https://github.com/quanser/quanser_academic_resources/blob/dev-windows/docs/pc_setup.md Download the standalone installer for Python 3.11.9 for Windows 64-bit systems. Ensure 'Add Python to PATH' is selected during installation. ```bash https://www.python.org/ftp/python/3.11.9/python-3.11.9-amd64.exe ``` -------------------------------- ### Download Python 3.12.10 Installer (Windows 64-bit) Source: https://github.com/quanser/quanser_academic_resources/blob/dev-windows/docs/pc_setup.md Download the standalone installer for Python 3.12.10 for Windows 64-bit systems. Ensure 'Add Python to PATH' is selected during installation. ```bash https://www.python.org/ftp/python/3.12.10/python-3.12.10-amd64.exe ``` -------------------------------- ### Install Executable Target Source: https://github.com/quanser/quanser_academic_resources/blob/dev-windows/5_research/qarm/ROS Examples/ros1/src/qarm/CMakeLists.txt Installs an executable target to the runtime destination. ```cmake install(TARGETS ${PROJECT_NAME}_node RUNTIME DESTINATION ${CATKIN_PACKAGE_BIN_DESTINATION} ) ``` -------------------------------- ### Install Other Package Files Source: https://github.com/quanser/quanser_academic_resources/blob/dev-windows/5_research/qarm/ROS Examples/ros1/src/qarm_commander/CMakeLists.txt Installs miscellaneous files like launch or bag files to the share destination. Customize the file list as needed. ```cmake install(FILES # myfile1 # myfile2 DESTINATION ${CATKIN_PACKAGE_SHARE_DESTINATION} ) ``` -------------------------------- ### Install Launch and RT Model Directories Source: https://github.com/quanser/quanser_academic_resources/blob/dev-windows/5_research/sdcs/qcar2/ros2/src/qcar2_nodes/CMakeLists.txt Installs the 'launch' and 'rt_models' directories to the share directory of the ROS 2 package. ```cmake install(DIRECTORY launch DESTINATION share/${PROJECT_NAME}/ ) ``` ```cmake install(DIRECTORY rt_models DESTINATION share/${PROJECT_NAME}/ ) ``` -------------------------------- ### Install Quanser Interactive Labs for MATLAB Source: https://github.com/quanser/quanser_academic_resources/blob/dev-windows/docs/pc_setup.md Install Quanser Interactive Labs through the MATLAB Add On Explorer. This is necessary for users who are not using hardware and are only using virtual devices. ```text Quanser Interactive Labs for MATLAB ``` -------------------------------- ### Run IO Example Script Source: https://github.com/quanser/quanser_academic_resources/blob/dev-windows/5_research/qbot_platform_alpha/IO_examples/python/io_instructions.md Execute the io_example.py script to control the QBot Platform's motors and sensors. Ensure the PYTHONPATH is set correctly. ```python sudo PYTHONPATH=$PYTHONPATH python3 io_example.py ``` -------------------------------- ### Install Other Files Source: https://github.com/quanser/quanser_academic_resources/blob/dev-windows/5_research/qarm/ROS Examples/ros1/src/qarm/CMakeLists.txt Installs other miscellaneous files, such as launch or bag files, to the package's share destination. ```cmake install(FILES #myfile1 #myfile2 DESTINATION ${CATKIN_PACKAGE_SHARE_DESTINATION} ) ``` -------------------------------- ### Basic CMake and Project Setup Source: https://github.com/quanser/quanser_academic_resources/blob/dev-windows/5_research/sdcs/qcar2/ros2/src/qcar2_nodes/CMakeLists.txt Sets the minimum CMake version and project name. Includes compiler flags for GCC and Clang. ```cmake cmake_minimum_required(VERSION 3.8) project(qcar2_nodes) ``` ```cmake if(CMAKE_COMPILER_IS_GNUCXX OR CMAKE_CXX_COMPILER_ID MATCHES "Clang") add_compile_options(-Wall -Wextra -Wpedantic) endif() ``` -------------------------------- ### Run Setup Script to Check Requirements Source: https://github.com/quanser/quanser_academic_resources/blob/dev-windows/docs/pc_setup.md Execute 'step_1_check_requirements' from the '1_setup' folder to verify your computer has the necessary files for your chosen language/configuration. This script generates a log file. ```batch step_1_check_requirements ``` -------------------------------- ### Installing Executable Targets Source: https://github.com/quanser/quanser_academic_resources/blob/dev-windows/5_research/qarm/ROS Examples/ros1/src/qarm_action/CMakeLists.txt Configures the installation of executable targets. This ensures that executables are placed in the correct binary directory after the package is built. ```cmake # install(TARGETS ${PROJECT_NAME}_node # RUNTIME DESTINATION ${CATKIN_PACKAGE_BIN_DESTINATION} # ) ``` -------------------------------- ### Installing Other Package Files Source: https://github.com/quanser/quanser_academic_resources/blob/dev-windows/5_research/qarm/ROS Examples/ros1/src/qarm_action/CMakeLists.txt Marks miscellaneous files, such as launch files or bag files, for installation. These files are often used for running and testing ROS nodes. ```cmake # install(FILES # # myfile1 # # myfile2 # DESTINATION ${CATKIN_PACKAGE_SHARE_DESTINATION} # ) ``` -------------------------------- ### Install Library Targets Source: https://github.com/quanser/quanser_academic_resources/blob/dev-windows/5_research/qarm/ROS Examples/ros1/src/qarm/CMakeLists.txt Installs library targets, including archive, library, and runtime components, to their respective destinations. ```cmake install(TARGETS ${PROJECT_NAME} ARCHIVE DESTINATION ${CATKIN_PACKAGE_LIB_DESTINATION} LIBRARY DESTINATION ${CATKIN_PACKAGE_LIB_DESTINATION} RUNTIME DESTINATION ${CATKIN_GLOBAL_BIN_DESTINATION} ) ``` -------------------------------- ### Installing Library Files Source: https://github.com/quanser/quanser_academic_resources/blob/dev-windows/5_research/sdcs/qcar/hardware/ros1_python/src/vision_opencv/image_geometry/CMakeLists.txt Configures the installation of the library's header files and the compiled library itself to standard ROS package locations. This makes the library available for other packages. ```cmake install(DIRECTORY include/${PROJECT_NAME}/ DESTINATION ${CATKIN_PACKAGE_INCLUDE_DESTINATION}/ ) install(TARGETS ${PROJECT_NAME} RUNTIME DESTINATION ${CATKIN_PACKAGE_BIN_DESTINATION} ARCHIVE DESTINATION ${CATKIN_PACKAGE_LIB_DESTINATION} LIBRARY DESTINATION ${CATKIN_PACKAGE_LIB_DESTINATION} ) ``` -------------------------------- ### QArm - Granular I/O Source: https://context7.com/quanser/quanser_academic_resources/llms.txt This example shows how to use separate methods for controlling QArm joints (`write_position`), setting the base LED (`write_led`), and reading sensor feedback (`read_std`). This allows for more independent control over different aspects of the arm. ```APIDOC ## QArm.write_position / QArm.write_led / QArm.read_std() ### Description Provides granular control over QArm operations by allowing independent writing of joint/gripper commands, LED color, and reading of sensor feedback. ### Methods - `write_position(phiCMD, gprCMD)`: Sends joint and gripper commands. - `write_led(baseLED)`: Sends RGB values to control the base LED. - `read_std()`: Updates all feedback buffers with the latest sensor readings. ### Parameters #### `write_position` Parameters - **phiCMD** (numpy.ndarray) - Required - Joint commands in radians for [base, shoulder, elbow, wrist]. - **gprCMD** (numpy.ndarray) - Required - Gripper command, typically a single value between 0.1 (open) and 0.9 (closed). #### `write_led` Parameters - **baseLED** (numpy.ndarray) - Required - RGB values (0-1) for the base LED. #### `read_std` Parameters None ### Request Example ```python import numpy as np from pal.products.qarm import QArm arm = QArm(hardware=1, readMode=0) try: arm.write_position( phiCMD=np.array([0.0, 0.0, 0.0, 0.0], dtype=np.float64), gprCMD=np.array([0.1], dtype=np.float64) ) arm.write_led(baseLED=np.array([0, 0, 1], dtype=np.float64)) arm.read_std() print("PWM duty cycles:", arm.measJointPWM) finally: arm.terminate() ``` ### Response #### Success Response (200) - `write_position` and `write_led` do not return direct feedback. Sensor data is updated in the arm object's attributes after calling `read_std()`: - **measJointPWM** (numpy.ndarray) - Measured PWM duty cycles for the joints. #### Response Example ```python print("PWM duty cycles:", arm.measJointPWM) ``` ``` -------------------------------- ### Install teleop_twist_keyboard ROS2 Package Source: https://github.com/quanser/quanser_academic_resources/blob/dev-windows/5_research/isaac_sim/qcar2/README.md Installs the teleop_twist_keyboard ROS2 package. Ensure you replace '' with your ROS2 distribution (e.g., 'humble'). ```bash sudo apt-get install ros--teleop-twist-keyboard ``` -------------------------------- ### Installing Library Targets Source: https://github.com/quanser/quanser_academic_resources/blob/dev-windows/5_research/qarm/ROS Examples/ros1/src/qarm_action/CMakeLists.txt Specifies the installation of library targets, including static archives, shared libraries, and runtime components. This is essential for making libraries available to other packages. ```cmake # install(TARGETS ${PROJECT_NAME} # ARCHIVE DESTINATION ${CATKIN_PACKAGE_LIB_DESTINATION} # LIBRARY DESTINATION ${CATKIN_PACKAGE_LIB_DESTINATION} # RUNTIME DESTINATION ${CATKIN_GLOBAL_BIN_DESTINATION} # ) ``` -------------------------------- ### QArm - Synchronized Joint Command/Sense Source: https://context7.com/quanser/quanser_academic_resources/llms.txt This example demonstrates how to connect to a QArm, send synchronized joint and gripper commands, and read back sensor feedback using the `read_write_std()` method. It covers moving joints, controlling the gripper, and setting the base LED color. ```APIDOC ## QArm.read_write_std() ### Description Synchronously sends joint and gripper commands and updates all feedback buffers for the QArm robotic arm. ### Method `read_write_std(phiCMD, gprCMD, baseLED)` ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body - **phiCMD** (numpy.ndarray) - Required - Joint commands in radians for [base, shoulder, elbow, wrist]. - **gprCMD** (numpy.ndarray) - Required - Gripper command, typically a single value between 0.1 (open) and 0.9 (closed). - **baseLED** (numpy.ndarray) - Required - RGB values (0-1) for the base LED. ### Request Example ```python import numpy as np from pal.products.qarm import QArm arm = QArm(hardware=1, readMode=0, frequency=500, deviceId=0) try: joint_cmd = np.array([0.3, -0.2, 0.4, 0.0], dtype=np.float64) gripper_cmd = np.array([0.5], dtype=np.float64) led_rgb = np.array([0, 1, 0], dtype=np.float64) arm.read_write_std(phiCMD=joint_cmd, gprCMD=gripper_cmd, baseLED=led_rgb) finally: arm.terminate() ``` ### Response #### Success Response (200) Feedback data is updated in the arm object's attributes: - **measJointPosition** (numpy.ndarray) - Measured joint positions in radians. - **measJointCurrent** (numpy.ndarray) - Measured joint currents in Amperes. - **measJointSpeed** (numpy.ndarray) - Measured joint speeds in radians per second. - **measJointTemperature** (numpy.ndarray) - Measured joint temperatures in Celsius. #### Response Example ```python print("Joint positions (rad):", arm.measJointPosition) print("Joint currents (A): ", arm.measJointCurrent) print("Joint speeds (rad/s): ", arm.measJointSpeed) print("Temperatures (°C): ", arm.measJointTemperature) ``` ``` -------------------------------- ### Install Executable Nodes Source: https://github.com/quanser/quanser_academic_resources/blob/dev-windows/5_research/sdcs/qcar2/ros2/src/qcar2_nodes/CMakeLists.txt Installs compiled C++ nodes into the ROS 2 package's library directory. ```cmake install(TARGETS qcar2_hardware DESTINATION lib/${PROJECT_NAME}) ``` ```cmake install(TARGETS rgbd DESTINATION lib/${PROJECT_NAME}) ``` ```cmake install(TARGETS lidar DESTINATION lib/${PROJECT_NAME}) ``` ```cmake install(TARGETS csi DESTINATION lib/${PROJECT_NAME}) ``` ```cmake install(TARGETS command DESTINATION lib/${PROJECT_NAME}) ``` ```cmake install(TARGETS nav2_qcar2_converter DESTINATION lib/${PROJECT_NAME}) ``` ```cmake install(TARGETS fixed_lidar_frame DESTINATION lib/${PROJECT_NAME}) ``` ```cmake install(TARGETS fixed_lidar_frame_virtual DESTINATION lib/${PROJECT_NAME}) ``` -------------------------------- ### Installing C++ Header Files Source: https://github.com/quanser/quanser_academic_resources/blob/dev-windows/5_research/qarm/ROS Examples/ros1/src/qarm_action/CMakeLists.txt Configures the installation of C++ header files. This makes the package's public API accessible to other packages that depend on it. ```cmake # install(DIRECTORY include/${PROJECT_NAME}/ # DESTINATION ${CATKIN_PACKAGE_INCLUDE_DESTINATION} # FILES_MATCHING PATTERN "*.h" # PATTERN ".svn" EXCLUDE # ) ``` -------------------------------- ### Install C++ Header Files Source: https://github.com/quanser/quanser_academic_resources/blob/dev-windows/5_research/qarm/ROS Examples/ros1/src/qarm/CMakeLists.txt Installs C++ header files from a specified directory, matching files with a '.h' extension and excluding version control directories. ```cmake install(DIRECTORY include/${PROJECT_NAME}/ DESTINATION ${CATKIN_PACKAGE_INCLUDE_DESTINATION} FILES_MATCHING PATTERN "*.h" PATTERN ".svn" EXCLUDE ) ``` -------------------------------- ### Launch QUARC Server for Traffic Lights Source: https://github.com/quanser/quanser_academic_resources/blob/dev-windows/7_outreach/STEM_Interactive_Exhibit/STEM_Experience/Traffic_Lights/ReadMe.txt Run this batch file to start the QUARC server models for both traffic lights. ```batch run_all_traffic_light.bat ``` -------------------------------- ### Install Executable Scripts Source: https://github.com/quanser/quanser_academic_resources/blob/dev-windows/5_research/sdcs/qcar/hardware/ros1_cpp/src/qcar/CMakeLists.txt This commented-out section shows how to install executable scripts, such as Python scripts, to a specified destination within the ROS package structure. ```cmake # install(PROGRAMS # scripts/my_python_script # DESTINATION ${CATKIN_PACKAGE_BIN_DESTINATION} # ) ``` -------------------------------- ### Utilize PAL Timing Modules Source: https://github.com/quanser/quanser_academic_resources/blob/dev-windows/5_research/pal_utilities/timing/readMe.txt The final example demonstrates the use of two timing modules available within pal.utilities.timing. These modules provide advanced timing capabilities. ```python python 4_quanser_timing.py ``` -------------------------------- ### QCar - Synchronized Throttle/Steering and Sensor Read Source: https://context7.com/quanser/quanser_academic_resources/llms.txt This example demonstrates how to connect to a QCar (v1 or v2), send synchronized throttle and steering commands, control LEDs, and read back various sensor data including battery voltage, motor current, and IMU readings using `read_write_std()`. ```APIDOC ## QCar.read_write_std() ### Description Atomically writes throttle and steering commands to the QCar and updates internal buffers with sensor feedback such as motor status, battery voltage, and IMU data. ### Method `read_write_std(throttle, steering, LEDs)` ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body - **throttle** (float) - Required - Throttle command, a PWM fraction typically between -1.0 and 1.0, saturated by `pwmLimit`. - **steering** (float) - Required - Steering command in radians, saturated to ±0.6 rad. - **LEDs** (numpy.ndarray) - Required - An array of float values (0.0 to 1.0) to control the QCar's LEDs. The size depends on the QCar version (e.g., 8 for QCar 1). ### Request Example ```python import numpy as np from pal.products.qcar import QCar car = QCar(readMode=0, frequency=500, pwmLimit=0.3, steeringBias=0.0) try: throttle = 0.15 steering = 0.1 leds = np.zeros(8, dtype=np.float64) leds[0] = 1.0 car.read_write_std(throttle=throttle, steering=steering, LEDs=leds) finally: car.terminate() ``` ### Response #### Success Response (200) Sensor feedback is updated in the car object's attributes: - **batteryVoltage** (float) - Measured battery voltage in Volts. - **motorCurrent** (float) - Measured motor current in Amperes. - **motorEncoder** (numpy.ndarray) - Measured motor encoder counts. - **motorTach** (numpy.ndarray) - Measured motor tachometer speed in radians per second. - **accelerometer** (numpy.ndarray) - Measured acceleration from the IMU in m/s². - **gyroscope** (numpy.ndarray) - Measured angular velocity from the IMU in radians per second. #### Response Example ```python print("Battery voltage (V): ", car.batteryVoltage) print("Motor current (A): ", car.motorCurrent) print("Motor encoder counts:", car.motorEncoder) print("Motor tach (rad/s): ", car.motorTach) print("Accelerometer (m/s²):", car.accelerometer) print("Gyroscope (rad/s): ", car.gyroscope) ``` ``` -------------------------------- ### Configure MATLAB Setup Source: https://github.com/quanser/quanser_academic_resources/blob/dev-windows/docs/pc_setup.md Run 'configure_matlab.bat' to update environment variables for MATLAB. Restart your computer after running this script. ```batch configure_matlab.bat ``` -------------------------------- ### Clone Repository with Git Source: https://github.com/quanser/quanser_academic_resources/blob/dev-windows/README.md Use this command to clone the Quanser Academic Resources repository into your Documents folder using Git. Ensure Git is installed on your system. ```bash git clone https://github.com/quanser/Quanser_Academic_Resources.git Quanser ``` -------------------------------- ### Configure Python Setup Source: https://github.com/quanser/quanser_academic_resources/blob/dev-windows/docs/pc_setup.md Run 'configure_python.bat' to update environment variables for Python. Restart your computer after running this script. ```batch configure_python.bat ``` -------------------------------- ### Spawn and Animate a Virtual QArm Source: https://context7.com/quanser/quanser_academic_resources/llms.txt Spawns a QArm actor in QLabs and controls its joint configuration. Use for hardware-in-the-loop setups. ```python from qvl.qlabs import QuanserInteractiveLabs from qvl.qarm import QLabsQArm import numpy as np qlabs = QuanserInteractiveLabs() qlabs.open("localhost") q_arm = QLabsQArm(qlabs, verbose=False) # Spawn the QArm at the origin q_arm.spawn_id(actorNumber=0, location=[0, 0, 0], rotation=[0, 0, 0]) # Set joint configuration: [base, shoulder, elbow, wrist] in radians q_arm.set_joint_positions( np.array([0.3, -0.2, 0.4, 0.0]), sendMode=1 # 1 = move to target ) qlabs.close() ``` -------------------------------- ### Python Setup for Catkin Source: https://github.com/quanser/quanser_academic_resources/blob/dev-windows/5_research/sdcs/qcar/hardware/ros1_python/src/vision_opencv/image_geometry/CMakeLists.txt Enables Python support for the catkin package. This is typically used for Python-based nodes or tools within the package. ```cmake catkin_python_setup() ``` -------------------------------- ### Installing Python Scripts Source: https://github.com/quanser/quanser_academic_resources/blob/dev-windows/5_research/qarm/ROS Examples/ros1/src/qarm_action/CMakeLists.txt Marks Python scripts for installation within the ROS package. This allows scripts to be executed directly after installation. ```cmake # catkin_install_python(PROGRAMS # scripts/my_python_script # DESTINATION ${CATKIN_PACKAGE_BIN_DESTINATION} # ) ``` -------------------------------- ### Download and Enable QUARC Servers on Boot Source: https://github.com/quanser/quanser_academic_resources/blob/dev-windows/7_outreach/STEM_Interactive_Exhibit/STEM_Experience/Traffic_Lights/ReadMe.txt Use these batch scripts sequentially to download the server to the Raspberry Pi Zero and configure it to run automatically on startup. The initial time delay can be adjusted in config.txt. ```batch download_traffic_light_servers.bat ``` ```batch enable_run_on_boot.bat ``` -------------------------------- ### Install Python Scripts Source: https://github.com/quanser/quanser_academic_resources/blob/dev-windows/5_research/qarm/ROS Examples/ros1/src/qarm/CMakeLists.txt Marks Python scripts for installation into the specified destination directory. ```cmake catkin_install_python(PROGRAMS scripts/my_python_script DESTINATION ${CATKIN_PACKAGE_BIN_DESTINATION} ) ``` -------------------------------- ### Download and Enable Model on QCar Boot Source: https://github.com/quanser/quanser_academic_resources/blob/dev-windows/7_outreach/STEM_Interactive_Exhibit/STEM_Experience/Cars/ReadMe.txt These batch scripts are used sequentially to first download the model to the QCar and then configure it to run automatically upon the car's boot-up. This requires the model to be downloaded first. ```batch download_car_model.bat ``` ```batch enable_run_on_boot_car_model.bat ``` -------------------------------- ### Install Python Packages and Executables Source: https://github.com/quanser/quanser_academic_resources/blob/dev-windows/5_research/sdcs/qcar2/ros2/src/qcar2_nodes/CMakeLists.txt Installs Python packages and specific Python scripts as executables into the ROS 2 environment. ```cmake ament_python_install_package(${PROJECT_NAME}) ``` ```cmake install(PROGRAMS scripts/scan_match.py DESTINATION lib/${PROJECT_NAME} ) ``` ```cmake install(PROGRAMS scripts/ekf_fusor.py DESTINATION lib/${PROJECT_NAME} ) ``` -------------------------------- ### SSH into QBot Platform Source: https://github.com/quanser/quanser_academic_resources/blob/dev-windows/5_research/qbot_platform_alpha/IO_examples/python/io_instructions.md Connect to the QBot Platform via SSH using its IP address, username, and password. Navigate to the file directory after logging in. ```bash ssh 192.168.X.X ``` -------------------------------- ### Configure and Install Python Boost Module Source: https://github.com/quanser/quanser_academic_resources/blob/dev-windows/5_research/sdcs/qcar/hardware/ros1_python/src/vision_opencv/cv_bridge/python/CMakeLists.txt Configures and installs a Python boost module. This is typically used for Python packages that are part of a ROS package. ```cmake configure_file(__init__.py.plain.in ${CATKIN_DEVEL_PREFIX}/${CATKIN_PACKAGE_PYTHON_DESTINATION}/boost/__init__.py @ONLY ) install(FILES ${CATKIN_DEVEL_PREFIX}/${CATKIN_PACKAGE_PYTHON_DESTINATION}/boost/__init__.py DESTINATION ${CATKIN_PACKAGE_PYTHON_DESTINATION}/boost/ ) ``` -------------------------------- ### Install Configuration Directory in CMake Source: https://github.com/quanser/quanser_academic_resources/blob/dev-windows/5_research/sdcs/qcar2/ros2/src/qcar2_nodes/CMakeLists.txt Installs a directory named 'config' to the share// destination. This is typically used for configuration files needed by ROS nodes. ```cmake install(DIRECTORY config DESTINATION share/${PROJECT_NAME}/ ) ``` -------------------------------- ### QLabsQArm Source: https://context7.com/quanser/quanser_academic_resources/llms.txt Spawns a QArm actor in QLabs and controls its joint configuration. This class is useful for hardware-in-the-loop setups. ```APIDOC ## `QLabsQArm` — Spawn and Animate a Virtual QArm The `QLabsQArm` class in `qvl.qarm` spawns a QArm actor in QLabs and controls its joint configuration. It is used alongside the physical `QArm` PAL class for hardware-in-the-loop setups where the virtual environment mirrors physical hardware. ### Method Signature ```python QLabsQArm(quanser_interactive_labs_instance, verbose=False) ``` ### Spawn Method ```python q_arm.spawn_id(actorNumber, location, rotation) ``` - **actorNumber** (int): The unique identifier for the QArm actor. - **location** (list[float]): The [x, y, z] coordinates for the QArm's base. - **rotation** (list[float]): The [roll, pitch, yaw] angles in degrees for the QArm's base. ### Set Joint Positions Method ```python q_arm.set_joint_positions(joint_positions, sendMode) ``` - **joint_positions** (numpy.ndarray): An array of joint angles in radians [base, shoulder, elbow, wrist]. - **sendMode** (int): Mode for sending the command. `1` indicates moving to the target position. ``` -------------------------------- ### Launch Nav2 System Source: https://github.com/quanser/quanser_academic_resources/blob/dev-windows/5_research/isaac_sim/qbot_platform/README.md Run the specified launch file to initiate the Nav2 system for autonomous navigation. ```bash ros2 launch qbot_platform_isaac_nav2 qbot_platform_slam_and_nav_bringup_launch.py ``` -------------------------------- ### Package ROS 2 Build Information Source: https://github.com/quanser/quanser_academic_resources/blob/dev-windows/5_research/sdcs/qcar2/ros2/src/qcar2_interfaces/CMakeLists.txt Installs build information for the ROS 2 package, making it available to other packages. ```cmake ament_package() ``` -------------------------------- ### QArm: Granular I/O for Position, LED, and Readback Source: https://context7.com/quanser/quanser_academic_resources/llms.txt Provides separate methods for writing joint/gripper positions, setting the base LED color, and reading sensor feedback independently. Useful for non-atomic operations. Ensure to call `terminate()` when done. ```python import numpy as np from pal.products.qarm import QArm arm = QArm(hardware=1, readMode=0) try: # Write joints to home pose arm.write_position( phiCMD=np.array([0.0, 0.0, 0.0, 0.0], dtype=np.float64), gprCMD=np.array([0.1], dtype=np.float64) # fully open ) # Set LED to blue arm.write_led(baseLED=np.array([0, 0, 1], dtype=np.float64)) # Read all sensor feedback arm.read_std() print("PWM duty cycles:", arm.measJointPWM) finally: arm.terminate() ``` -------------------------------- ### Source ROS 2 Workspace Source: https://github.com/quanser/quanser_academic_resources/blob/dev-windows/5_research/isaac_sim/qbot_platform/README.md After compiling, source the setup.bash file to make the ROS 2 packages available in your current terminal session. ```bash source install/setup.bash ``` -------------------------------- ### Run QBot Driver Source: https://github.com/quanser/quanser_academic_resources/blob/dev-windows/5_research/qbot_platform_alpha/IO_examples/python/io_instructions.md Execute the QBot Platform driver using the quarc_run command. Successful execution is indicated by flashing white lights on the platform. ```bash sudo quarc_run -t tcpip://localhost:17000 -Q qbot_driver_v_1_22.rt-linux_pi_arm64 ``` -------------------------------- ### Finding ROS 2 Dependencies Source: https://github.com/quanser/quanser_academic_resources/blob/dev-windows/5_research/sdcs/qcar2/ros2/src/qcar2_nodes/CMakeLists.txt Finds required ROS 2 packages and their dependencies. Ensure these packages are installed in your ROS 2 environment. ```cmake find_package(ament_cmake REQUIRED) find_package(ament_cmake_python REQUIRED) find_package(cv_bridge REQUIRED) find_package(image_transport REQUIRED) find_package(OpenCV REQUIRED COMPONENTS highgui imgcodecs imgproc videoio) find_package(rclcpp REQUIRED) find_package(rclpy REQUIRED) find_package(nav_msgs REQUIRED) find_package(action_msgs REQUIRED) find_package(std_msgs REQUIRED) find_package(geometry_msgs REQUIRED) find_package(sensor_msgs REQUIRED) find_package(control_msgs REQUIRED) find_package(qcar2_interfaces REQUIRED) find_package(tf2_ros REQUIRED) ``` -------------------------------- ### Finding Required Packages Source: https://github.com/quanser/quanser_academic_resources/blob/dev-windows/5_research/sdcs/qcar/hardware/ros1_python/src/vision_opencv/image_geometry/CMakeLists.txt Locates necessary ROS packages (sensor_msgs) and external libraries (OpenCV) for the project. These packages must be installed in the ROS environment. ```cmake find_package(catkin REQUIRED sensor_msgs) find_package(OpenCV REQUIRED) ``` -------------------------------- ### Configure and Read from RGB-D Camera (Intel RealSense) Source: https://context7.com/quanser/quanser_academic_resources/llms.txt Configures an Intel RealSense or compatible RGB-D camera, streaming RGB and aligned depth frames. Camera intrinsics and extrinsics can be provided for image-to-3D projection. ```python import numpy as np import cv2 from pal.utilities.vision import Camera3D cam = Camera3D( mode='RGB&Depth', frameWidthRGB=640, frameHeightRGB=480, frameRateRGB=30.0, frameWidthDepth=640, frameHeightDepth=480, frameRateDepth=30.0, deviceId='0', readMode=1 ) try: for _ in range(30): cam.read_RGB() cam.read_depth() rgb = cam.imageBufferRGB # (480, 640, 3) uint8 depth = cam.imageBufferDepthM # (480, 640, 1) float32, meters center_dist = depth[240, 320, 0] print(f"Distance at image center: {center_dist:.3f} m") cv2.imshow("RGB", rgb) cv2.waitKey(1) finally: cam.terminate() cv2.destroyAllWindows() ``` -------------------------------- ### Add cv_bridge Library and Link Dependencies Source: https://github.com/quanser/quanser_academic_resources/blob/dev-windows/5_research/sdcs/qcar/hardware/ros1_python/src/vision_opencv/cv_bridge/src/CMakeLists.txt This snippet defines the main cv_bridge library, links against OpenCV and catkin libraries, and specifies the installation destination. ```cmake include_directories(.) add_library(${PROJECT_NAME} cv_bridge.cpp rgb_colors.cpp) add_dependencies(${PROJECT_NAME} ${catkin_EXPORTED_TARGETS}) target_link_libraries(${PROJECT_NAME} ${OpenCV_LIBRARIES} ${catkin_LIBRARIES}) install(TARGETS ${PROJECT_NAME} DESTINATION ${CATKIN_PACKAGE_LIB_DESTINATION}) ``` -------------------------------- ### Disable QUARC Server from Running on Boot Source: https://github.com/quanser/quanser_academic_resources/blob/dev-windows/7_outreach/STEM_Interactive_Exhibit/STEM_Experience/Traffic_Lights/ReadMe.txt Run this batch script to prevent the QUARC server model from starting automatically when the Raspberry Pi boots. ```batch disable_run_on_boot.bat ``` -------------------------------- ### CMakeLists.txt Configuration Source: https://github.com/quanser/quanser_academic_resources/blob/dev-windows/5_research/sdcs/qcar/hardware/ros1_python/src/vision_opencv/vision_opencv/CMakeLists.txt Standard CMakeLists.txt for a Catkin metapackage. Sets the minimum CMake version, project name, and finds the Catkin package. ```cmake cmake_minimum_required(VERSION 2.8.3) project(vision_opencv) find_package(catkin REQUIRED) catkin_metapackage() ```