├── ROSBasicsIndex.mlx ├── lib ├── RP_ROS_robot.slx ├── Resources │ ├── Winner.stl │ ├── Images │ │ ├── Lidar.png │ │ ├── lamps.png │ │ ├── Compass.png │ │ ├── MLRobot.PNG │ │ ├── RP_app.PNG │ │ ├── RP_icon.PNG │ │ ├── RedObjD.png │ │ ├── encoder.jpg │ │ ├── BlueObjD.png │ │ ├── GlobeMotor.png │ │ ├── GreenObjD.png │ │ ├── Gyroscope.png │ │ ├── ObjectEnv.PNG │ │ ├── RPROSbot.PNG │ │ ├── SumoArena.PNG │ │ ├── SumoGame.PNG │ │ ├── USVisual.PNG │ │ ├── discRobot.PNG │ │ ├── latchGraph.png │ │ ├── plowRobot.PNG │ │ ├── ClawbotIcon.png │ │ ├── KeyboardIcon.PNG │ │ ├── ObjectArena.PNG │ │ ├── ObstacleEnv.PNG │ │ ├── SwitchVisual.PNG │ │ ├── arcadeModule.png │ │ ├── sensors_lib.PNG │ │ ├── BEST2020Arena.png │ │ ├── BEST2020Cells.png │ │ ├── BEST2020Robot.png │ │ ├── BEST2021arena.png │ │ ├── BEST2021objects.png │ │ ├── CompassVisual.PNG │ │ ├── ContactSwitch.png │ │ ├── ObjectDetector.png │ │ ├── ObstacleArena.PNG │ │ ├── PlaygroundImage.PNG │ │ ├── contactDiscDisc.PNG │ │ ├── objectContact.PNG │ │ ├── obstacle-tower.png │ │ ├── obstacle-tree.png │ │ ├── wallContactDisc.PNG │ │ ├── BEST2020Vaccines.png │ │ ├── DashboardControls.PNG │ │ ├── environments_lib.PNG │ │ ├── objectWallContact.PNG │ │ ├── ultrasonic_sensor.jpg │ │ ├── BEST2020Environment.png │ │ ├── BEST2021environment.png │ │ ├── BEST2021lightpoles.png │ │ ├── Gamepad_Controller.png │ │ ├── ObjectDetectorVisual.PNG │ │ ├── advanced_sensors_lib.PNG │ │ ├── obstacle-environment.png │ │ ├── obstacleContactDisc.PNG │ │ ├── vexv5GamepadSimInput.PNG │ │ ├── vexv5GamepadSimInput2.PNG │ │ └── BESTRobotics_Usage_Logo.jpg │ ├── CFL_Libs │ │ ├── README.txt │ │ ├── Libraries │ │ │ ├── Parts_Lib.slx │ │ │ ├── Contact_Forces_Lib.slx │ │ │ ├── Images │ │ │ │ ├── BoxB_Corners_IMAGE.jpg │ │ │ │ ├── BoxF_Corners_IMAGE.jpg │ │ │ │ ├── Box_to_Belt_Ends_IMAGE.jpg │ │ │ │ ├── Box_to_Belt_Faces_IMAGE.jpg │ │ │ │ ├── Box_to_Belt_Contact_IMAGE.jpg │ │ │ │ ├── Box_to_Box_Contact_IMAGE.jpg │ │ │ │ ├── Face_to_Belt_Faces_IMAGE.jpg │ │ │ │ ├── Circle_to_Ring_Contact_IMAGE.jpg │ │ │ │ ├── Face_to_Plane_Contact_IMAGE.jpg │ │ │ │ ├── Sphere_to_Cone_Contact_IMAGE.jpg │ │ │ │ ├── Sphere_to_Tube_Contact_IMAGE.jpg │ │ │ │ ├── Circle_to_Circle_Contact_IMAGE.jpg │ │ │ │ ├── Circle_to_Hole_Attraction_IMAGE.jpg │ │ │ │ ├── Sphere_in_Sphere_Contact_IMAGE.jpg │ │ │ │ ├── Sphere_to_Plane_Contact_IMAGE.jpg │ │ │ │ ├── Sphere_to_Sphere_Contact_IMAGE.jpg │ │ │ │ ├── Circle_to_Finite_Line_Contact_IMAGE.jpg │ │ │ │ ├── Circle_to_Circle_Contact_Enabled_IMAGE.jpg │ │ │ │ ├── Sphere_to_Plane_Contact_Enabled_IMAGE.jpg │ │ │ │ └── Circle_to_Finite_Line_Contact_Enabled_IMAGE.jpg │ │ │ └── slblocks.m │ │ ├── Scripts_Data │ │ │ ├── CheckAnim.m │ │ │ ├── CFL_visual_setOnOff.m │ │ │ ├── CFL_friction_setModel.m │ │ │ └── Extrusions │ │ │ │ ├── Extr_Data_LinkHoles.m │ │ │ │ ├── Extr_Data_Box.m │ │ │ │ ├── Extr_Data_Cam_Circles.m │ │ │ │ ├── Extr_Data_Ring.m │ │ │ │ ├── Extr_Data_Frustum_Conical.m │ │ │ │ └── Extr_Data_Ellipse.m │ │ └── startup_Contact_Forces.m │ ├── RP_Simulator_Components.slx │ └── Utils │ │ ├── +bus_conv_fcns │ │ └── +ros2 │ │ │ ├── +busToMsg │ │ │ ├── RefCachedMap.mat │ │ │ └── +std_msgs │ │ │ │ └── Float64.m │ │ │ └── +msgToBus │ │ │ ├── RefCachedMap.mat │ │ │ └── +std_msgs │ │ │ └── Float64.m │ │ ├── mlrosbot_src │ │ ├── slprj │ │ │ └── sim │ │ │ │ └── varcache │ │ │ │ └── RP_ROS_robot │ │ │ │ ├── varInfo.mat │ │ │ │ ├── checksumOfCache.mat │ │ │ │ └── tmwinternal │ │ │ │ └── simulink_cache.xml │ │ ├── +bus_conv_fcns │ │ │ └── +ros2 │ │ │ │ ├── +busToMsg │ │ │ │ ├── +std_msgs │ │ │ │ │ └── Float64.m │ │ │ │ └── RefCachedMap.mat │ │ │ │ └── +msgToBus │ │ │ │ ├── RefCachedMap.mat │ │ │ │ └── +std_msgs │ │ │ │ └── Float64.m │ │ ├── mlrosbotstart.m │ │ ├── mlrosbotstop.m │ │ └── mlrosbot.m │ │ ├── RP_ROS2_srv_eStop.m │ │ ├── mlrobot_src │ │ ├── mlrobotstart.m │ │ ├── mlrobotstop.m │ │ ├── mlrobotreadcompassangle.m │ │ ├── mlrobotsetmotorvoltage.m │ │ ├── mlrobotreadwheelspeed.m │ │ └── mlrobot.m │ │ ├── disableObstacles.m │ │ ├── commentObstacles.m │ │ ├── RP_ROS2_fcn_eStop.m │ │ ├── setObjects.m │ │ ├── motorCheck.m │ │ ├── createMapFromName.m │ │ ├── PlaygroundCreateSimMap.m │ │ ├── setObstaclesUI.m │ │ ├── Extr_Data_Mesh.m │ │ ├── RPInit.m │ │ ├── LidarSensorRP.m │ │ ├── ObjectDetectorRP.m │ │ └── addSensors.m ├── RoboticsPlayground.slx └── slblocks.m ├── Lessons ├── 6_MoreROS │ ├── ROSThanks.mlx │ └── ROSMoreConcepts.mlx ├── 1_WhatWhyHowROS │ ├── HowROS.mlx │ ├── RPRobot.PNG │ ├── WhatROS.mlx │ ├── WhyROS.mlx │ ├── IntroROS.gif │ ├── RobotDevices.PNG │ └── distributed.PNG ├── 2_MessagesTopics │ ├── ExploreROS.mlx │ └── ROSMessagesTopics.mlx ├── 4_ServicesActions │ ├── ROSServices.mlx │ ├── ROSServices_Practice.mlx │ └── ROSServices_Practice_Solution.mlx ├── 5_ROSSimulink │ ├── RP_ROS_Simulink.slx │ └── RP_ROS_Stateflow.slx └── 3_PublishersSubscribers │ ├── ROSPublishers.mlx │ ├── ROSSubscribers.mlx │ ├── ROSMaze_Project1.mlx │ ├── ROSPublishers_practice.mlx │ ├── ROSPublishers_solution.mlx │ ├── ROSSubscribers_practice.mlx │ ├── ROSSubscribers_solution.mlx │ └── ROSMaze_Project1_Solution.mlx ├── SECURITY.md ├── license.txt └── README.md /ROSBasicsIndex.mlx: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mathworks-robotics/matlab-and-simulink-ros-tutorials/HEAD/ROSBasicsIndex.mlx -------------------------------------------------------------------------------- /lib/RP_ROS_robot.slx: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mathworks-robotics/matlab-and-simulink-ros-tutorials/HEAD/lib/RP_ROS_robot.slx -------------------------------------------------------------------------------- /lib/Resources/Winner.stl: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mathworks-robotics/matlab-and-simulink-ros-tutorials/HEAD/lib/Resources/Winner.stl -------------------------------------------------------------------------------- /lib/RoboticsPlayground.slx: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mathworks-robotics/matlab-and-simulink-ros-tutorials/HEAD/lib/RoboticsPlayground.slx -------------------------------------------------------------------------------- /lib/Resources/Images/Lidar.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mathworks-robotics/matlab-and-simulink-ros-tutorials/HEAD/lib/Resources/Images/Lidar.png -------------------------------------------------------------------------------- /lib/Resources/Images/lamps.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mathworks-robotics/matlab-and-simulink-ros-tutorials/HEAD/lib/Resources/Images/lamps.png -------------------------------------------------------------------------------- /Lessons/6_MoreROS/ROSThanks.mlx: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mathworks-robotics/matlab-and-simulink-ros-tutorials/HEAD/Lessons/6_MoreROS/ROSThanks.mlx -------------------------------------------------------------------------------- /lib/Resources/Images/Compass.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mathworks-robotics/matlab-and-simulink-ros-tutorials/HEAD/lib/Resources/Images/Compass.png -------------------------------------------------------------------------------- /lib/Resources/Images/MLRobot.PNG: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mathworks-robotics/matlab-and-simulink-ros-tutorials/HEAD/lib/Resources/Images/MLRobot.PNG -------------------------------------------------------------------------------- /lib/Resources/Images/RP_app.PNG: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mathworks-robotics/matlab-and-simulink-ros-tutorials/HEAD/lib/Resources/Images/RP_app.PNG -------------------------------------------------------------------------------- /lib/Resources/Images/RP_icon.PNG: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mathworks-robotics/matlab-and-simulink-ros-tutorials/HEAD/lib/Resources/Images/RP_icon.PNG -------------------------------------------------------------------------------- /lib/Resources/Images/RedObjD.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mathworks-robotics/matlab-and-simulink-ros-tutorials/HEAD/lib/Resources/Images/RedObjD.png -------------------------------------------------------------------------------- /lib/Resources/Images/encoder.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mathworks-robotics/matlab-and-simulink-ros-tutorials/HEAD/lib/Resources/Images/encoder.jpg -------------------------------------------------------------------------------- /Lessons/1_WhatWhyHowROS/HowROS.mlx: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mathworks-robotics/matlab-and-simulink-ros-tutorials/HEAD/Lessons/1_WhatWhyHowROS/HowROS.mlx -------------------------------------------------------------------------------- /Lessons/1_WhatWhyHowROS/RPRobot.PNG: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mathworks-robotics/matlab-and-simulink-ros-tutorials/HEAD/Lessons/1_WhatWhyHowROS/RPRobot.PNG -------------------------------------------------------------------------------- /Lessons/1_WhatWhyHowROS/WhatROS.mlx: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mathworks-robotics/matlab-and-simulink-ros-tutorials/HEAD/Lessons/1_WhatWhyHowROS/WhatROS.mlx -------------------------------------------------------------------------------- /Lessons/1_WhatWhyHowROS/WhyROS.mlx: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mathworks-robotics/matlab-and-simulink-ros-tutorials/HEAD/Lessons/1_WhatWhyHowROS/WhyROS.mlx -------------------------------------------------------------------------------- /lib/Resources/CFL_Libs/README.txt: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mathworks-robotics/matlab-and-simulink-ros-tutorials/HEAD/lib/Resources/CFL_Libs/README.txt -------------------------------------------------------------------------------- /lib/Resources/Images/BlueObjD.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mathworks-robotics/matlab-and-simulink-ros-tutorials/HEAD/lib/Resources/Images/BlueObjD.png -------------------------------------------------------------------------------- /lib/Resources/Images/GlobeMotor.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mathworks-robotics/matlab-and-simulink-ros-tutorials/HEAD/lib/Resources/Images/GlobeMotor.png -------------------------------------------------------------------------------- /lib/Resources/Images/GreenObjD.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mathworks-robotics/matlab-and-simulink-ros-tutorials/HEAD/lib/Resources/Images/GreenObjD.png -------------------------------------------------------------------------------- /lib/Resources/Images/Gyroscope.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mathworks-robotics/matlab-and-simulink-ros-tutorials/HEAD/lib/Resources/Images/Gyroscope.png -------------------------------------------------------------------------------- /lib/Resources/Images/ObjectEnv.PNG: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mathworks-robotics/matlab-and-simulink-ros-tutorials/HEAD/lib/Resources/Images/ObjectEnv.PNG -------------------------------------------------------------------------------- /lib/Resources/Images/RPROSbot.PNG: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mathworks-robotics/matlab-and-simulink-ros-tutorials/HEAD/lib/Resources/Images/RPROSbot.PNG -------------------------------------------------------------------------------- /lib/Resources/Images/SumoArena.PNG: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mathworks-robotics/matlab-and-simulink-ros-tutorials/HEAD/lib/Resources/Images/SumoArena.PNG -------------------------------------------------------------------------------- /lib/Resources/Images/SumoGame.PNG: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mathworks-robotics/matlab-and-simulink-ros-tutorials/HEAD/lib/Resources/Images/SumoGame.PNG -------------------------------------------------------------------------------- /lib/Resources/Images/USVisual.PNG: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mathworks-robotics/matlab-and-simulink-ros-tutorials/HEAD/lib/Resources/Images/USVisual.PNG -------------------------------------------------------------------------------- /lib/Resources/Images/discRobot.PNG: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mathworks-robotics/matlab-and-simulink-ros-tutorials/HEAD/lib/Resources/Images/discRobot.PNG -------------------------------------------------------------------------------- /lib/Resources/Images/latchGraph.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mathworks-robotics/matlab-and-simulink-ros-tutorials/HEAD/lib/Resources/Images/latchGraph.png -------------------------------------------------------------------------------- /lib/Resources/Images/plowRobot.PNG: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mathworks-robotics/matlab-and-simulink-ros-tutorials/HEAD/lib/Resources/Images/plowRobot.PNG -------------------------------------------------------------------------------- /Lessons/1_WhatWhyHowROS/IntroROS.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mathworks-robotics/matlab-and-simulink-ros-tutorials/HEAD/Lessons/1_WhatWhyHowROS/IntroROS.gif -------------------------------------------------------------------------------- /Lessons/6_MoreROS/ROSMoreConcepts.mlx: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mathworks-robotics/matlab-and-simulink-ros-tutorials/HEAD/Lessons/6_MoreROS/ROSMoreConcepts.mlx -------------------------------------------------------------------------------- /lib/Resources/Images/ClawbotIcon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mathworks-robotics/matlab-and-simulink-ros-tutorials/HEAD/lib/Resources/Images/ClawbotIcon.png -------------------------------------------------------------------------------- /lib/Resources/Images/KeyboardIcon.PNG: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mathworks-robotics/matlab-and-simulink-ros-tutorials/HEAD/lib/Resources/Images/KeyboardIcon.PNG -------------------------------------------------------------------------------- /lib/Resources/Images/ObjectArena.PNG: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mathworks-robotics/matlab-and-simulink-ros-tutorials/HEAD/lib/Resources/Images/ObjectArena.PNG -------------------------------------------------------------------------------- /lib/Resources/Images/ObstacleEnv.PNG: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mathworks-robotics/matlab-and-simulink-ros-tutorials/HEAD/lib/Resources/Images/ObstacleEnv.PNG -------------------------------------------------------------------------------- /lib/Resources/Images/SwitchVisual.PNG: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mathworks-robotics/matlab-and-simulink-ros-tutorials/HEAD/lib/Resources/Images/SwitchVisual.PNG -------------------------------------------------------------------------------- /lib/Resources/Images/arcadeModule.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mathworks-robotics/matlab-and-simulink-ros-tutorials/HEAD/lib/Resources/Images/arcadeModule.png -------------------------------------------------------------------------------- /lib/Resources/Images/sensors_lib.PNG: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mathworks-robotics/matlab-and-simulink-ros-tutorials/HEAD/lib/Resources/Images/sensors_lib.PNG -------------------------------------------------------------------------------- /Lessons/1_WhatWhyHowROS/RobotDevices.PNG: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mathworks-robotics/matlab-and-simulink-ros-tutorials/HEAD/Lessons/1_WhatWhyHowROS/RobotDevices.PNG -------------------------------------------------------------------------------- /Lessons/1_WhatWhyHowROS/distributed.PNG: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mathworks-robotics/matlab-and-simulink-ros-tutorials/HEAD/Lessons/1_WhatWhyHowROS/distributed.PNG -------------------------------------------------------------------------------- /Lessons/2_MessagesTopics/ExploreROS.mlx: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mathworks-robotics/matlab-and-simulink-ros-tutorials/HEAD/Lessons/2_MessagesTopics/ExploreROS.mlx -------------------------------------------------------------------------------- /lib/Resources/Images/BEST2020Arena.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mathworks-robotics/matlab-and-simulink-ros-tutorials/HEAD/lib/Resources/Images/BEST2020Arena.png -------------------------------------------------------------------------------- /lib/Resources/Images/BEST2020Cells.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mathworks-robotics/matlab-and-simulink-ros-tutorials/HEAD/lib/Resources/Images/BEST2020Cells.png -------------------------------------------------------------------------------- /lib/Resources/Images/BEST2020Robot.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mathworks-robotics/matlab-and-simulink-ros-tutorials/HEAD/lib/Resources/Images/BEST2020Robot.png -------------------------------------------------------------------------------- /lib/Resources/Images/BEST2021arena.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mathworks-robotics/matlab-and-simulink-ros-tutorials/HEAD/lib/Resources/Images/BEST2021arena.png -------------------------------------------------------------------------------- /lib/Resources/Images/BEST2021objects.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mathworks-robotics/matlab-and-simulink-ros-tutorials/HEAD/lib/Resources/Images/BEST2021objects.png -------------------------------------------------------------------------------- /lib/Resources/Images/CompassVisual.PNG: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mathworks-robotics/matlab-and-simulink-ros-tutorials/HEAD/lib/Resources/Images/CompassVisual.PNG -------------------------------------------------------------------------------- /lib/Resources/Images/ContactSwitch.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mathworks-robotics/matlab-and-simulink-ros-tutorials/HEAD/lib/Resources/Images/ContactSwitch.png -------------------------------------------------------------------------------- /lib/Resources/Images/ObjectDetector.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mathworks-robotics/matlab-and-simulink-ros-tutorials/HEAD/lib/Resources/Images/ObjectDetector.png -------------------------------------------------------------------------------- /lib/Resources/Images/ObstacleArena.PNG: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mathworks-robotics/matlab-and-simulink-ros-tutorials/HEAD/lib/Resources/Images/ObstacleArena.PNG -------------------------------------------------------------------------------- /lib/Resources/Images/PlaygroundImage.PNG: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mathworks-robotics/matlab-and-simulink-ros-tutorials/HEAD/lib/Resources/Images/PlaygroundImage.PNG -------------------------------------------------------------------------------- /lib/Resources/Images/contactDiscDisc.PNG: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mathworks-robotics/matlab-and-simulink-ros-tutorials/HEAD/lib/Resources/Images/contactDiscDisc.PNG -------------------------------------------------------------------------------- /lib/Resources/Images/objectContact.PNG: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mathworks-robotics/matlab-and-simulink-ros-tutorials/HEAD/lib/Resources/Images/objectContact.PNG -------------------------------------------------------------------------------- /lib/Resources/Images/obstacle-tower.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mathworks-robotics/matlab-and-simulink-ros-tutorials/HEAD/lib/Resources/Images/obstacle-tower.png -------------------------------------------------------------------------------- /lib/Resources/Images/obstacle-tree.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mathworks-robotics/matlab-and-simulink-ros-tutorials/HEAD/lib/Resources/Images/obstacle-tree.png -------------------------------------------------------------------------------- /lib/Resources/Images/wallContactDisc.PNG: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mathworks-robotics/matlab-and-simulink-ros-tutorials/HEAD/lib/Resources/Images/wallContactDisc.PNG -------------------------------------------------------------------------------- /Lessons/4_ServicesActions/ROSServices.mlx: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mathworks-robotics/matlab-and-simulink-ros-tutorials/HEAD/Lessons/4_ServicesActions/ROSServices.mlx -------------------------------------------------------------------------------- /Lessons/5_ROSSimulink/RP_ROS_Simulink.slx: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mathworks-robotics/matlab-and-simulink-ros-tutorials/HEAD/Lessons/5_ROSSimulink/RP_ROS_Simulink.slx -------------------------------------------------------------------------------- /Lessons/5_ROSSimulink/RP_ROS_Stateflow.slx: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mathworks-robotics/matlab-and-simulink-ros-tutorials/HEAD/Lessons/5_ROSSimulink/RP_ROS_Stateflow.slx -------------------------------------------------------------------------------- /lib/Resources/Images/BEST2020Vaccines.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mathworks-robotics/matlab-and-simulink-ros-tutorials/HEAD/lib/Resources/Images/BEST2020Vaccines.png -------------------------------------------------------------------------------- /lib/Resources/Images/DashboardControls.PNG: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mathworks-robotics/matlab-and-simulink-ros-tutorials/HEAD/lib/Resources/Images/DashboardControls.PNG -------------------------------------------------------------------------------- /lib/Resources/Images/environments_lib.PNG: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mathworks-robotics/matlab-and-simulink-ros-tutorials/HEAD/lib/Resources/Images/environments_lib.PNG -------------------------------------------------------------------------------- /lib/Resources/Images/objectWallContact.PNG: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mathworks-robotics/matlab-and-simulink-ros-tutorials/HEAD/lib/Resources/Images/objectWallContact.PNG -------------------------------------------------------------------------------- /lib/Resources/Images/ultrasonic_sensor.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mathworks-robotics/matlab-and-simulink-ros-tutorials/HEAD/lib/Resources/Images/ultrasonic_sensor.jpg -------------------------------------------------------------------------------- /lib/Resources/RP_Simulator_Components.slx: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mathworks-robotics/matlab-and-simulink-ros-tutorials/HEAD/lib/Resources/RP_Simulator_Components.slx -------------------------------------------------------------------------------- /lib/Resources/Images/BEST2020Environment.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mathworks-robotics/matlab-and-simulink-ros-tutorials/HEAD/lib/Resources/Images/BEST2020Environment.png -------------------------------------------------------------------------------- /lib/Resources/Images/BEST2021environment.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mathworks-robotics/matlab-and-simulink-ros-tutorials/HEAD/lib/Resources/Images/BEST2021environment.png -------------------------------------------------------------------------------- /lib/Resources/Images/BEST2021lightpoles.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mathworks-robotics/matlab-and-simulink-ros-tutorials/HEAD/lib/Resources/Images/BEST2021lightpoles.png -------------------------------------------------------------------------------- /lib/Resources/Images/Gamepad_Controller.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mathworks-robotics/matlab-and-simulink-ros-tutorials/HEAD/lib/Resources/Images/Gamepad_Controller.png -------------------------------------------------------------------------------- /lib/Resources/Images/ObjectDetectorVisual.PNG: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mathworks-robotics/matlab-and-simulink-ros-tutorials/HEAD/lib/Resources/Images/ObjectDetectorVisual.PNG -------------------------------------------------------------------------------- /lib/Resources/Images/advanced_sensors_lib.PNG: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mathworks-robotics/matlab-and-simulink-ros-tutorials/HEAD/lib/Resources/Images/advanced_sensors_lib.PNG -------------------------------------------------------------------------------- /lib/Resources/Images/obstacle-environment.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mathworks-robotics/matlab-and-simulink-ros-tutorials/HEAD/lib/Resources/Images/obstacle-environment.png -------------------------------------------------------------------------------- /lib/Resources/Images/obstacleContactDisc.PNG: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mathworks-robotics/matlab-and-simulink-ros-tutorials/HEAD/lib/Resources/Images/obstacleContactDisc.PNG -------------------------------------------------------------------------------- /lib/Resources/Images/vexv5GamepadSimInput.PNG: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mathworks-robotics/matlab-and-simulink-ros-tutorials/HEAD/lib/Resources/Images/vexv5GamepadSimInput.PNG -------------------------------------------------------------------------------- /Lessons/2_MessagesTopics/ROSMessagesTopics.mlx: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mathworks-robotics/matlab-and-simulink-ros-tutorials/HEAD/Lessons/2_MessagesTopics/ROSMessagesTopics.mlx -------------------------------------------------------------------------------- /lib/Resources/CFL_Libs/Libraries/Parts_Lib.slx: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mathworks-robotics/matlab-and-simulink-ros-tutorials/HEAD/lib/Resources/CFL_Libs/Libraries/Parts_Lib.slx -------------------------------------------------------------------------------- /lib/Resources/Images/vexv5GamepadSimInput2.PNG: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mathworks-robotics/matlab-and-simulink-ros-tutorials/HEAD/lib/Resources/Images/vexv5GamepadSimInput2.PNG -------------------------------------------------------------------------------- /Lessons/3_PublishersSubscribers/ROSPublishers.mlx: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mathworks-robotics/matlab-and-simulink-ros-tutorials/HEAD/Lessons/3_PublishersSubscribers/ROSPublishers.mlx -------------------------------------------------------------------------------- /Lessons/3_PublishersSubscribers/ROSSubscribers.mlx: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mathworks-robotics/matlab-and-simulink-ros-tutorials/HEAD/Lessons/3_PublishersSubscribers/ROSSubscribers.mlx -------------------------------------------------------------------------------- /Lessons/4_ServicesActions/ROSServices_Practice.mlx: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mathworks-robotics/matlab-and-simulink-ros-tutorials/HEAD/Lessons/4_ServicesActions/ROSServices_Practice.mlx -------------------------------------------------------------------------------- /lib/Resources/Images/BESTRobotics_Usage_Logo.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mathworks-robotics/matlab-and-simulink-ros-tutorials/HEAD/lib/Resources/Images/BESTRobotics_Usage_Logo.jpg -------------------------------------------------------------------------------- /Lessons/3_PublishersSubscribers/ROSMaze_Project1.mlx: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mathworks-robotics/matlab-and-simulink-ros-tutorials/HEAD/Lessons/3_PublishersSubscribers/ROSMaze_Project1.mlx -------------------------------------------------------------------------------- /lib/Resources/CFL_Libs/Libraries/Contact_Forces_Lib.slx: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mathworks-robotics/matlab-and-simulink-ros-tutorials/HEAD/lib/Resources/CFL_Libs/Libraries/Contact_Forces_Lib.slx -------------------------------------------------------------------------------- /Lessons/3_PublishersSubscribers/ROSPublishers_practice.mlx: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mathworks-robotics/matlab-and-simulink-ros-tutorials/HEAD/Lessons/3_PublishersSubscribers/ROSPublishers_practice.mlx -------------------------------------------------------------------------------- /Lessons/3_PublishersSubscribers/ROSPublishers_solution.mlx: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mathworks-robotics/matlab-and-simulink-ros-tutorials/HEAD/Lessons/3_PublishersSubscribers/ROSPublishers_solution.mlx -------------------------------------------------------------------------------- /Lessons/3_PublishersSubscribers/ROSSubscribers_practice.mlx: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mathworks-robotics/matlab-and-simulink-ros-tutorials/HEAD/Lessons/3_PublishersSubscribers/ROSSubscribers_practice.mlx -------------------------------------------------------------------------------- /Lessons/3_PublishersSubscribers/ROSSubscribers_solution.mlx: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mathworks-robotics/matlab-and-simulink-ros-tutorials/HEAD/Lessons/3_PublishersSubscribers/ROSSubscribers_solution.mlx -------------------------------------------------------------------------------- /Lessons/4_ServicesActions/ROSServices_Practice_Solution.mlx: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mathworks-robotics/matlab-and-simulink-ros-tutorials/HEAD/Lessons/4_ServicesActions/ROSServices_Practice_Solution.mlx -------------------------------------------------------------------------------- /Lessons/3_PublishersSubscribers/ROSMaze_Project1_Solution.mlx: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mathworks-robotics/matlab-and-simulink-ros-tutorials/HEAD/Lessons/3_PublishersSubscribers/ROSMaze_Project1_Solution.mlx -------------------------------------------------------------------------------- /lib/Resources/CFL_Libs/Libraries/Images/BoxB_Corners_IMAGE.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mathworks-robotics/matlab-and-simulink-ros-tutorials/HEAD/lib/Resources/CFL_Libs/Libraries/Images/BoxB_Corners_IMAGE.jpg -------------------------------------------------------------------------------- /lib/Resources/CFL_Libs/Libraries/Images/BoxF_Corners_IMAGE.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mathworks-robotics/matlab-and-simulink-ros-tutorials/HEAD/lib/Resources/CFL_Libs/Libraries/Images/BoxF_Corners_IMAGE.jpg -------------------------------------------------------------------------------- /lib/Resources/CFL_Libs/Libraries/Images/Box_to_Belt_Ends_IMAGE.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mathworks-robotics/matlab-and-simulink-ros-tutorials/HEAD/lib/Resources/CFL_Libs/Libraries/Images/Box_to_Belt_Ends_IMAGE.jpg -------------------------------------------------------------------------------- /lib/Resources/CFL_Libs/Libraries/Images/Box_to_Belt_Faces_IMAGE.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mathworks-robotics/matlab-and-simulink-ros-tutorials/HEAD/lib/Resources/CFL_Libs/Libraries/Images/Box_to_Belt_Faces_IMAGE.jpg -------------------------------------------------------------------------------- /lib/Resources/Utils/+bus_conv_fcns/+ros2/+busToMsg/RefCachedMap.mat: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mathworks-robotics/matlab-and-simulink-ros-tutorials/HEAD/lib/Resources/Utils/+bus_conv_fcns/+ros2/+busToMsg/RefCachedMap.mat -------------------------------------------------------------------------------- /lib/Resources/Utils/+bus_conv_fcns/+ros2/+msgToBus/RefCachedMap.mat: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mathworks-robotics/matlab-and-simulink-ros-tutorials/HEAD/lib/Resources/Utils/+bus_conv_fcns/+ros2/+msgToBus/RefCachedMap.mat -------------------------------------------------------------------------------- /lib/Resources/CFL_Libs/Libraries/Images/Box_to_Belt_Contact_IMAGE.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mathworks-robotics/matlab-and-simulink-ros-tutorials/HEAD/lib/Resources/CFL_Libs/Libraries/Images/Box_to_Belt_Contact_IMAGE.jpg -------------------------------------------------------------------------------- /lib/Resources/CFL_Libs/Libraries/Images/Box_to_Box_Contact_IMAGE.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mathworks-robotics/matlab-and-simulink-ros-tutorials/HEAD/lib/Resources/CFL_Libs/Libraries/Images/Box_to_Box_Contact_IMAGE.jpg -------------------------------------------------------------------------------- /lib/Resources/CFL_Libs/Libraries/Images/Face_to_Belt_Faces_IMAGE.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mathworks-robotics/matlab-and-simulink-ros-tutorials/HEAD/lib/Resources/CFL_Libs/Libraries/Images/Face_to_Belt_Faces_IMAGE.jpg -------------------------------------------------------------------------------- /lib/Resources/CFL_Libs/Libraries/Images/Circle_to_Ring_Contact_IMAGE.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mathworks-robotics/matlab-and-simulink-ros-tutorials/HEAD/lib/Resources/CFL_Libs/Libraries/Images/Circle_to_Ring_Contact_IMAGE.jpg -------------------------------------------------------------------------------- /lib/Resources/CFL_Libs/Libraries/Images/Face_to_Plane_Contact_IMAGE.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mathworks-robotics/matlab-and-simulink-ros-tutorials/HEAD/lib/Resources/CFL_Libs/Libraries/Images/Face_to_Plane_Contact_IMAGE.jpg -------------------------------------------------------------------------------- /lib/Resources/CFL_Libs/Libraries/Images/Sphere_to_Cone_Contact_IMAGE.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mathworks-robotics/matlab-and-simulink-ros-tutorials/HEAD/lib/Resources/CFL_Libs/Libraries/Images/Sphere_to_Cone_Contact_IMAGE.jpg -------------------------------------------------------------------------------- /lib/Resources/CFL_Libs/Libraries/Images/Sphere_to_Tube_Contact_IMAGE.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mathworks-robotics/matlab-and-simulink-ros-tutorials/HEAD/lib/Resources/CFL_Libs/Libraries/Images/Sphere_to_Tube_Contact_IMAGE.jpg -------------------------------------------------------------------------------- /lib/Resources/CFL_Libs/Libraries/Images/Circle_to_Circle_Contact_IMAGE.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mathworks-robotics/matlab-and-simulink-ros-tutorials/HEAD/lib/Resources/CFL_Libs/Libraries/Images/Circle_to_Circle_Contact_IMAGE.jpg -------------------------------------------------------------------------------- /lib/Resources/CFL_Libs/Libraries/Images/Circle_to_Hole_Attraction_IMAGE.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mathworks-robotics/matlab-and-simulink-ros-tutorials/HEAD/lib/Resources/CFL_Libs/Libraries/Images/Circle_to_Hole_Attraction_IMAGE.jpg -------------------------------------------------------------------------------- /lib/Resources/CFL_Libs/Libraries/Images/Sphere_in_Sphere_Contact_IMAGE.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mathworks-robotics/matlab-and-simulink-ros-tutorials/HEAD/lib/Resources/CFL_Libs/Libraries/Images/Sphere_in_Sphere_Contact_IMAGE.jpg -------------------------------------------------------------------------------- /lib/Resources/CFL_Libs/Libraries/Images/Sphere_to_Plane_Contact_IMAGE.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mathworks-robotics/matlab-and-simulink-ros-tutorials/HEAD/lib/Resources/CFL_Libs/Libraries/Images/Sphere_to_Plane_Contact_IMAGE.jpg -------------------------------------------------------------------------------- /lib/Resources/CFL_Libs/Libraries/Images/Sphere_to_Sphere_Contact_IMAGE.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mathworks-robotics/matlab-and-simulink-ros-tutorials/HEAD/lib/Resources/CFL_Libs/Libraries/Images/Sphere_to_Sphere_Contact_IMAGE.jpg -------------------------------------------------------------------------------- /lib/Resources/Utils/+bus_conv_fcns/+ros2/+busToMsg/+std_msgs/Float64.m: -------------------------------------------------------------------------------- 1 | function rosmsgOut = Float64(slBusIn, rosmsgOut) 2 | %#codegen 3 | % Copyright 2021 The MathWorks, Inc. 4 | rosmsgOut.data = double(slBusIn.data); 5 | end 6 | -------------------------------------------------------------------------------- /lib/Resources/Utils/+bus_conv_fcns/+ros2/+msgToBus/+std_msgs/Float64.m: -------------------------------------------------------------------------------- 1 | function slBusOut = Float64(msgIn, slBusOut, varargin) 2 | %#codegen 3 | % Copyright 2021 The MathWorks, Inc. 4 | slBusOut.data = double(msgIn.data); 5 | end 6 | -------------------------------------------------------------------------------- /lib/Resources/Utils/mlrosbot_src/slprj/sim/varcache/RP_ROS_robot/varInfo.mat: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mathworks-robotics/matlab-and-simulink-ros-tutorials/HEAD/lib/Resources/Utils/mlrosbot_src/slprj/sim/varcache/RP_ROS_robot/varInfo.mat -------------------------------------------------------------------------------- /lib/Resources/CFL_Libs/Libraries/Images/Circle_to_Finite_Line_Contact_IMAGE.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mathworks-robotics/matlab-and-simulink-ros-tutorials/HEAD/lib/Resources/CFL_Libs/Libraries/Images/Circle_to_Finite_Line_Contact_IMAGE.jpg -------------------------------------------------------------------------------- /lib/Resources/Utils/mlrosbot_src/+bus_conv_fcns/+ros2/+busToMsg/+std_msgs/Float64.m: -------------------------------------------------------------------------------- 1 | function rosmsgOut = Float64(slBusIn, rosmsgOut) 2 | %#codegen 3 | % Copyright 2021 The MathWorks, Inc. 4 | rosmsgOut.data = double(slBusIn.data); 5 | end 6 | -------------------------------------------------------------------------------- /lib/Resources/Utils/mlrosbot_src/+bus_conv_fcns/+ros2/+busToMsg/RefCachedMap.mat: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mathworks-robotics/matlab-and-simulink-ros-tutorials/HEAD/lib/Resources/Utils/mlrosbot_src/+bus_conv_fcns/+ros2/+busToMsg/RefCachedMap.mat -------------------------------------------------------------------------------- /lib/Resources/Utils/mlrosbot_src/+bus_conv_fcns/+ros2/+msgToBus/RefCachedMap.mat: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mathworks-robotics/matlab-and-simulink-ros-tutorials/HEAD/lib/Resources/Utils/mlrosbot_src/+bus_conv_fcns/+ros2/+msgToBus/RefCachedMap.mat -------------------------------------------------------------------------------- /lib/Resources/CFL_Libs/Libraries/Images/Circle_to_Circle_Contact_Enabled_IMAGE.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mathworks-robotics/matlab-and-simulink-ros-tutorials/HEAD/lib/Resources/CFL_Libs/Libraries/Images/Circle_to_Circle_Contact_Enabled_IMAGE.jpg -------------------------------------------------------------------------------- /lib/Resources/CFL_Libs/Libraries/Images/Sphere_to_Plane_Contact_Enabled_IMAGE.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mathworks-robotics/matlab-and-simulink-ros-tutorials/HEAD/lib/Resources/CFL_Libs/Libraries/Images/Sphere_to_Plane_Contact_Enabled_IMAGE.jpg -------------------------------------------------------------------------------- /lib/Resources/Utils/mlrosbot_src/+bus_conv_fcns/+ros2/+msgToBus/+std_msgs/Float64.m: -------------------------------------------------------------------------------- 1 | function slBusOut = Float64(msgIn, slBusOut, varargin) 2 | %#codegen 3 | % Copyright 2021 The MathWorks, Inc. 4 | slBusOut.data = double(msgIn.data); 5 | end 6 | -------------------------------------------------------------------------------- /lib/Resources/Utils/mlrosbot_src/slprj/sim/varcache/RP_ROS_robot/checksumOfCache.mat: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mathworks-robotics/matlab-and-simulink-ros-tutorials/HEAD/lib/Resources/Utils/mlrosbot_src/slprj/sim/varcache/RP_ROS_robot/checksumOfCache.mat -------------------------------------------------------------------------------- /lib/Resources/CFL_Libs/Libraries/Images/Circle_to_Finite_Line_Contact_Enabled_IMAGE.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mathworks-robotics/matlab-and-simulink-ros-tutorials/HEAD/lib/Resources/CFL_Libs/Libraries/Images/Circle_to_Finite_Line_Contact_Enabled_IMAGE.jpg -------------------------------------------------------------------------------- /lib/slblocks.m: -------------------------------------------------------------------------------- 1 | function blkStruct = slblocks 2 | % This function specifies that the library should appear 3 | % in the Library Browser 4 | % and be cached in the browser repository 5 | 6 | Browser.Library = 'RoboticsPlayground'; 7 | Browser.Name = 'Robotics Playground'; 8 | 9 | blkStruct.Browser = Browser; -------------------------------------------------------------------------------- /lib/Resources/Utils/RP_ROS2_srv_eStop.m: -------------------------------------------------------------------------------- 1 | %% ROS2™ Navigate Maze Callback 2 | % This function is used as a callback for the /navigateMaze ROS2 service 3 | % part of the ROS2 basics examples of the Robotics Playground 4 | 5 | srv_node=ros2node("/RP_emergencyStop"); 6 | 7 | server = ros2svcserver(srv_node,'/RP_emergencyStop','test_msgs/BasicTypes',{@RP_ROS2_fcn_eStop, 'RP_ROS_robot'}); 8 | 9 | 10 | -------------------------------------------------------------------------------- /SECURITY.md: -------------------------------------------------------------------------------- 1 | # Reporting Security Vulnerabilities 2 | 3 | If you believe you have discovered a security vulnerability, please report it to 4 | [security@mathworks.com](mailto:security@mathworks.com). Please see 5 | [MathWorks Vulnerability Disclosure Policy for Security Researchers](https://www.mathworks.com/company/aboutus/policies_statements/vulnerability-disclosure-policy.html) 6 | for additional information. -------------------------------------------------------------------------------- /lib/Resources/Utils/mlrobot_src/mlrobotstart.m: -------------------------------------------------------------------------------- 1 | function mlrobotstart(mlrobot) 2 | %MLROBOTSTART This function starts running the virtual environment for an 3 | % MLROBOT object 4 | % 5 | % Example: 6 | % 7 | % myRobot = mlrobot; 8 | % mlrobotstart(myRobot); 9 | % 10 | % See also MLROBOT 11 | % 12 | % Copyright 2018 The MathWorks, Inc. 13 | 14 | mlrobot.connect; 15 | 16 | end 17 | 18 | -------------------------------------------------------------------------------- /lib/Resources/Utils/mlrosbot_src/mlrosbotstart.m: -------------------------------------------------------------------------------- 1 | function mlrosbotstart(mlrosbot) 2 | %MLROBOTSTART This function starts running the virtual environment for an 3 | % MLROBOT object 4 | % 5 | % Example: 6 | % 7 | % myRobot = mlrobot; 8 | % mlrobotstart(myRobot); 9 | % 10 | % See also MLROBOT 11 | % 12 | % Copyright 2018 The MathWorks, Inc. 13 | 14 | mlrosbot.connect; 15 | 16 | end 17 | 18 | -------------------------------------------------------------------------------- /lib/Resources/Utils/mlrobot_src/mlrobotstop.m: -------------------------------------------------------------------------------- 1 | function mlrobotstop(mlrobot) 2 | %MLROBOTSTOP This function stops running the virtual environment for a 3 | % MLROBOT robot. 4 | % 5 | % Example: 6 | % 7 | % myRobot = mlrobot; 8 | % mlrobotstart(myRobot); 9 | % mlrobotstop(myRobot); 10 | % 11 | % See also MLROBOT MLROBOTSTART 12 | % 13 | % Copyright 2018 The MathWorks, Inc. 14 | 15 | mlrobot.disconnect; 16 | 17 | end 18 | -------------------------------------------------------------------------------- /lib/Resources/Utils/mlrosbot_src/mlrosbotstop.m: -------------------------------------------------------------------------------- 1 | function mlrosbotstop(mlrosbot) 2 | %MLROBOTSTOP This function stops running the virtual environment for a 3 | % MLROBOT robot. 4 | % 5 | % Example: 6 | % 7 | % myRobot = mlrobot; 8 | % mlrobotstart(myRobot); 9 | % mlrobotstop(myRobot); 10 | % 11 | % See also MLROBOT MLROBOTSTART 12 | % 13 | % Copyright 2018 The MathWorks, Inc. 14 | 15 | mlrosbot.disconnect; 16 | 17 | end 18 | -------------------------------------------------------------------------------- /lib/Resources/Utils/disableObstacles.m: -------------------------------------------------------------------------------- 1 | function disableObstacles(blk) 2 | % This function goes through the objects in and obstacle environment and disables all the obstacles 3 | % It is implemented as a button in the environment mask 4 | % Copyright 2018 The MathWorks, Inc. 5 | 6 | 7 | for idx=1:10 8 | set_param(blk,['obs' num2str(idx)],'off') 9 | set_param([blk '/Obstacles/Obstacle' num2str(idx)],'Commented','on'); 10 | end 11 | 12 | 13 | end 14 | -------------------------------------------------------------------------------- /lib/Resources/Utils/mlrosbot_src/slprj/sim/varcache/RP_ROS_robot/tmwinternal/simulink_cache.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | JPmGpEsTWOIAVpCVg4BVU6R56SjYq/MVyT0CqRv3FTbNduOBFvmTunrsExvLTztdTHiJjONX0Z6Q7GE+5xHyaw== 5 | 6 | -------------------------------------------------------------------------------- /lib/Resources/Utils/commentObstacles.m: -------------------------------------------------------------------------------- 1 | function commentObstacles(blk) 2 | % This function comments or uncomments obstacle blocks when a mask 3 | % parameter is changed 4 | % 5 | % Copyright 2018 The MathWorks, Inc. 6 | 7 | 8 | for idx=1:10 9 | status=get_param(blk,strcat('obs',num2str(idx))); 10 | 11 | if strcmp(status,'off') 12 | set_param([blk '/Obstacles/Obstacle' num2str(idx)],'Commented','on'); 13 | else 14 | set_param([blk '/Obstacles/Obstacle' num2str(idx)],'Commented','off'); 15 | end 16 | end 17 | 18 | 19 | end 20 | -------------------------------------------------------------------------------- /lib/Resources/Utils/mlrobot_src/mlrobotreadcompassangle.m: -------------------------------------------------------------------------------- 1 | function angle=mlrobotreadcompassangle(mlrobot) 2 | % MLROBOTREADCOMPASSANGLE Reads the angle an MLROBOT robot with respect 3 | % to the world in degrees (deg). 4 | % 5 | % mlrobotreadcompassangle(mlrobot) 6 | % 7 | % 8 | % EXAMPLE: 9 | % myRobot = mlrobot; 10 | % mlrobotstart(myRobot); 11 | % angle = mlrobotreadcompassangle(myRobot) 12 | % 13 | % See also MLROBOT MLROBOTSTART MLROBOTSETMOTORVOLTAGE 14 | % MLROBOTREADWHEELSPEED 15 | % 16 | % Copyright 2018 The MathWorks, Inc. 17 | 18 | angle=mlrobot.readCompassAngle; 19 | 20 | end -------------------------------------------------------------------------------- /lib/Resources/CFL_Libs/Scripts_Data/CheckAnim.m: -------------------------------------------------------------------------------- 1 | function CheckAnim(animation_file) 2 | % Verify if animation file exists before attempting to display 3 | % the animation in the MATLAB web browser. 4 | 5 | % Copyright 2014-2017 The MathWorks, Inc. 6 | 7 | if (exist(animation_file)) 8 | % If exists, display in web browser 9 | web(animation_file) 10 | else 11 | % If does not exist, display warning dialog 12 | % Some animations GIFs are too large to include in zip file for sharing 13 | warndlg(sprintf('%s\n%s','The animation file for this example was not included',... 14 | 'to reduce the size of the zip file.'),'Animation Not Included'); 15 | end 16 | -------------------------------------------------------------------------------- /lib/Resources/Utils/mlrobot_src/mlrobotsetmotorvoltage.m: -------------------------------------------------------------------------------- 1 | function mlrobotsetmotorvoltage(mlrobot,motor,input) 2 | % MLROBOTSETMOTORVOLTAGE Sets the motor voltage for either the left or 3 | % right motors connected to the wheels of a MLROBOT robot object. 4 | % 5 | % mlrobotsetmotorvoltage(mlrobot,motor,voltage) 6 | % 7 | % Motor selection is 'left' or 'right' 8 | % Voltage range is between -5 to 5 9 | % 10 | % EXAMPLE: 11 | % myRobot = mlrobot; 12 | % mlrobotsetmotorvoltage(myRobot,'left',4.5) 13 | % 14 | % See also MLROBOT MLROBOTSTART MLROBOTREADWHEELSPEED 15 | % 16 | % Copyright 2018 The MathWorks, Inc. 17 | 18 | mlrobot.writeMotorVoltage(motor,input) 19 | 20 | end 21 | 22 | -------------------------------------------------------------------------------- /lib/Resources/Utils/mlrobot_src/mlrobotreadwheelspeed.m: -------------------------------------------------------------------------------- 1 | function speed=mlrobotreadwheelspeed(mlrobot,wheel) 2 | % MLROBOTREADWHEELSPEED Reads the instantaneous wheel speed from either 3 | % the left or right wheel of the MLROBOT object in degrees per second 4 | % (deg/s). 5 | % 6 | % mlrobotreadwheelspeed(mlrobot,wheel) 7 | % 8 | % Wheel selection is 'left' or 'right' 9 | % 10 | % EXAMPLE: 11 | % myRobot = mlrobot; 12 | % mlrobotstart(myRobot); 13 | % speed = mlrobotreadwheelspeed(myRobot,'left') 14 | % 15 | % See also MLROBOT MLROBOTSTART MLROBOTSETMOTORVOLTAGE 16 | % MLROBOTREADCOMPASSANGLE 17 | % 18 | % Copyright 2018 The MathWorks, Inc. 19 | 20 | speed=mlrobot.readWheelSpeed(wheel); 21 | 22 | end 23 | -------------------------------------------------------------------------------- /lib/Resources/Utils/RP_ROS2_fcn_eStop.m: -------------------------------------------------------------------------------- 1 | function respMsg = RP_ROS2_fcn_eStop(reqMsg, respMsg, model) 2 | %% ROS2™ Navigate Maze Callback 3 | % This function is used as a callback for the /moveRobot ROS2 service 4 | % part of the ROS2 basics examples of the Robotics Playground. 5 | % 6 | % The algorithm sets different commmands to move forward or turn. 7 | 8 | % respMsg = reqMsg; % Response is 99 for "int64_value" if service doesn't finish running 9 | % respMsg.float64_value = 99; 10 | 11 | 12 | 13 | %% Disable Motors in RP ROS™ Robot Simulator 14 | 15 | if strcmp(reqMsg.string_value,'disable') 16 | set_param([model '/RP ROS™ Robot/Enabled'],'Value','0'); 17 | respMsg.string_value = 'Robot Disabled'; % Set response message 18 | elseif strcmp(reqMsg.string_value,'enable') 19 | set_param([model '/RP ROS™ Robot/Enabled'],'Value','1') 20 | respMsg.string_value = 'Robot Enabled'; % Set response message 21 | end 22 | 23 | % END callback 24 | end -------------------------------------------------------------------------------- /lib/Resources/CFL_Libs/startup_Contact_Forces.m: -------------------------------------------------------------------------------- 1 | % Startup for Simscape Multibody Contact Force Library 2 | % Copyright 2014-2017 The MathWorks, Inc. 3 | 4 | CFR_HomeDir = pwd; 5 | addpath(genpath(pwd)); 6 | 7 | CFL_libname = 'Contact_Forces_Lib'; 8 | load_system(CFL_libname); 9 | CFL_ver = get_param(CFL_libname,'Description'); 10 | disp(CFL_ver); 11 | which(CFL_libname) 12 | 13 | tempNumCFLLibs = which(CFL_libname,'-all'); 14 | if (length(tempNumCFLLibs)>1) 15 | tempCFLwarnStr = sprintf('Multiple copies of the Simscape Multibody Contact Force Library are on the MATLAB path. It is recommended you only have one copy on your path. Please consider adjusting your MATLAB path so that only one copy is present.\n\nLocations of Simscape Multibody Contact Force Library on your path:\n'); 16 | tempCFLLibStr = sprintf('%s\n',tempNumCFLLibs{:}); 17 | warning([tempCFLwarnStr tempCFLLibStr]) 18 | end 19 | clear tempNumCFLLibs tempCFLwarnStr 20 | 21 | if(exist('Cam_Follower.slx')==4) 22 | Cam_Follower 23 | web('Contact_Forces_Demo_Script.html'); 24 | end 25 | 26 | -------------------------------------------------------------------------------- /lib/Resources/Utils/setObjects.m: -------------------------------------------------------------------------------- 1 | function setObjects(blk) 2 | % This function is a callback implemented in the obstacle environment map 3 | % to update settings on the objects within the environment 4 | % Copyright 2018 The MathWorks, Inc. 5 | 6 | for idx=1:5 7 | if strcmp(get_param(blk,['obj' num2str(idx)]),'off') 8 | set_param([blk '/Objects/Object' num2str(idx)],'Commented','on'); 9 | else 10 | set_param([blk '/Objects/Object' num2str(idx)],'Commented','off'); 11 | end 12 | % set parameters on block mask 13 | pose=get_param(blk,['obj' 'Pose' num2str(idx)]); 14 | set_param([blk '/Objects/Object' num2str(idx)],'Pose',pose); 15 | % set the color and object label 16 | color=get_param(blk,['obj' 'Color' num2str(idx)]); 17 | if strcmp(color,'Red') 18 | set_param([blk '/Objects/Object' num2str(idx)],'color','[0.8 0 0]'); 19 | elseif strcmp(color,'Green') 20 | set_param([blk '/Objects/Object' num2str(idx)],'color','[0 0.8 0]'); 21 | else 22 | set_param([blk '/Objects/Object' num2str(idx)],'color','[0 0 0.8]'); 23 | end 24 | end 25 | 26 | end 27 | -------------------------------------------------------------------------------- /lib/Resources/Utils/motorCheck.m: -------------------------------------------------------------------------------- 1 | function motorCheck(model,blk) 2 | % This functions check that any motors have a corresponding 3 | % Environment block with a valid robot ID 4 | % Copyright 2018 The MathWorks, Inc. 5 | 6 | envBlk=find_system(model,'MaskType','RP Obstacle Environment'); 7 | blk_ID=get_param(blk,'robotId'); 8 | 9 | if size(envBlk)==1 10 | 11 | ID=get_param(envBlk,'robotId'); 12 | 13 | if ~strcmp(ID{1},blk_ID) 14 | error(['No matching robot ID for ' blk ' Please check robot motor ID matches environment settings']) 15 | end 16 | end 17 | 18 | envBlk=find_system(model,'MaskType','RP Object Environment'); 19 | 20 | if size(envBlk)==1 21 | 22 | ID=get_param(envBlk,'robotId'); 23 | 24 | if ~strcmp(ID{1},blk_ID) 25 | error(['No matching robot ID for ' blk ' Please check robot motor ID matches environment settings']) 26 | end 27 | end 28 | 29 | envBlk=find_system(model,'MaskType','RP Sumo Game'); 30 | 31 | if size(envBlk)==1 32 | 33 | ID1=get_param(envBlk,'robot1Id'); 34 | ID2=get_param(envBlk,'robot2Id'); 35 | 36 | if ~strcmp(ID1{1},blk_ID) 37 | if ~strcmp(ID2{1},blk_ID) 38 | error(['No matching robot ID for ' blk ' Please check robot motor ID matches environment settings']) 39 | end 40 | end 41 | 42 | end 43 | 44 | end -------------------------------------------------------------------------------- /license.txt: -------------------------------------------------------------------------------- 1 | Copyright (c) 2022, The MathWorks, Inc. 2 | All rights reserved. 3 | 4 | Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: 5 | 6 | 1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. 7 | 2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. 8 | 3. In all cases, the software is, and all modifications and derivatives of the software shall be, licensed to you solely for use in conjunction with MathWorks products and service offerings. 9 | 10 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 11 | -------------------------------------------------------------------------------- /lib/Resources/Utils/createMapFromName.m: -------------------------------------------------------------------------------- 1 | function map = createMapFromName(mapName) 2 | % CREATEMAPFROMNAME Outputs a robotics.BinaryOccupancyGrid object given the 3 | % name of the map variable. This is necessary because MATLAB objects are 4 | % currently not supported as Simulink mask parameters 5 | % 6 | % Copyright 2018 The MathWorks, Inc. 7 | 8 | % Default value is empty 9 | map = []; 10 | 11 | % First, check whether the map name is empty 12 | if isempty(mapName) 13 | return; 14 | end 15 | 16 | % Next, check the base and current model workspaces for a valid variable 17 | % with the specified name 18 | try 19 | map = evalin('base',mapName); 20 | catch 21 | try 22 | mdlWs = get_param(bdroot,'ModelWorkspace'); 23 | map = getVariable(mdlWs,mapName); 24 | catch 25 | error(['Invalid map name ''' num2str(mapName) ''' in base and model workspaces.']); 26 | end 27 | end 28 | 29 | % Check the data type of the map 30 | % If it is a robotics.OccupancyGrid, return it as is 31 | if isa(map,'robotics.OccupancyGrid') 32 | return; 33 | % If it is a robotics.BinaryOccupancyGrid, convert it to a 34 | % robotics.OccupancyGrid. This provides access to necessary methods such as 35 | % RAYCAST and RAYINTERSECTION 36 | elseif isa(map,'robotics.BinaryOccupancyGrid') 37 | map = binToOccGrid(map); 38 | else 39 | error(['Map name ''' num2str(mapName) ''' must be a robotics.OccupancyGrid or robotics.BinaryOccupancyGrid object.']); 40 | end 41 | 42 | end 43 | 44 | function occGrid = binToOccGrid(binGrid) 45 | % BINTOOCCGRID Converts a robotics.BinaryOccupancyGrid object to an 46 | % equivalent robotics.OccupancyGrid object. 47 | 48 | occGrid = robotics.OccupancyGrid(binGrid.occupancyMatrix,binGrid.Resolution); 49 | occGrid.GridLocationInWorld = binGrid.GridLocationInWorld; 50 | 51 | end 52 | 53 | -------------------------------------------------------------------------------- /lib/Resources/CFL_Libs/Scripts_Data/CFL_visual_setOnOff.m: -------------------------------------------------------------------------------- 1 | function CFL_visual_setOnOff(mdlname,visOnOff) 2 | % Show or hide all contact surfaces in all contact force blocks in a model 3 | % from Simscape Multibody Contact Force Library. Pass the name of the model 4 | % as an argument to this function 5 | 6 | % Copyright 2014-2017 The MathWorks, Inc. 7 | 8 | CF_bpth=find_system(mdlname,'RegExp','on','LookUnderMasks','on','FollowLinks','on','vis_on','.*'); 9 | CF_bpth_box2box=find_system(mdlname,'RegExp','on','LookUnderMasks','on','FollowLinks','on','vis_on_box2box','.*'); 10 | CF_bpth_box2belt=find_system(mdlname,'RegExp','on','LookUnderMasks','on','FollowLinks','on','vis_on_box2belt','.*'); 11 | 12 | if(~isempty(CF_bpth)) 13 | for i=1:length(CF_bpth) 14 | within_composite_force = 0; 15 | 16 | if(~isempty(CF_bpth_box2box)) 17 | for j=1:length(CF_bpth_box2box) 18 | if (strfind(char(CF_bpth(i)),char(CF_bpth_box2box(j)))) 19 | within_composite_force = 1; 20 | end 21 | end 22 | end 23 | 24 | if(~isempty(CF_bpth_box2belt)) 25 | for k=1:length(CF_bpth_box2belt) 26 | if (strfind(char(CF_bpth(i)),char(CF_bpth_box2belt(k)))) 27 | within_composite_force = 1; 28 | end 29 | end 30 | end 31 | 32 | if(within_composite_force==0) 33 | set_param(char(CF_bpth(i)),'vis_on',visOnOff); 34 | %disp(['Force ' char(CF_bpth(i)) ' not in composite force']); 35 | %else 36 | % disp(['Force ' char(CF_bpth(i)) ' WITHIN composite force']); 37 | end 38 | end 39 | end 40 | 41 | if(~isempty(CF_bpth_box2box)) 42 | for j=1:length(CF_bpth_box2box) 43 | set_param(char(CF_bpth_box2box(j)),'vis_on_box2box',visOnOff) 44 | end 45 | end 46 | 47 | if(~isempty(CF_bpth_box2belt)) 48 | for j=1:length(CF_bpth_box2belt) 49 | set_param(char(CF_bpth_box2belt(j)),'vis_on_box2belt',visOnOff) 50 | end 51 | end 52 | 53 | end 54 | -------------------------------------------------------------------------------- /lib/Resources/CFL_Libs/Scripts_Data/CFL_friction_setModel.m: -------------------------------------------------------------------------------- 1 | function CFL_friction_setModel(mdlname,frictionModel) 2 | % Turn friction on or off in all contact force blocks in a model 3 | % from Simscape Multibody Contact Force Library. Pass the name of the model 4 | % as an argument to this function 5 | 6 | % Copyright 2014-2017 The MathWorks, Inc. 7 | 8 | CF_bpth=find_system(mdlname,'RegExp','on','LookUnderMasks','on','FollowLinks','on','friction_law','.*'); 9 | CF_bpth_box2box=find_system(mdlname,'RegExp','on','LookUnderMasks','on','FollowLinks','on','friction_law_box2box','.*'); 10 | CF_bpth_box2belt=find_system(mdlname,'RegExp','on','LookUnderMasks','on','FollowLinks','on','friction_law_box2belt','.*'); 11 | 12 | if(~isempty(CF_bpth)) 13 | for i=1:length(CF_bpth) 14 | within_composite_force = 0; 15 | 16 | if(~isempty(CF_bpth_box2box)) 17 | for j=1:length(CF_bpth_box2box) 18 | if (strfind(char(CF_bpth(i)),char(CF_bpth_box2box(j)))) 19 | within_composite_force = 1; 20 | end 21 | end 22 | end 23 | 24 | if(~isempty(CF_bpth_box2belt)) 25 | for k=1:length(CF_bpth_box2belt) 26 | if (strfind(char(CF_bpth(i)),char(CF_bpth_box2belt(k)))) 27 | within_composite_force = 1; 28 | end 29 | end 30 | end 31 | 32 | if(within_composite_force==0) 33 | set_param(char(CF_bpth(i)),'friction_law',frictionModel); 34 | %disp(['Force ' char(CF_bpth(i)) ' not in composite force']); 35 | %else 36 | % disp(['Force ' char(CF_bpth(i)) ' WITHIN composite force']); 37 | end 38 | end 39 | end 40 | 41 | if(~isempty(CF_bpth_box2box)) 42 | for j=1:length(CF_bpth_box2box) 43 | set_param(char(CF_bpth_box2box(j)),'friction_law_box2box',frictionModel) 44 | end 45 | end 46 | 47 | if(~isempty(CF_bpth_box2belt)) 48 | for j=1:length(CF_bpth_box2belt) 49 | set_param(char(CF_bpth_box2belt(j)),'friction_law_box2belt',frictionModel) 50 | end 51 | end 52 | 53 | end 54 | -------------------------------------------------------------------------------- /lib/Resources/Utils/PlaygroundCreateSimMap.m: -------------------------------------------------------------------------------- 1 | function mapForSim = PlaygroundCreateSimMap(Arena,blk) 2 | % This function parses through the settings in the obstacle environment 3 | % mask and creates an occupancy grid in order to implement sensors 4 | % Copyright 2018 The MathWorks, Inc. 5 | 6 | arenaDimensions=[Arena.width Arena.length]; 7 | % Normalize the arena dimensions 8 | normDims=arenaDimensions/max(arenaDimensions); 9 | mapScale=200/max(arenaDimensions); 10 | mapGridSize=round(normDims*200); 11 | 12 | 13 | % Initialize obstacle map 14 | locObsMap = ones(mapGridSize(1),mapGridSize(2),'single'); 15 | for idx = 1:size(Arena.obj,2) 16 | % add walls to occupancy map 17 | locObsMap(1:5,:)=0; 18 | locObsMap(end-5:end,:)=0; 19 | locObsMap(:,1:5)=0; 20 | locObsMap(:,end-5:end)=0; 21 | 22 | % if obstacle is enabled in mask then add to occupancy map 23 | if strcmp(Arena.obj(idx).status,'on') 24 | 25 | 26 | obsLoc(1)=((Arena.obj(idx).position(1)+Arena.length/2)*mapScale)-(Arena.obj(idx).width*mapScale/2); 27 | obsLoc(2)=mapGridSize(1)-((Arena.obj(idx).position(2)+Arena.width/2)*mapScale)-(Arena.obj(idx).length*mapScale/2); 28 | obsLoc(3)= Arena.obj(idx).width*mapScale; 29 | obsLoc(4)= Arena.obj(idx).length*mapScale; 30 | 31 | % Get obstacle indices 32 | currObsLoc = ceil(obsLoc); 33 | colIdx = currObsLoc(1):(currObsLoc(1)+currObsLoc(3)); 34 | rowIdx = currObsLoc(2):(currObsLoc(2)+currObsLoc(4)); 35 | 36 | % Set obstacle indices to 0 in map 37 | locObsMap(rowIdx,colIdx) = 0; 38 | 39 | end 40 | 41 | end 42 | 43 | mapForSim.obsMap=locObsMap; 44 | mapForSim.scaleFactor=mapScale; 45 | % imshow(mapForSim.obsMap*240) 46 | % Create simulation map using binary occupancy grid 47 | % compMap = imcomplement(locObsMap); %binary occupancy grid flips this for some reason 48 | compMap=1-locObsMap; 49 | 50 | mapForSim.simMap = robotics.BinaryOccupancyGrid(compMap,mapScale); 51 | % image(mapForSim.obsMap*240) 52 | % show(mapForSim.simMap) 53 | 54 | % Only for testing 55 | % assignin('base','occGrid',mapForSim.simMap) 56 | 57 | 58 | end -------------------------------------------------------------------------------- /lib/Resources/Utils/mlrosbot_src/mlrosbot.m: -------------------------------------------------------------------------------- 1 | classdef mlrosbot 2 | % MLROSBOT Creates a MATLAB Disc Robot in a virtual environment that cane controlled through ROS messages. 3 | % This class is intended for learning to program in 4 | % MATLAB using the Robotics Playground. This robot provides a virtual 5 | % environment visualization and access to sensors and actuators using 6 | % ROS features. 7 | % 8 | % EXAMPLE: 9 | % myRobot = mlrobot; 10 | % mlrobotstart(myRobot); 11 | % mlrobotsetmotorvoltage(myRobot,'left',3); 12 | % wheelSpeed = mlrobotreadwheelspeed(myRobot,'left'); 13 | % mlrobotstop(myRobot); 14 | % 15 | % Open getting started example with the following command: 16 | % 17 | % >> edit mlrobot_getting_started 18 | % 19 | % 20 | % When using with a custom model that reuses the 'MATLAB Disc Robot' from 21 | % the Simulink Robotics Playground library, call this class by passing 22 | % the custom model name as an input 23 | % 24 | % myRobot = mlrosbot('customModelName') 25 | % 26 | % See also MLROBOTSTART MLROBOTSTOP MLROBOTSETMOTORVOLTAGE 27 | % MLROBOTREADWHEELSPEED MLROBOTREADCOMPASSANGLE 28 | % 29 | % Copyright 2018 The MathWorks, Inc. 30 | 31 | properties 32 | modelName='RP_ROS_robot'; 33 | end 34 | 35 | methods 36 | function obj = mlrosbot(varargin) 37 | % The constructor should initialize the class and change the 38 | % modelName if a custom model is used 39 | if nargin==1 40 | obj.modelName=varargin{:}; 41 | end 42 | 43 | end 44 | function obj = close(obj) 45 | bdclose(obj.modelName); 46 | end 47 | 48 | function obj=connect(obj) 49 | if ~bdIsLoaded(obj.modelName) 50 | disp('Loading robot environment...') 51 | load_system(obj.modelName) 52 | disp('Robot environment loaded') 53 | end 54 | disp('Starting simulation...') 55 | set_param(obj.modelName,'SimulationCommand','start'); 56 | 57 | disp('Simulation started') 58 | end 59 | 60 | function disconnect(obj) 61 | set_param(obj.modelName,'SimulationCommand','stop') 62 | disp('Simulation stopped') 63 | end 64 | 65 | 66 | end 67 | 68 | end 69 | 70 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # MATLAB® and Simulink® ROS™ Tutorials 2 | 3 | 4 | [![Open in MATLAB Online](https://www.mathworks.com/images/responsive/global/open-in-matlab-online.svg)](https://matlab.mathworks.com/open/github/v1?repo=mathworks-robotics/matlab-and-simulink-ros-tutorials&file=ROSBasicsIndex.mlx) [![View MATLAB® and Simulink® ROS™ Tutorials on File Exchange](https://www.mathworks.com/matlabcentral/images/matlab-file-exchange.svg)](https://www.mathworks.com/matlabcentral/fileexchange/118630-matlab-and-simulink-ros-tutorials) 5 | 6 | 7 | This is a set of interactive online tutorials teaching the basics of using ROS (Robot Operating System) to develop and program robots. Open these tutorials in either MATLAB or MATLAB Online to learn more about ROS, and get hands-on experience interacting with robots powered by ROS. 8 | 9 | 10 | 11 | 12 | ## Content 13 | 14 | - 9 Interactive Lessons 15 | - 4 Practice Programming Projects 16 | - 1.5 Hours estimated time to completion 17 | 18 | ## Tutorials 19 | 20 | 1. What is ROS? Why use ROS? How to use ROS? 21 | 2. Exploring ROS Networks 22 | 3. Understanding ROS Messages and Topics 23 | 4. Using ROS Subscribers 24 | 5. Using ROS Publishers 25 | 6. Project - Control Robot to Navigate Maze 26 | 7. Using ROS Services 27 | 8. Interact with ROS powered Robots from Simulink and Stateflow 28 | 9. Intro to rosbags, Node deployment, and Custom Messages 29 | 30 | 31 | 32 | 33 | ### [MathWorks Products](http://www.mathworks.com) 34 | 35 | Requires MATLAB release R2022a or newer 36 | - [MATLAB](https://www.mathworks.com/products/matlab.html) 37 | - [Simulink®](https://www.mathworks.com/products/simulink.html) 38 | - [ROS Toolbox](https://www.mathworks.com/products/ros.html) 39 | - [Simscape™ Multibody™](https://www.mathworks.com/products/simscape-multibody.html) 40 | 41 | ## Getting Started 42 | 43 | - [Click to open ROSBasicsIndex.mlx in MATLAB Online](https://matlab.mathworks.com/open/github/v1?repo=mathworks-robotics/matlab-and-simulink-ros-tutorials&file=ROSBasicsIndex.mlx) 44 | 45 | or 46 | 47 | - Search for "ROS Tutorials" in the MATLAB Addon Explorer 48 | 49 | or 50 | 51 | - Download this repo and open the ROSBasicsIndex file in MATLAB! 52 | 53 | 54 | ## Community Support 55 | [MATLAB Central](https://www.mathworks.com/matlabcentral) 56 | 57 | Email: roboticsarena@mathworks.com 58 | 59 | Copyright 2022 The MathWorks, Inc. 60 | 61 | 62 | -------------------------------------------------------------------------------- /lib/Resources/Utils/setObstaclesUI.m: -------------------------------------------------------------------------------- 1 | function setObstaclesUI(blk) 2 | % This function is an interactive obstacle placement tool 3 | % It is implemented within the obstacle environment mask and provides the 4 | % user the ability to draw the desired obstacles within the map. 5 | % Copyright 2018 The MathWorks, Inc. 6 | 7 | numObs=inputdlg('Number of obstacles to place (Max 10): ','Obstacle sekection'); 8 | 9 | for idx=1:10 10 | set_param(blk,['obs' num2str(idx)],'off') 11 | set_param([blk '/Obstacles/Obstacle' num2str(idx)],'Commented','on'); 12 | end 13 | 14 | 15 | if ~isempty(numObs) 16 | 17 | % disable all obstacle sin mask 18 | 19 | 20 | hg=figure('Name','Set Arena Obstacles','NumberTitle','off'); 21 | length=eval(get_param(blk,'arenaLength')); 22 | width=eval(get_param(blk,'arenaWidth')); 23 | arenaDimensions=[width length]; 24 | 25 | % Normalize the arena dimensions 26 | 27 | normDims=arenaDimensions/max(arenaDimensions); 28 | mapScale=2048/max(arenaDimensions); 29 | mapGridSize=round(normDims*2048); 30 | xScale=mapGridSize(2)/length; 31 | yScale=mapGridSize(1)/width; 32 | 33 | image=imread('PlaygroundImage.png'); 34 | scaledImg=imresize(image,mapGridSize); 35 | 36 | imshow(scaledImg) 37 | 38 | for idx=1:eval(numObs{1}) 39 | title(['Draw obstacle ' num2str(idx) ' as a rectangle by clicking and dragging on map']) 40 | h=imrect; 41 | % wait(h(idx)); 42 | recPose(:)=getPosition(h); 43 | 44 | % Fill-in rectangle with obstacle color for user feedback 45 | rectangle('Position',recPose(:),'FaceColor',[1 0.4 0.2]); 46 | 47 | % Correct y axis inversion from image axis and scale to world 48 | % coordinates 49 | 50 | imgPose(:)=[-mapGridSize(2)/2+recPose(1)+recPose(3)/2 mapGridSize(1)/2-recPose(2)-recPose(4)/2 recPose(3:4)]; 51 | 52 | % shift objects to correct reference frame 53 | obsPose(:)=[imgPose(1)/xScale imgPose(2)/yScale imgPose(3)/xScale imgPose(4)/yScale]; 54 | 55 | % set parameters on block mask 56 | set_param(blk,['obs' num2str(idx)],'on') 57 | set_param(blk,['obsPose' num2str(idx)],['[' num2str(obsPose(1:2)) ']']); 58 | set_param(blk,['obsWidth' num2str(idx)],num2str(obsPose(3))); 59 | set_param(blk,['obsLength' num2str(idx)],num2str(obsPose(4))); 60 | set_param([blk '/Obstacles/Obstacle' num2str(idx)],'Commented','off'); 61 | 62 | end 63 | pause(1) 64 | close(hg) 65 | end 66 | end 67 | -------------------------------------------------------------------------------- /lib/Resources/CFL_Libs/Scripts_Data/Extrusions/Extr_Data_LinkHoles.m: -------------------------------------------------------------------------------- 1 | function [xy_data] = Extr_Data_LinkHoles(L, W, r, num_holes, varargin) 2 | %Extr_Data_LinkHoles Produce extrusion data for a link with an arbitrary 3 | %number of holes and rounded ends. 4 | % [xy_data] = Extr_Data_LinkHoles(L, W, r, num_holes) 5 | % This function returns x-y data for a link with half a hole at one end. 6 | % You can specify: 7 | % Length L 8 | % Width W 9 | % Hole radius r 10 | % # holes num_holes 11 | % 12 | % To see a plot showing parameter values, enter the name 13 | % of the function with no arguments 14 | % >> Extr_Data_LinkHoles 15 | % 16 | % To see a plot created with your parameter values, 17 | % add 'plot' as the final argument 18 | % >> Extr_Data_LinkHoles(10,5,1,3,'plot') 19 | % 20 | % Copyright 2014-2017 The MathWorks, Inc. 21 | 22 | % Default data to show diagram 23 | if (nargin == 0) 24 | L = 15; 25 | W = 5; 26 | r = 1; 27 | num_holes = 4; 28 | end 29 | 30 | % Check if plot should be produced 31 | if (isempty(varargin)) 32 | showplot = 'n'; 33 | else 34 | showplot = char(varargin); 35 | end 36 | 37 | 38 | % Half length and width 39 | hl = L / 2; 40 | hw = W / 2; 41 | 42 | % Rounded ends and outer boundary of member 43 | theta = (-89:1:+90)' * pi/180; % CCW 44 | rght_end = repmat([hl 0], 180, 1) + hw * [cos(theta), sin(theta)]; 45 | left_end = flipud(rght_end) * diag([-1 1]); 46 | boundary = [rght_end; left_end]; 47 | 48 | % Circular holes 49 | theta = (270:-1:-90)' * pi/180; % CW 50 | hole = [[0 -hw]; r * [cos(theta), sin(theta)]; [0 -hw]]; 51 | holes = kron(linspace(-hl, +hl, num_holes)', repmat([1 0], 363, 1)) ... 52 | + repmat(hole, num_holes, 1); 53 | 54 | xy_data = [boundary; holes]; 55 | 56 | % Plot diagram to show parameters and extrusion 57 | if (nargin == 0 || strcmpi(showplot,'plot')) 58 | % Figure name 59 | figString = ['h1_' mfilename]; 60 | % Only create a figure if no figure exists 61 | figExist = 0; 62 | fig_hExist = evalin('base',['exist(''' figString ''')']); 63 | if (fig_hExist) 64 | figExist = evalin('base',['ishandle(' figString ') && strcmp(get(' figString ', ''type''), ''figure'')']); 65 | end 66 | if ~figExist 67 | fig_h = figure('Name',figString); 68 | assignin('base',figString,fig_h); 69 | else 70 | fig_h = evalin('base',figString); 71 | end 72 | figure(fig_h) 73 | clf(fig_h) 74 | 75 | % Plot extrusion 76 | patch(xy_data(:,1),xy_data(:,2),[1 1 1]*0.95,'EdgeColor','none'); 77 | hold on 78 | plot(xy_data(:,1),xy_data(:,2),'-','Marker','o','MarkerSize',4,'LineWidth',2); 79 | 80 | axis('equal'); 81 | axis([-1 1 -1 1]*(L+W)*1.1/2); 82 | 83 | % Show parameters 84 | plot([-L/2 L/2],[0 0],'r-d','MarkerFaceColor','r'); 85 | text(-L/4,W/10,'{\color{red}L}'); 86 | plot([L/4 L/4],[-W/2 W/2],'g-d','MarkerFaceColor','g'); 87 | text(L/3.8,W/4,'{\color{green}W}'); 88 | plot([-L/2 -L/2+r*sin(30*pi/180)],[0 r*cos(30*pi/180)],'k-d','MarkerFaceColor','k'); 89 | text(-L/2+r*sin(30*pi/180)*1.4,1.4*r*cos(30*pi/180),'r'); 90 | 91 | title('[xy\_data] = Extr\_Data\_LinkHoles(L, W, r, num\_holes);'); 92 | hold off 93 | box on 94 | clear xy_data 95 | end 96 | 97 | 98 | -------------------------------------------------------------------------------- /lib/Resources/CFL_Libs/Scripts_Data/Extrusions/Extr_Data_Box.m: -------------------------------------------------------------------------------- 1 | function [xy_data] = Extr_Data_Box(box_ox, box_ix, varargin) 2 | %Extr_Data_Box Produce extrusion data for a hollow box. 3 | % [xy_data] = Extr_Data_Box(box_ox, box_ix, , ) 4 | % This function returns x-y data for a hollow box. 5 | % You can specify: 6 | % Box outer width (x) box_ox 7 | % Box inner width (x) box_ix 8 | % (optional) Box outer height (y) box_oy 9 | % (optional) Box inner height (y) box_iy 10 | % 11 | % To see a plot showing parameter values, enter the name 12 | % of the function with no arguments 13 | % >> Extr_Data_Box 14 | % 15 | % To see a plot created with your parameter values, 16 | % add 'plot' as the final argument 17 | % >> Extr_Data_Box(10,5,'plot') 18 | 19 | % Copyright 2013-2017 The MathWorks, Inc. 20 | 21 | % Default data to show diagram 22 | if (nargin == 0) 23 | box_ox = 15; 24 | box_ix = 12; 25 | box_oy = 10; 26 | box_iy = 5; 27 | elseif (nargin <= 3) 28 | box_oy = box_ox; 29 | box_iy = box_ix; 30 | elseif (nargin > 3) 31 | box_oy = varargin{1}; 32 | box_iy = varargin{2}; 33 | end 34 | 35 | if (nargin==0) 36 | showplot = 'plot'; 37 | elseif (nargin==3 || nargin==5) 38 | showplot = varargin(end); 39 | else 40 | showplot = 'n'; 41 | end 42 | 43 | % Generate extrusion data 44 | x_signs = [1 -1 -1 1]'; 45 | y_signs = [1 1 -1 -1]'; 46 | xy_data = [box_ox/2*x_signs box_oy/2*y_signs]; 47 | if(box_ix>0 && box_iy>0) 48 | xy_data = [xy_data;box_ox/2 box_oy/2;box_ix/2*y_signs box_iy/2*x_signs;box_ix/2 box_iy/2]; 49 | end 50 | 51 | % Plot diagram to show parameters and extrusion 52 | if (nargin == 0 || strcmpi(showplot,'plot')) 53 | 54 | % Figure name 55 | figString = ['h1_' mfilename]; 56 | % Only create a figure if no figure exists 57 | figExist = 0; 58 | fig_hExist = evalin('base',['exist(''' figString ''')']); 59 | if (fig_hExist) 60 | figExist = evalin('base',['ishandle(' figString ') && strcmp(get(' figString ', ''type''), ''figure'')']); 61 | end 62 | if ~figExist 63 | fig_h = figure('Name',figString); 64 | assignin('base',figString,fig_h); 65 | else 66 | fig_h = evalin('base',figString); 67 | end 68 | figure(fig_h) 69 | clf(fig_h) 70 | 71 | % Get max axis dimension 72 | maxd = max(box_ox,box_oy); 73 | 74 | % Plot extrusion 75 | patch(xy_data(:,1),xy_data(:,2),[1 1 1]*0.90,'EdgeColor','none'); 76 | hold on 77 | plot(xy_data(:,1),xy_data(:,2),'-','Marker','o','MarkerSize',4,'LineWidth',2); 78 | axis('equal'); 79 | axis([-1.1 1.1 -1.1 1.1]*maxd/2); 80 | 81 | % Show parameters 82 | hold on 83 | 84 | plot([-1 1]*box_ox/2,[0 0],'r-d','MarkerFaceColor','r'); 85 | text(0.25*box_ox,0.025*maxd,'{\color{red}box\_ox}'); 86 | 87 | plot([0 0],[-1 1]*box_oy/2,'g-d','MarkerFaceColor','g'); 88 | text(0,-0.4*box_oy,'{\color{green}box\_oy}'); 89 | 90 | if(box_ix>0 && box_iy>0) 91 | plot([-1 1]*box_ix/2,[1 1]*0.25*box_iy,'b-d','MarkerFaceColor','b'); 92 | text(0.25*box_ix,0.03*maxd+0.25*box_iy,'{\color{blue}box\_ix}'); 93 | 94 | plot([-1 -1]*0.25*box_ix,[-1 1]*box_iy/2,'k-d','MarkerFaceColor','k'); 95 | text(-0.25*box_ix+0.03*maxd,0.4*box_iy,'{\color{black}box\_iy}'); 96 | end 97 | title('[xy\_data] = Extr\_Data\_Box(box\_ox, box\_ix, );'); 98 | hold off 99 | box on 100 | clear xy_data 101 | end 102 | -------------------------------------------------------------------------------- /lib/Resources/Utils/Extr_Data_Mesh.m: -------------------------------------------------------------------------------- 1 | function [xy_data] = Extr_Data_Mesh(lenX, lenY, numHx, numHy, hx, hy, varargin) 2 | %Extr_Data_Mesh Produce extrusion data for a square mesh. 3 | % [xy_data] = Extr_Data_Mesh(lenX, lenY, numHx, numHy, hx, hy) 4 | % This function returns x-y data for a square mesh. 5 | % You can specify: 6 | % Mesh outer width lenX 7 | % Mesh outer length lenY 8 | % Number of mesh holes along X numHx 9 | % Number of mesh holes along Y numHy 10 | % Width of mesh holes (along x) hx 11 | % Length of mesh holes (along y) hy 12 | % 13 | % To see a plot showing parameter values, enter the name 14 | % of the function with no arguments 15 | % >> Extr_Data_Mesh 16 | % 17 | % To see a plot created with your parameter values, 18 | % add 'plot' as the final argument 19 | % >> Extr_Data_Mesh(3,3,3,2,0.8,0.8,'plot') 20 | 21 | % Copyright 2017 The MathWorks, Inc. 22 | 23 | % Default data to show diagram 24 | if (nargin == 0) 25 | lenX = 3; 26 | lenY = 3; 27 | numHx = 3; 28 | numHy = 2; 29 | hx = 0.8; 30 | hy = 0.8; 31 | end 32 | 33 | self_intersect_offset = 1e-4; 34 | 35 | if (nargin==0 ||nargin==7) 36 | showplot = 'plot'; 37 | else 38 | showplot = 'n'; 39 | end 40 | 41 | % Calculate extrusion data 42 | 43 | tx = (lenX-(numHx*hx))/(numHx+1); 44 | ty = (lenY-(numHy*hy))/(numHy+1); 45 | 46 | xy_data = [... 47 | 0 0; 48 | lenX 0; 49 | lenX ty-self_intersect_offset; 50 | tx ty-self_intersect_offset]; 51 | 52 | for j=1:numHy 53 | for i=1:numHx 54 | append_pts = [ 55 | tx*(i)+hx*(i-1) ty+(ty+hy)*(j-1); 56 | tx*(i)+hx*(i-1) ty+hy+(ty+hy)*(j-1); 57 | tx*(i)+hx*i ty+hy+(ty+hy)*(j-1); 58 | tx*(i)+hx*i ty+(ty+hy)*(j-1); 59 | ]; 60 | xy_data = [xy_data;append_pts]; 61 | end 62 | if(i==numHx) 63 | xy_data = [xy_data; 64 | lenX hy*(j-1)+ty*j; 65 | lenX hy*j+ty*(j+1)-self_intersect_offset; 66 | tx hy*j+ty*(j+1)-self_intersect_offset]; 67 | end 68 | if(j==numHy) 69 | xy_data=[xy_data;0 lenY-self_intersect_offset]; 70 | end 71 | end 72 | 73 | xy_data = xy_data-[lenX/2 lenY/2]; 74 | 75 | % Plot diagram to show parameters and extrusion 76 | 77 | if (nargin == 0 || strcmpi(showplot,'plot')) 78 | 79 | % Get max axis dimension 80 | maxd = max(lenX,lenY); 81 | 82 | % Plot extrusion 83 | plot(xy_data(:,1),xy_data(:,2),'b-o','LineWidth',1.5); 84 | axis('square'); 85 | axis([-0.55 0.55 -0.55 0.55]*maxd); 86 | 87 | % Show parameters 88 | 89 | hold on 90 | 91 | plot([-0.5 0.5]*lenX,-[1 1]*(lenY-ty)/2,'r-d','MarkerFaceColor','r'); 92 | text(0,-(lenY-ty)/2,'{\color{red}lenX}'); 93 | 94 | plot(-[1 1]*(lenX-tx)/2,[-0.5 0.5]*lenY,'c-d','MarkerFaceColor','c'); 95 | text(-(lenX-tx)/2,0,'{\color{cyan}lenY}'); 96 | 97 | plot([tx tx+hx]-lenX/2,[1 1]*(ty+hy/2)-lenY/2,'g-d','MarkerFaceColor','g'); 98 | text((tx+hx/2)-lenX/2,(ty+hy/2)-lenY/2,'{\color{green}hx}'); 99 | 100 | plot([-1 -1]*(tx+hx/2)+lenX/2,-[ty ty+hy]+lenY/2,'m-d','MarkerFaceColor','m'); 101 | text(-(tx+hx/2)+lenX/2,-(ty+hy/2)+lenY/2,'{\color{magenta}hy}'); 102 | 103 | plot([tx+hx/2 2*tx+3*hx/2]-lenX/2,-[1 1]*(ty+hy/2)+lenY/2,'k:d','MarkerFaceColor','w'); 104 | text(-lenX/2+(tx+hx/2),lenY/2-(ty+hy/4),'{\color{black}numHx}','HorizontalAlignment','center'); 105 | 106 | title(['[xy\_data] = Extr\_Data\_Mesh(lenX, lenY, numHx, numHy, hx, hy);']); 107 | hold off 108 | clear xy_data 109 | 110 | end 111 | -------------------------------------------------------------------------------- /lib/Resources/CFL_Libs/Scripts_Data/Extrusions/Extr_Data_Cam_Circles.m: -------------------------------------------------------------------------------- 1 | function [xy_data] = Extr_Data_Cam_Circles(rad1, rad2, d, radh1, radh2, varargin) 2 | %Extr_Data_Cam_Circles Produce extrusion data for a cam formed from two circles. 3 | % [xy_data] = Extr_Data_Cam_Circles(rad1, rad2, d, radh1, radh2) 4 | % This function returns x-y data for a cam formed from two circles 5 | % that are connected by lines tangent to the circles. 6 | % 7 | % You can specify: 8 | % Radius, circle 1 rad1 9 | % Radius, circle 2 rad2 10 | % Distance between circle centers d 11 | % Radius of hole at center of circle 1 radh1 12 | % Radius of hole at center of circle 2 radh2 13 | % 14 | % To see a plot showing parameter values, enter the name 15 | % of the function with no arguments 16 | % >> Extr_Data_Cam_Circles 17 | % 18 | % To see a plot created with your parameter values, 19 | % add 'plot' as the final argument 20 | % >> Extr_Data_Cam_Circles(4,3,5,1,0,'plot') 21 | 22 | % Copyright 2012-2017 The MathWorks, Inc. 23 | 24 | % Default data to show diagram 25 | if (nargin == 0) 26 | rad1 = 4; 27 | rad2 = 3; 28 | d = 5; 29 | radh1 = 1; 30 | radh2 = 1; 31 | end 32 | 33 | % Check if plot should be produced 34 | if (isempty(varargin)) 35 | showplot = 'n'; 36 | else 37 | showplot = varargin; 38 | end 39 | 40 | % Calculate angle for external tangent 41 | theta1 = acos((rad1-rad2)/d)*180/pi; 42 | 43 | % Start circle at 90 degrees to avoid self-intersecting polygons 44 | theta_cir = [90:1:360+90]'*pi/180; 45 | unit_cir = [cos(theta_cir), sin(theta_cir)]; 46 | 47 | % Calculate extrusion data 48 | % Arc for rad1 49 | theta_r1 = [(theta1:1:360-theta1)]'*pi/180; 50 | unit_arc = [cos(theta_r1), sin(theta_r1)]; 51 | xy_data1 = [rad1 * unit_arc]; 52 | if(radh1>0) 53 | % Circle for radh1 54 | xy_data1 = [xy_data1(1,:);radh1 * flipud(unit_cir);xy_data1]; 55 | end 56 | 57 | % Arc for rad2 58 | theta_r2 = [(-theta1:1:theta1)]'*pi/180; 59 | unit_arc = [cos(theta_r2), sin(theta_r2)]; 60 | xy_data2 = [rad2 * unit_arc]+repmat([d 0],size(unit_arc,1),1); 61 | if(radh2>0) 62 | % Circle for radh2 63 | xy_data2 = [xy_data2;radh2 * flipud(unit_cir)+repmat([d 0],size(unit_cir,1),1);xy_data2(end,:)]; 64 | end 65 | 66 | xy_data = [xy_data1;xy_data2]; 67 | 68 | % Plot diagram to show parameters and extrusion 69 | if (nargin == 0 || strcmpi(showplot,'plot')) 70 | 71 | % Figure name 72 | figString = ['h1_' mfilename]; 73 | % Only create a figure if no figure exists 74 | figExist = 0; 75 | fig_hExist = evalin('base',['exist(''' figString ''')']); 76 | if (fig_hExist) 77 | figExist = evalin('base',['ishandle(' figString ') && strcmp(get(' figString ', ''type''), ''figure'')']); 78 | end 79 | if ~figExist 80 | fig_h = figure('Name',figString); 81 | assignin('base',figString,fig_h); 82 | else 83 | fig_h = evalin('base',figString); 84 | end 85 | figure(fig_h) 86 | clf(fig_h) 87 | 88 | % Plot extrusion data 89 | patch(xy_data(:,1),xy_data(:,2),[1 1 1]*0.90,'EdgeColor','none'); 90 | hold on 91 | plot(xy_data(:,1),xy_data(:,2),'-','Marker','o','MarkerSize',4,'LineWidth',2); 92 | axis('square'); 93 | axis([-rad1 d+rad2 [-1 1]*(rad1+d+rad2)/2]*1.1); 94 | 95 | % Show parameters 96 | hold on 97 | plot([0 d],[0 0],'k-d','MarkerFaceColor','k','MarkerSize',10); 98 | text(d/2,0.1*max(rad1,rad2),'d'); 99 | 100 | plot([d d+rad2*cos(theta1*pi/180)],[0 rad2*sin(theta1*pi/180)],'r-d','MarkerFaceColor','r'); 101 | text(d+rad2*cos(theta1*pi/180)/2,rad2*sin(theta1*pi/180)/2,'{\color{red}rad2}'); 102 | 103 | plot([0 rad1*cos(theta1*pi/180)],[0 rad1*sin(theta1*pi/180)],'g-d','MarkerFaceColor','g'); 104 | text(rad1*cos(theta1*pi/180)/2,rad1*sin(theta1*pi/180)/2,'{\color{green}rad1}'); 105 | 106 | title(['[xy\_data] = Extr\_Data\_Cam(rad1, rad2, d1);']); 107 | hold off 108 | box on 109 | clear xy_data 110 | end 111 | -------------------------------------------------------------------------------- /lib/Resources/CFL_Libs/Scripts_Data/Extrusions/Extr_Data_Ring.m: -------------------------------------------------------------------------------- 1 | function [xy_data] = Extr_Data_Ring(ring_or, ring_ir, deg1, deg2, varargin) 2 | %Extr_Data_Ring Produce extrusion data for a ring. 3 | % [xy_data] = Extr_Data_Ring(ring_or, ring_ir, deg1, deg2) 4 | % This function returns x-y data for a ring. 5 | % You can specify: 6 | % Outer radius ring_or 7 | % Inner radius ring_ir 8 | % Start angle deg1 9 | % Finish angle deg2 10 | % 11 | % To see a plot showing parameter values, enter the name 12 | % of the function with no arguments 13 | % >> Extr_Data_Ring 14 | % 15 | % To see a plot created with your parameter values, 16 | % add 'plot' as the final argument 17 | % >> Extr_Data_Ring(10,5,45,315,'plot') 18 | 19 | % Copyright 2012-2017 The MathWorks, Inc. 20 | 21 | % Default data to show diagram 22 | if (nargin == 0) 23 | deg1 = 45; 24 | deg2 = 315; 25 | ring_or = 10; 26 | ring_ir = 5; 27 | end 28 | 29 | % Check if plot should be produced 30 | if (isempty(varargin)) 31 | showplot = 'n'; 32 | else 33 | showplot = varargin; 34 | end 35 | 36 | % Calculate extrusion data 37 | theta = [(deg1:1:deg2) ]'*pi/180; 38 | unit_circle = [cos(theta), sin(theta)]; 39 | if(ring_ir>0) 40 | xy_data = [ring_or * unit_circle; ring_ir * flipud(unit_circle)]; 41 | else 42 | xy_data = [ring_or * unit_circle]; 43 | end 44 | 45 | % Plot diagram to show parameters and extrusion 46 | if (nargin == 0 || strcmpi(showplot,'plot')) 47 | 48 | % Figure name 49 | figString = ['h1_' mfilename]; 50 | % Only create a figure if no figure exists 51 | figExist = 0; 52 | fig_hExist = evalin('base',['exist(''' figString ''')']); 53 | if (fig_hExist) 54 | figExist = evalin('base',['ishandle(' figString ') && strcmp(get(' figString ', ''type''), ''figure'')']); 55 | end 56 | if ~figExist 57 | fig_h = figure('Name',figString); 58 | assignin('base',figString,fig_h); 59 | else 60 | fig_h = evalin('base',figString); 61 | end 62 | figure(fig_h) 63 | clf(fig_h) 64 | 65 | % Plot extrusion 66 | patch(xy_data(:,1),xy_data(:,2),[1 1 1]*0.90,'EdgeColor','none'); 67 | hold on 68 | plot(xy_data(:,1),xy_data(:,2),'-','Marker','o','MarkerSize',4,'LineWidth',2); 69 | axis('equal'); 70 | axis([-1.1 1.1 -1.1 1.1]*ring_or); 71 | 72 | % Show parameters 73 | hold on 74 | 75 | ir_label_ang = deg1+deg2*0.2; 76 | or_label_ang = deg1+deg2*0.5; 77 | plot([0 ring_or*(cos(or_label_ang*pi/180))],[0 ring_or*(sin(or_label_ang*pi/180))],'r-d','MarkerFaceColor','r'); 78 | text(cos(or_label_ang*pi/180)*0.75*ring_or,sin(or_label_ang*pi/180)*0.75*ring_or,'{\color{red}ring\_or}'); 79 | 80 | plot([0 ring_ir*(cos(ir_label_ang*pi/180))],[0 ring_ir*(sin(ir_label_ang*pi/180))],'g-d','MarkerFaceColor','g'); 81 | text(cos(ir_label_ang*pi/180)*0.5*ring_ir,sin(ir_label_ang*pi/180)*0.5*ring_ir,'{\color{green}ring\_ir}'); 82 | 83 | plot([0 ring_or],[0 0],'k:'); 84 | plot([0 ring_ir*cos(deg1*pi/180)],[0 ring_ir*sin(deg1*pi/180)],'k:'); 85 | plot([0 ring_ir*cos(deg2*pi/180)],[0 ring_ir*sin(deg2*pi/180)],'k:'); 86 | 87 | arc1_r = 0.75*ring_ir; 88 | arc1 = linspace(0,deg1,50)'*pi/180; 89 | plot(cos(arc1)*arc1_r,sin(arc1)*arc1_r,'k-'); 90 | plot(cos(arc1(1))*arc1_r,sin(arc1(1))*arc1_r,'kd','MarkerFaceColor','k'); 91 | plot(cos(arc1(end))*arc1_r,sin(arc1(end))*arc1_r,'kd','MarkerFaceColor','k'); 92 | text(cos(deg1/2*pi/180)*arc1_r*1.1,sin(deg1/2*pi/180)*arc1_r*1.1,'deg1'); 93 | 94 | arc2_r = 0.25*ring_ir; 95 | arc2 = [(0:1:deg2)]'*pi/180; 96 | plot(cos(arc2)*arc2_r,sin(arc2)*arc2_r,'k-'); 97 | plot(cos(arc2(1))*arc2_r,sin(arc2(1))*arc2_r,'kd','MarkerFaceColor','k'); 98 | plot(cos(arc2(end))*arc2_r,sin(arc2(end))*arc2_r,'kd','MarkerFaceColor','k'); 99 | text(cos(0.7*deg2*pi/180)*arc2_r*2,sin(0.7*deg2*pi/180)*arc2_r*2,'deg2'); 100 | title(['[xy\_data] = Extr\_Data\_Ring(ring\_or, ring\_ir, deg1, deg2);']); 101 | hold off 102 | box on 103 | clear xy_data 104 | end 105 | -------------------------------------------------------------------------------- /lib/Resources/Utils/mlrobot_src/mlrobot.m: -------------------------------------------------------------------------------- 1 | classdef mlrobot 2 | % MLROBOT Creates a MATLAB Disc Robot in a virtual environment. 3 | % This class is intended for learning to program in 4 | % MATLAB using the Robotics Playground. This robot provides a virtual 5 | % environment visualization and access to sensors and actuators using 6 | % MATLAB functions. 7 | % 8 | % EXAMPLE: 9 | % myRobot = mlrobot; 10 | % mlrobotstart(myRobot); 11 | % mlrobotsetmotorvoltage(myRobot,'left',3); 12 | % wheelSpeed = mlrobotreadwheelspeed(myRobot,'left'); 13 | % mlrobotstop(myRobot); 14 | % 15 | % Open getting started example with the following command: 16 | % 17 | % >> edit mlrobot_getting_started 18 | % 19 | % 20 | % When using with a custom model that reuses the 'MATLAB Disc Robot' from 21 | % the Simulink Robotics Playground library, call this class by passing 22 | % the custom model name as an input 23 | % 24 | % myRobot = mlrobot('customModelName') 25 | % 26 | % See also MLROBOTSTART MLROBOTSTOP MLROBOTSETMOTORVOLTAGE 27 | % MLROBOTREADWHEELSPEED MLROBOTREADCOMPASSANGLE 28 | % 29 | % Copyright 2018 The MathWorks, Inc. 30 | 31 | properties 32 | modelName='RP_MATLAB_Disc_robot'; 33 | end 34 | 35 | methods 36 | function obj = mlrobot(varargin) 37 | % The constructor should initialize the class and change the 38 | % modelName if a custom model is used 39 | if nargin==1 40 | obj.modelName=varargin{:}; 41 | end 42 | 43 | end 44 | function obj = close(obj) 45 | bdclose(obj.modelName); 46 | end 47 | 48 | function obj=connect(obj) 49 | if ~bdIsLoaded(obj.modelName) 50 | disp('Loading robot environment...') 51 | load_system(obj.modelName) 52 | disp('Robot environment loaded') 53 | end 54 | disp('Starting simulation...') 55 | set_param(obj.modelName,'SimulationCommand','start'); 56 | set_param([obj.modelName '/MATLAB Disc Robot/Robot/leftVoltage'],'Gain','0'); 57 | set_param([obj.modelName '/MATLAB Disc Robot/Robot/rightVoltage'],'Gain','0'); 58 | disp('Simulation started') 59 | end 60 | 61 | function disconnect(obj) 62 | set_param(obj.modelName,'SimulationCommand','stop') 63 | disp('Simulation stopped') 64 | end 65 | 66 | function writeMotorVoltage(obj,motor,input) 67 | % This function writes the input as the right motor voltage to the 68 | % simulation 69 | if strcmp(motor,'left') 70 | set_param([obj.modelName '/MATLAB Disc Robot/Robot/leftVoltage'],'Gain',num2str(input)); 71 | elseif strcmp(motor,'right') 72 | set_param([obj.modelName '/MATLAB Disc Robot/Robot/rightVoltage'],'Gain',num2str(input)); 73 | else 74 | error('Incorrect motor selection. Choose between ''left'' and ''right''') 75 | end 76 | if input>5 || input<-5 77 | error('Input is out of bounds and will be saturated. Correct range is -5 to 5') 78 | end 79 | 80 | end 81 | 82 | function wheelSpeed=readWheelSpeed(obj,wheel) 83 | robject=get_param([obj.modelName '/MATLAB Disc Robot/Robot/Sensors'],'RuntimeObject'); 84 | if strcmp(wheel,'left') 85 | wheelSpeed=robject.InputPort(1).Data(3); 86 | elseif strcmp(wheel,'right') 87 | wheelSpeed=robject.InputPort(1).Data(5); 88 | else 89 | error('Incorrect wheel selection. Choose between ''left'' and ''right''') 90 | end 91 | end 92 | 93 | function compassAngle=readCompassAngle(obj) 94 | robject=get_param([obj.modelName '/MATLAB Disc Robot/Robot/Sensors'],'RuntimeObject'); 95 | compassAngle=robject.InputPort(1).Data(1); 96 | end 97 | end 98 | 99 | end 100 | 101 | -------------------------------------------------------------------------------- /lib/Resources/Utils/RPInit.m: -------------------------------------------------------------------------------- 1 | function RPInit() 2 | % RP Environment Initalization script 3 | % This script initalizes sensors and creates the necessary information for 4 | % all sensors to operate accordingly. 5 | % Copyright 2018 The MathWorks, Inc. 6 | 7 | model=gcs; 8 | environments=0; 9 | isMlRobot=0; 10 | 11 | set_param(model,'SimMechanicsRigidlyBoundBlock','none'); 12 | set_param(model,'UnconnectedLineMsg','none'); 13 | 14 | %% 15 | envBlk=find_system(model,'MaskType','RP MATLAB Environment'); 16 | 17 | if size(envBlk)==1 18 | environments=environments+1; 19 | isMlRobot=1; 20 | block=envBlk{1}; 21 | % Disable link so that the changes can be saved with the model 22 | set_param(block,'LinkStatus','breakWithoutHierarchy'); 23 | set_param([block '/Robot'],'LinkStatus','breakWithoutHierarchy'); 24 | end 25 | 26 | envBlk=find_system(model,'MaskType','RP Robot Motor'); 27 | 28 | if isempty(envBlk) && isMlRobot == 0 29 | error('No RP Motor blocks found. Please place necessary actuators to interact with the robot.') 30 | end 31 | 32 | envBlk=find_system(model,'MaskType','RP Obstacle Environment'); 33 | 34 | if size(envBlk)==1 35 | environments=environments+1; 36 | block=envBlk{1}; 37 | % Disable link so that the changes can be saved with the model 38 | set_param(block,'LinkStatus','breakWithoutHierarchy'); 39 | 40 | Arena.width=eval(get_param(block,'arenaWidth')); 41 | Arena.length=eval(get_param(block,'arenaLength')); 42 | 43 | for idx=1:10 44 | Arena.obj(idx).status=get_param(block,strcat('obs',num2str(idx))); 45 | Arena.obj(idx).position=eval(get_param(block,strcat('obsPose',num2str(idx)))); 46 | Arena.obj(idx).width=eval(get_param(block,strcat('obsWidth',num2str(idx)))); 47 | Arena.obj(idx).length=eval(get_param(block,strcat('obsLength',num2str(idx)))); 48 | end 49 | mapForSim=PlaygroundCreateSimMap(Arena,envBlk{1}); 50 | ws=get_param(gcs,'modelworkspace'); 51 | 52 | try 53 | ws.assignin('mapForSim',mapForSim); 54 | ws.assignin('occGrid',mapForSim.simMap); 55 | catch 56 | disp('Make sure library block is placed in model') 57 | end 58 | 59 | 60 | end 61 | 62 | %% 63 | 64 | envBlk=find_system(model,'MaskType','RP Object Environment'); 65 | 66 | if size(envBlk)==1 67 | environments=environments+1; 68 | block=envBlk{1}; 69 | % Disable link so that the changes can be saved with the model 70 | set_param(block,'LinkStatus','breakWithoutHierarchy'); 71 | 72 | Arena.width=eval(get_param(block,'arenaWidth')); 73 | Arena.length=eval(get_param(block,'arenaLength')); 74 | arenaDimensions=[Arena.width Arena.length]; 75 | % Normalize the arena dimensions 76 | normDims=arenaDimensions/max(arenaDimensions); 77 | mapScale=2048/max(arenaDimensions); 78 | mapGridSize=round(normDims*2048); 79 | 80 | % Initialize obstacle map 81 | locObsMap = ones(mapGridSize(1),mapGridSize(2),'single'); 82 | % add walls to occupancy map 83 | locObsMap(1:5,:)=0; 84 | locObsMap(end-5:end,:)=0; 85 | locObsMap(:,1:5)=0; 86 | locObsMap(:,end-5:end)=0; 87 | 88 | mapForSim.obsMap=locObsMap; 89 | mapForSim.scaleFactor=mapScale; 90 | % Create simulation map using binary occupancy grid 91 | % compMap = imcomplement(locObsMap); %binary occupancy grid flips this for some reason 92 | compMap=1-locObsMap; 93 | mapForSim.simMap = robotics.BinaryOccupancyGrid(compMap,mapScale); 94 | 95 | ws=get_param(gcs,'modelworkspace'); 96 | 97 | try 98 | ws.assignin('mapForSim',mapForSim); 99 | ws.assignin('occGrid',mapForSim.simMap); 100 | catch 101 | disp('Make sure library block is placed in model') 102 | end 103 | 104 | end 105 | 106 | 107 | %% 108 | envBlk=find_system(model,'MaskType','RP Sumo Game'); 109 | 110 | if size(envBlk)==1 111 | environments=environments+1; 112 | block=envBlk{1}; 113 | % Disable link so that the changes can be saved with the model 114 | set_param(block,'LinkStatus','breakWithoutHierarchy'); 115 | end 116 | %% 117 | if environments ~= 1 118 | if environments ==0 119 | error('Please ensure there is at least one environment block in your model') 120 | else 121 | error('Please ensure there is only one environment block in your model') 122 | end 123 | end 124 | end -------------------------------------------------------------------------------- /lib/Resources/CFL_Libs/Libraries/slblocks.m: -------------------------------------------------------------------------------- 1 | function blkStruct = slblocks 2 | %SLBLOCKS Defines the block library for a specific Toolbox or Blockset. 3 | % SLBLOCKS returns information about a Blockset to Simulink. The 4 | % information returned is in the form of a BlocksetStruct with the 5 | % following fields: 6 | % 7 | % Name Name of the Blockset in the Simulink block library 8 | % Blocksets & Toolboxes subsystem. 9 | % OpenFcn MATLAB expression (function) to call when you 10 | % double-click on the block in the Blocksets & Toolboxes 11 | % subsystem. 12 | % MaskDisplay Optional field that specifies the Mask Display commands 13 | % to use for the block in the Blocksets & Toolboxes 14 | % subsystem. 15 | % Browser Array of Simulink Library Browser structures, described 16 | % below. 17 | % 18 | % The Simulink Library Browser needs to know which libraries in your 19 | % Blockset it should show, and what names to give them. To provide 20 | % this information, define an array of Browser data structures with one 21 | % array element for each library to display in the Simulink Library 22 | % Browser. Each array element has two fields: 23 | % 24 | % Library File name of the library (model file) to include in the 25 | % Library Browser. 26 | % Name Name displayed for the library in the Library Browser 27 | % window. Note that the Name is not required to be the 28 | % same as the model file name. 29 | % 30 | % Example: 31 | % 32 | % % 33 | % % Define the BlocksetStruct for the Simulink block libraries 34 | % % Only simulink_extras shows up in Blocksets & Toolboxes 35 | % % 36 | % blkStruct.Name = ['Simulink' sprintf('\n') 'Extras']; 37 | % blkStruct.OpenFcn = 'simulink_extras'; 38 | % blkStruct.MaskDisplay = sprintf('Simulink\nExtras'); 39 | % 40 | % % 41 | % % Both simulink and simulink_extras show up in the Library Browser. 42 | % % 43 | % blkStruct.Browser(1).Library = 'simulink'; 44 | % blkStruct.Browser(1).Name = 'Simulink'; 45 | % blkStruct.Browser(2).Library = 'simulink_extras'; 46 | % blkStruct.Browser(2).Name = 'Simulink Extras'; 47 | % 48 | 49 | % Copyright 1990-2017 The MathWorks, Inc. 50 | 51 | % 52 | % Name of the subsystem which will show up in the Simulink Blocksets 53 | % and Toolboxes subsystem. 54 | % 55 | blkStruct.Name = ['Simscape Multibody Contact Forces Library']; 56 | % 57 | % The function that will be called when the user double-clicks on 58 | % this icon. 59 | % 60 | blkStruct.OpenFcn = 'Contact_Forces_Lib'; 61 | 62 | % 63 | % The argument to be set as the Mask Display for the subsystem. You 64 | % may comment this line out if no specific mask is desired. 65 | % Example: blkStruct.MaskDisplay = 'plot([0:2*pi],sin([0:2*pi]));'; 66 | % No display for Simulink Extras. 67 | % 68 | blkStruct.MaskDisplay = 'Simscape Multibody Contact Forces Library'; 69 | 70 | % 71 | % Define the Browser structure array, the first element contains the 72 | % information for the Simulink block library and the second for the 73 | % Simulink Extras block library. 74 | % 75 | 76 | %blkStruct.Browser(1).Library = 'simulink'; 77 | %blkStruct.Browser(1).Name = 'Simulink'; 78 | %blkStruct.Browser(2).Library = 'Contact_Forces_Lib'; 79 | %blkStruct.Browser(2).Name = 'Simscape Multibody Contact Forces Library'; 80 | 81 | %blkStruct.Browser(1).Library = 'Contact_Forces_Lib'; 82 | %blkStruct.Browser(1).Name = 'Simscape Multibody Contact Forces Library'; 83 | 84 | Browser(1).Library = 'Contact_Forces_Lib'; 85 | Browser(1).Name = 'Simscape Multibody Contact Forces Library'; 86 | 87 | %Browser(1).IsTopLevel = 0; 88 | %Browser(1).IsFlat = 1;% Is this library "flat" (i.e. no subsystems)? 89 | 90 | %Browser(2).Library = 'TNO_dtlib_2'; 91 | %Browser(2).Name = 'Simulink'; 92 | %Browser(2).IsFlat = 0;% Is this library "flat" (i.e. no subsystems)? 93 | 94 | blkStruct.Browser = Browser; 95 | clear Browser; 96 | 97 | 98 | % Define information for model updater 99 | blkStruct.ModelUpdaterMethods.fhDetermineBrokenLinks = @UpdateSimulinkBrokenLinksMappingHelper; 100 | blkStruct.ModelUpdaterMethods.fhSeparatedChecks = @UpdateSimulinkBlocksHelper; 101 | 102 | % End of slblocks 103 | 104 | 105 | -------------------------------------------------------------------------------- /lib/Resources/Utils/LidarSensorRP.m: -------------------------------------------------------------------------------- 1 | classdef LidarSensorRP < matlab.System 2 | % LIDARSENSOR 2D Lidar simulator 3 | % 4 | % Returns the angles and ranges of a simulated lidar sensor based on 5 | % the input map (occupancy grid), scan offsets/angles, and maximum range. 6 | % Range values outside the maximum range will return NaN. 7 | % 8 | % 9 | % Copyright 2018 The MathWorks, Inc. 10 | 11 | %% PROPERTIES 12 | % Public (user-visible) properties 13 | properties(Nontunable) 14 | mapName = ''; % Map 15 | end 16 | properties 17 | sensorOffset = [0,0]; % Lidar sensor offset (x,y) [m] 18 | scanAngles = [-pi/4,0,pi/4]; % Scan angles [rad] 19 | maxRange = 5; % Maximum range [m] 20 | end 21 | 22 | % Private properties 23 | properties(Access = private) 24 | map; % Occupancy grid 25 | end 26 | 27 | %% METHODS 28 | methods(Access = protected) 29 | 30 | % Setup method: Initializes all necessary graphics objects 31 | function setupImpl(obj) 32 | 33 | % Load the occupancy grid 34 | obj.map = createMapFromName(obj.mapName); 35 | 36 | end 37 | 38 | % Step method: Outputs simulated lidar ranges based on map, 39 | % robot pose, and scan angles/max range 40 | function ranges = stepImpl(obj,pose) 41 | 42 | % Initialize the ranges to the invalid value (NaN) 43 | ranges = nan(numel(obj.scanAngles),1); 44 | 45 | % If the map is empty or the pose is outside the map limits, 46 | % return all NaN 47 | if isempty(obj.map) 48 | warning('Robot map is empty. Returning NaN for lidar ranges.') 49 | return; 50 | elseif (pose(1)obj.map.XWorldLimits(2)) || ... 51 | (pose(2)obj.map.YWorldLimits(2)) 52 | warning('Robot pose outside world limits. Returning NaN for lidar ranges.'); 53 | return; 54 | end 55 | 56 | % Find the sensor pose 57 | theta = pose(3); 58 | offsetVec = [cos(theta) -sin(theta); ... 59 | sin(theta) cos(theta)]*obj.sensorOffset'; 60 | sensorLoc = pose(1:2)' + offsetVec'; 61 | 62 | % Cast a ray from the robot pose through the max range 63 | 64 | % If there is a single sensor offset, use that value and find 65 | % the intersection points/ranges in a single command 66 | if size(sensorLoc,1) == 1 67 | sensorPose = [sensorLoc, theta]; 68 | interPts = rayIntersection(obj.map, sensorPose, ... 69 | obj.scanAngles, obj.maxRange); 70 | offsets = interPts-sensorPose(1:2); 71 | ranges = sqrt(sum(offsets.^2,2)); 72 | % Else, loop through each sensor location and find the 73 | % intersection points/ranges one by one 74 | else 75 | for idx = 1:numel(ranges) 76 | sensorPose = [sensorLoc(idx,:), theta]; 77 | interPts = rayIntersection(obj.map, sensorPose, ... 78 | obj.scanAngles(idx), obj.maxRange); 79 | offsets = interPts-sensorPose(1:2); 80 | ranges(idx) = sqrt(sum(offsets^2,2)); 81 | end 82 | end 83 | end 84 | 85 | % More methods needed for the Simulink block to inherit its output 86 | % sizes from the scan angle parameter provided. 87 | function sz = getOutputSizeImpl(obj) 88 | sz = numel(obj.scanAngles); 89 | end 90 | 91 | function fx = isOutputFixedSizeImpl(~) 92 | fx = true; 93 | end 94 | 95 | function dt = getOutputDataTypeImpl(obj) 96 | dt = propagatedInputDataType(obj,1); 97 | end 98 | 99 | function cp = isOutputComplexImpl(~) 100 | cp = false; 101 | end 102 | 103 | % Define icon for System block 104 | function icon = getIconImpl(~) 105 | icon = {'Lidar','Sensor'}; 106 | end 107 | 108 | end 109 | 110 | methods (Static, Access = protected) 111 | % Do not show "Simulate using" option 112 | function flag = showSimulateUsingImpl 113 | flag = false; 114 | end 115 | % Always run in interpreted mode 116 | function simMode = getSimulateUsingImpl 117 | simMode = 'Interpreted execution'; 118 | end 119 | end 120 | 121 | end 122 | -------------------------------------------------------------------------------- /lib/Resources/CFL_Libs/Scripts_Data/Extrusions/Extr_Data_Frustum_Conical.m: -------------------------------------------------------------------------------- 1 | function [xy_data] = Extr_Data_Frustum_Conical(cone_or, cone_th, varargin) 2 | %Extr_Data_Frustum_Conical Produce *revolution* data for a conical frustum. 3 | % [xy_data] = Extr_Data_Frustum_Conical(cone_or, cone_th, , ) 4 | % This function returns x-y data for a conical frustrum. 5 | % You can specify: 6 | % Cone outer radius (m) cone_or 7 | % Cone theta (deg) cone_th 8 | % (optional) Cone height (m) cone_h 9 | % (optional) Cone inner radius (m) cone_ir 10 | % 11 | % To see a plot showing parameter values, enter the name 12 | % of the function with no arguments 13 | % >> Extr_Data_Frustum_Conical 14 | % 15 | % To see a plot created with your parameter values, 16 | % add 'plot' as the final argument 17 | % >> Extr_Data_Frustum_Conical(5,60,4,4,'plot') 18 | 19 | % Copyright 2017 The MathWorks, Inc. 20 | 21 | % Default data to show diagram 22 | showplot = 'n'; 23 | if (nargin == 0) 24 | cone_or = 5; 25 | cone_th = 60; 26 | cone_h = 4; 27 | cone_ir = 4; 28 | showplot = 'plot'; 29 | elseif (nargin == 2) 30 | cone_h = cone_or*tand(cone_th); 31 | cone_ir = 0; 32 | elseif (nargin == 3) 33 | cone_ir = 0; 34 | if ischar(varargin{1}) % PLOT REQUESTED 35 | showplot = varargin{1}; 36 | cone_h = cone_or*tand(cone_th); 37 | else 38 | cone_h = varargin{1}; % Ad SPECIFIED 39 | end 40 | elseif (nargin == 4) 41 | cone_h = varargin{1}; % Ad SPECIFIED 42 | if ischar(varargin{2}) % PLOT REQUESTED 43 | showplot = varargin{2}; 44 | cone_ir = 0; 45 | else 46 | cone_ir = varargin{2}; % Ad SPECIFIED 47 | end 48 | elseif (nargin == 5) 49 | cone_h = varargin{1}; % Ad SPECIFIED 50 | cone_ir = varargin{2}; % Ad SPECIFIED 51 | showplot = varargin{3}; 52 | end 53 | 54 | % Generate extrusion data 55 | h_out = min(cone_h,cone_or*tand(cone_th)); 56 | x_out = max(0,cone_or-h_out/tand(cone_th)); 57 | h_in = min(h_out,cone_ir*tand(cone_th)); 58 | x_in = max(0,cone_ir-h_in/tand(cone_th)); 59 | 60 | xy_data = [... 61 | cone_ir 0; 62 | cone_or 0; 63 | x_out h_out]; 64 | 65 | % Logic to avoid duplicate coordinates 66 | if (x_out ~= 0) 67 | xy_data = [xy_data; x_in h_out]; 68 | end 69 | 70 | if ((cone_ir ~= 0) && (h_in ~= h_out)) 71 | xy_data = [xy_data; x_in h_in]; 72 | end 73 | 74 | 75 | 76 | % Plot diagram to show parameters and extrusion 77 | if (nargin == 0 || strcmpi(showplot,'plot')) 78 | 79 | % Figure name 80 | figString = ['h1_' mfilename]; 81 | % Only create a figure if no figure exists 82 | figExist = 0; 83 | fig_hExist = evalin('base',['exist(''' figString ''')']); 84 | if (fig_hExist) 85 | figExist = evalin('base',['ishandle(' figString ') && strcmp(get(' figString ', ''type''), ''figure'')']); 86 | end 87 | if ~figExist 88 | fig_h = figure('Name',figString); 89 | assignin('base',figString,fig_h); 90 | else 91 | fig_h = evalin('base',figString); 92 | end 93 | figure(fig_h) 94 | clf(fig_h) 95 | 96 | % Get max axis dimension 97 | % maxd = max(box_ox,box_oy); 98 | 99 | % Plot data 100 | patch(xy_data(:,1),xy_data(:,2),[1 1 1]*0.90,'EdgeColor','none'); 101 | hold on 102 | plot(xy_data(:,1),xy_data(:,2),'-','Marker','o','MarkerSize',4,'LineWidth',2); 103 | 104 | % Mirror data to show revolution 105 | patch(-xy_data(:,1),xy_data(:,2),[1 1 1]*0.90,'EdgeColor','none'); 106 | hold on 107 | plot(-xy_data(:,1),xy_data(:,2),'-','Marker','o','MarkerSize',4,'LineWidth',2); 108 | 109 | axis('equal'); 110 | 111 | % Show parameters 112 | hold on 113 | 114 | plot([0 cone_or],[0 0],'r-d','MarkerFaceColor','r'); 115 | text(0.25*cone_or,0.025*h_out,'{\color{red}cone\_or}','HorizontalAlignment','center'); 116 | 117 | if(cone_ir>0) 118 | plot([0 -cone_ir],[0 0],'g-d','MarkerFaceColor','g'); 119 | text(-0.25*cone_ir,0.025*h_out,'{\color{green}cone\_ir}','HorizontalAlignment','center'); 120 | end 121 | 122 | plot([0 0],[0 cone_h],'b-d','MarkerFaceColor','b'); 123 | text(0, 0.5*cone_h,'{\color{blue}cone\_h}'); 124 | 125 | arc1_r = 0.6*cone_or; 126 | arc1 = [(0:1:cone_th)]'*pi/180; 127 | plot(-cos(arc1)*arc1_r+cone_or,sin(arc1)*arc1_r,'k-'); 128 | plot(-cos(arc1(1))*arc1_r+cone_or,sin(arc1(1))*arc1_r,'kd','MarkerFaceColor','k'); 129 | plot(-cos(arc1(end))*arc1_r+cone_or,sin(arc1(end))*arc1_r,'kd','MarkerFaceColor','k'); 130 | text(-cos(cone_th/2*pi/180)*arc1_r*1.1+cone_or,sin(cone_th/2*pi/180)*arc1_r*1.1,'cone\_theta'); 131 | 132 | 133 | title('[xy\_data] = Extr\_Data\_Frustum\_Conical(cone\_or, cone\_th, );'); 134 | hold off 135 | box on 136 | clear xy_data 137 | end 138 | -------------------------------------------------------------------------------- /lib/Resources/CFL_Libs/Scripts_Data/Extrusions/Extr_Data_Ellipse.m: -------------------------------------------------------------------------------- 1 | function [xy_data] = Extr_Data_Ellipse(a, b, deg1, deg2, ctr, varargin) 2 | %Extr_Data_Ellipse Produce extrusion data for an ellipse. 3 | % [xy_data] = Extr_Data_Ellipse(a, b, deg1, deg2, ctr, varargin) 4 | % This function returns x-y data for a ring. 5 | % You can specify: 6 | % Radius 1 a 7 | % Radius 2 b 8 | % Start angle deg1 9 | % Finish angle deg2 10 | % Include Center ctr 11 | % 12 | % To see a plot showing parameter values, enter the name 13 | % of the function with no arguments 14 | % >> Extr_Data_Ellipse 15 | % 16 | % To see a plot created with your parameter values, 17 | % add 'plot' as the final argument 18 | % >> Extr_Data_Ellipse(5,2,60,315,1,'plot') 19 | 20 | % Copyright 2012-2017 The MathWorks, Inc. 21 | 22 | % Default data to show diagram 23 | if (nargin == 0) 24 | a = 5; 25 | b = 2; 26 | deg1 = 60; 27 | deg2 = 315; 28 | ctr = 1; 29 | end 30 | 31 | % Check if plot should be produced 32 | if (isempty(varargin)) 33 | showplot = 'n'; 34 | else 35 | showplot = varargin; 36 | end 37 | 38 | % Calculate quarter of ellipse 39 | xdata = a:-a/50:0; 40 | for i=1:length(xdata) 41 | ydata(i) = b/a*sqrt(a^2-xdata(i)^2); 42 | end 43 | 44 | % Full outer ellipse 45 | xy_data = [xdata -fliplr(xdata(1:end-1)) -xdata(2:end) fliplr(xdata(1:end-1)); ydata fliplr(ydata(1:end-1)) -ydata(2:end) -fliplr(ydata(1:end-1))]'; 46 | 47 | % Determine start and stop 48 | angles = unwrap(atan2(xy_data(:,2),xy_data(:,1)))*180/pi; 49 | start = find(angles>=deg1); 50 | start_ind = start(1); 51 | finish = find(angles<=deg2); 52 | finish_ind = finish(end); 53 | 54 | % Determine connection between start and finish 55 | if (ctr == 0) 56 | xy_data = [0 0; xy_data(start_ind:finish_ind,:)]; 57 | elseif (ctr == 1) 58 | xy_data = [xy_data(start_ind:finish_ind,:)]; 59 | else 60 | xy_data = [xy_data(start_ind:finish_ind,:);flipud(xy_data(start_ind:finish_ind,:))*ctr]; 61 | end 62 | 63 | % Plot diagram to show parameters and extrusion 64 | if (nargin == 0 || strcmpi(showplot,'plot')) 65 | 66 | % Figure name 67 | figString = ['h1_' mfilename]; 68 | % Only create a figure if no figure exists 69 | figExist = 0; 70 | fig_hExist = evalin('base',['exist(''' figString ''')']); 71 | if (fig_hExist) 72 | figExist = evalin('base',['ishandle(' figString ') && strcmp(get(' figString ', ''type''), ''figure'')']); 73 | end 74 | if ~figExist 75 | fig_h = figure('Name',figString); 76 | assignin('base',figString,fig_h); 77 | else 78 | fig_h = evalin('base',figString); 79 | end 80 | figure(fig_h) 81 | clf(fig_h) 82 | 83 | 84 | % Plot extrusion 85 | patch(xy_data(:,1),xy_data(:,2),[1 1 1]*0.90,'EdgeColor','none'); 86 | hold on 87 | plot(xy_data(:,1),xy_data(:,2),'-','Marker','o','MarkerSize',4,'LineWidth',2); 88 | 89 | % plot(xy_data(:,1),xy_data(:,2),'-','Marker','.','MarkerSize',12,'LineWidth',1.5); 90 | axis('equal'); 91 | axis([-1.1 1.1 -1.1 1.1]*max(a,b)); 92 | 93 | % Show parameters 94 | hold on 95 | 96 | a_label_ang = 180; 97 | b_label_ang = 90; 98 | plot([0 a*(cos(a_label_ang*pi/180))],[0 a*(sin(a_label_ang*pi/180))],'r-d','MarkerFaceColor','r'); 99 | text(cos(a_label_ang*pi/180)*0.75*a,sin(a_label_ang*pi/180)*0.75*a,'{\color{red}a}'); 100 | 101 | plot([0 b*(cos(b_label_ang*pi/180))],[0 b*(sin(b_label_ang*pi/180))],'g-d','MarkerFaceColor','g'); 102 | text(cos(b_label_ang*pi/180)*0.5*b,sin(b_label_ang*pi/180)*0.5*b,'{\color{green}b}'); 103 | 104 | plot([0 a],[0 0],'k:'); 105 | plot([0 b*cos(deg1*pi/180)],[0 b*sin(deg1*pi/180)],'k:'); 106 | plot([0 b*cos(deg2*pi/180)],[0 b*sin(deg2*pi/180)],'k:'); 107 | 108 | arc1_r = 0.6*b; 109 | arc1 = [(0:1:deg1)]'*pi/180; 110 | plot(cos(arc1)*arc1_r,sin(arc1)*arc1_r,'k-'); 111 | plot(cos(arc1(1))*arc1_r,sin(arc1(1))*arc1_r,'kd','MarkerFaceColor','k'); 112 | plot(cos(arc1(end))*arc1_r,sin(arc1(end))*arc1_r,'kd','MarkerFaceColor','k'); 113 | text(cos(deg1/2*pi/180)*arc1_r*1.1,sin(deg1/2*pi/180)*arc1_r*1.1,'deg1'); 114 | 115 | arc2_r = 0.25*b; 116 | arc2 = [(0:1:deg2)]'*pi/180; 117 | plot(cos(arc2)*arc2_r,sin(arc2)*arc2_r,'k-'); 118 | plot(cos(arc2(1))*arc2_r,sin(arc2(1))*arc2_r,'kd','MarkerFaceColor','k'); 119 | plot(cos(arc2(end))*arc2_r,sin(arc2(end))*arc2_r,'kd','MarkerFaceColor','k'); 120 | text(cos(0.7*deg2*pi/180)*arc2_r*2,sin(0.7*deg2*pi/180)*arc2_r*2,'deg2'); 121 | 122 | text(-a,0.75*a,'ctr = 0, center point included'); 123 | text(-a,0.65*a,'ctr >0 & <1, hollow ellipse created'); 124 | text(-a,0.55*a,'ctr = 1, chord connects ends'); 125 | 126 | title(['[xy\_data] = Extr\_Data\_Ellipse(a, b, deg1, deg2, ctr);']); 127 | hold off 128 | box on 129 | clear xy_data 130 | end 131 | -------------------------------------------------------------------------------- /lib/Resources/Utils/ObjectDetectorRP.m: -------------------------------------------------------------------------------- 1 | classdef ObjectDetectorRP < matlab.System & matlab.system.mixin.CustomIcon & matlab.system.mixin.Propagates 2 | % OBJECTDETECTOR Object detector simulator 3 | % 4 | % Returns the angles, ranges, and labels of a simulated object detector 5 | % 6 | % 7 | % Copyright 2018 The MathWorks, Inc. 8 | 9 | %% PROPERTIES 10 | % Public (user-visible) properties 11 | properties(Nontunable) 12 | mapName = ''; % Map 13 | end 14 | properties 15 | sensorOffset = [0,0]; % Object detector offset (x,y) [m] 16 | sensorAngle = 0; % Object detector angle [rad] 17 | fieldOfView = pi/3; % Sensor field of view [rad] 18 | maxRange = 5; % Maximum range [m] 19 | maxDetections = 3; % Maximum number of detections 20 | end 21 | 22 | % Private properties 23 | properties(Access = private) 24 | map; % Occupancy grid 25 | end 26 | 27 | %% METHODS 28 | methods(Access = protected) 29 | 30 | % Setup method: Initializes all necessary graphics objects 31 | function setupImpl(obj) 32 | 33 | % Load the occupancy grid 34 | obj.map = createMapFromName(obj.mapName); 35 | 36 | end 37 | 38 | % Step method: Outputs simulated lidar ranges based on map, 39 | % robot pose, sensor field of view, max range, and object color 40 | function detections = stepImpl(obj,pose,objects) 41 | 42 | % Initialize 43 | ranges = []; 44 | angles = []; 45 | labels = []; 46 | 47 | % Find the sensor pose 48 | theta = pose(3); 49 | offsetVec = [cos(theta) -sin(theta); ... 50 | sin(theta) cos(theta)]*obj.sensorOffset'; 51 | sensorPose = pose' + [offsetVec', obj.sensorAngle]; 52 | 53 | % Return the range and angle for all objects 54 | % First, find the offsets 55 | offsets = objects(:,1:2) - sensorPose(1:2); 56 | 57 | if ~isempty(offsets) 58 | % Extract ranges and angles 59 | ranges = sqrt(sum(offsets.^2,2)); 60 | angles = wrapToPi(atan2(offsets(:,2),offsets(:,1))-sensorPose(3)); 61 | 62 | % Filter by maximum range and field of vision 63 | validIdx = (ranges <= obj.maxRange) & ... 64 | (abs(angles) <= obj.fieldOfView/2); 65 | ranges = ranges(validIdx); 66 | angles = angles(validIdx); 67 | labels = objects(validIdx,3); 68 | 69 | % Use occupancy grid, if any, to account for obstacles 70 | if ~isempty(obj.map) 71 | % Loop backwards since we're removing values 72 | for idx = numel(ranges):-1:1 73 | intPts = rayIntersection(obj.map,sensorPose, ... 74 | angles(idx),ranges(idx)); 75 | % Delete the reading if the point is occupied 76 | if ~isnan(intPts) 77 | ranges(idx) = []; 78 | angles(idx) = []; 79 | labels(idx) = []; 80 | end 81 | end 82 | end 83 | 84 | end 85 | 86 | if ~isempty(ranges) 87 | % Sort from nearest 88 | [ranges,sortedIdx] = sort(ranges); 89 | angles = angles(sortedIdx); 90 | if numel(ranges) > obj.maxDetections 91 | ranges = ranges(1:obj.maxDetections); 92 | angles = angles(1:obj.maxDetections); 93 | labels = labels(1:obj.maxDetections); 94 | end 95 | end 96 | 97 | % Pack the final results into the output 98 | detections = [ranges, angles, labels]; 99 | 100 | end 101 | 102 | % More methods needed for the Simulink block to inherit its output 103 | % sizes from the scan angle parameter provided. 104 | function sz = getOutputSizeImpl(obj) 105 | sz = [obj.maxDetections,3]; 106 | end 107 | 108 | function fx = isOutputFixedSizeImpl(~) 109 | fx = false; 110 | end 111 | 112 | function dt = getOutputDataTypeImpl(obj) 113 | dt = propagatedInputDataType(obj,1); 114 | end 115 | 116 | function cp = isOutputComplexImpl(~) 117 | cp = false; 118 | end 119 | 120 | % Define icon for System block 121 | function icon = getIconImpl(~) 122 | icon = {'Object','Detector'}; 123 | end 124 | 125 | end 126 | 127 | methods (Static, Access = protected) 128 | % Do not show "Simulate using" option 129 | function flag = showSimulateUsingImpl 130 | flag = false; 131 | end 132 | % Always run in interpreted mode 133 | function simMode = getSimulateUsingImpl 134 | simMode = 'Interpreted execution'; 135 | end 136 | end 137 | 138 | end 139 | -------------------------------------------------------------------------------- /lib/Resources/Utils/addSensors.m: -------------------------------------------------------------------------------- 1 | function addSensors(blk,robotID) 2 | 3 | % This funciton is meant to add a sensor visualization from the components 4 | % library to a robot 5 | % Copyright 2018 The MathWorks, Inc. 6 | 7 | % Disable the library link so all configurations can be saved with the 8 | % model, otherwise it pulls from the library when model opens 9 | set_param(blk,'LinkStatus','inactive'); 10 | 11 | % remove any existing visual blocks 12 | 13 | subsystem = [blk '/Sensor Visuals']; 14 | blocks = find_system(subsystem,'LookUnderMasks','all'); 15 | 16 | % Delete all previous blocks except the inport 17 | for idx = 2:length(blocks)-1 18 | delete_block(blocks{idx}) 19 | end 20 | 21 | % Delete all signals 22 | while ~isempty(find_system(subsystem,'LookUnderMasks','all','FindAll','on','type','line')) 23 | lines = find_system(subsystem,'LookUnderMasks','all','FindAll','on','type','line'); 24 | delete_line(lines(1)) 25 | end 26 | % Set a position for the Physical connection port 27 | pos1 = [140 100 180 140]; 28 | pos2 = [140 170 180 210]; 29 | 30 | set_param(strcat(subsystem,'/Robot'),'position',[140 60 180 80]) 31 | %% Check for Distance sensors 32 | 33 | sensors=find_system(bdroot,'MaskType','RP Distance Sensor'); 34 | 35 | if ~isempty(sensors) 36 | % Check for block with a matching Robot ID 37 | 38 | for idx=1:size(sensors,1) 39 | if (eval(get_param(sensors{idx},'robotID')) == robotID) 40 | pos1 = pos1 + [60 0 60 0]; 41 | pos2 = pos2 + [60 0 60 0]; 42 | 43 | % Get X Y sensor offsets 44 | xyOffset=get_param(sensors{idx},'sensOff'); 45 | degOffset=get_param(sensors{idx},'sensOffDeg'); 46 | 47 | % Add sensor visual and set parameters 48 | add_block('RP_Simulator_Components/US Visual',strcat(subsystem,'/US Visual ',num2str(idx))); 49 | set_param(strcat(subsystem,'/US Visual ',num2str(idx)),'position',pos1,'Orientation','down'); 50 | set_param(strcat(subsystem,'/US Visual ',num2str(idx)),'pose',xyOffset,'angle',degOffset); 51 | add_line(subsystem,strcat('Robot','/Rconn1'),strcat('US Visual ',num2str(idx),'/LConn1')); 52 | end 53 | end 54 | end 55 | %% Check for contact switch sensors 56 | 57 | sensors=find_system(bdroot(gcs),'MaskType','RP Contact Switch'); 58 | 59 | if ~isempty(sensors) 60 | % Check for block with a matching Robot ID 61 | 62 | for idx=1:size(sensors,1) 63 | if (eval(get_param(sensors{idx},'robotID')) == robotID) 64 | pos1 = pos1 + [60 0 60 0]; 65 | pos2 = pos2 + [60 0 60 0]; 66 | 67 | % Get X Y sensor offsets 68 | xyOffset=get_param(sensors{idx},'sensOff'); 69 | degOffset=get_param(sensors{idx},'sensOffDeg'); 70 | 71 | % Add sensor visual and set parameters 72 | add_block('RP_Simulator_Components/Switch Visual',strcat(subsystem,'/Switch Visual ',num2str(idx))); 73 | set_param(strcat(subsystem,'/Switch Visual ',num2str(idx)),'position',pos1,'Orientation','down'); 74 | set_param(strcat(subsystem,'/Switch Visual ',num2str(idx)),'pose',xyOffset,'angle',degOffset); 75 | add_line(subsystem,strcat('Robot','/Rconn1'),strcat('Switch Visual ',num2str(idx),'/LConn1')); 76 | end 77 | end 78 | end 79 | 80 | %% Check for Compass 81 | 82 | sensors=find_system(bdroot(gcs),'MaskType','RP Compass Sensor'); 83 | 84 | if ~isempty(sensors) 85 | % Check for block with a matching Robot ID 86 | 87 | for idx=1:size(sensors,1) 88 | if (eval(get_param(sensors{idx},'robotID')) == robotID) 89 | pos1 = pos1 + [60 0 60 0]; 90 | pos2 = pos2 + [60 0 60 0]; 91 | 92 | % Add sensor visual and set parameters 93 | add_block('RP_Simulator_Components/Compass Visual',strcat(subsystem,'/Compass Visual ',num2str(idx))); 94 | set_param(strcat(subsystem,'/Compass Visual ',num2str(idx)),'position',pos1,'Orientation','down'); 95 | add_line(subsystem,strcat('Robot','/Rconn1'),strcat('Compass Visual ',num2str(idx),'/LConn1')); 96 | end 97 | end 98 | end 99 | %% Check for Object Sensor 100 | 101 | 102 | sensors=find_system(bdroot(gcs),'MaskType','RP Object Sensor'); 103 | 104 | if ~isempty(sensors) 105 | % Check for block with a matching Robot ID 106 | 107 | for idx=1:size(sensors,1) 108 | if (eval(get_param(sensors{idx},'robotID')) == robotID) 109 | pos1 = pos1 + [60 0 60 0]; 110 | pos2 = pos2 + [60 0 60 0]; 111 | 112 | % Get X Y sensor offsets 113 | xyOffset=get_param(sensors{idx},'sensOff'); 114 | degOffset=get_param(sensors{idx},'sensOffDeg'); 115 | 116 | % Add sensor visual and set parameters 117 | add_block('RP_Simulator_Components/Object Sensor Visual',strcat(subsystem,'/Object Sensor Visual ',num2str(idx))); 118 | set_param(strcat(subsystem,'/Object Sensor Visual ',num2str(idx)),'position',pos1,'Orientation','down'); 119 | set_param(strcat(subsystem,'/Object Sensor Visual ',num2str(idx)),'pose',xyOffset,'angle',degOffset); 120 | add_line(subsystem,strcat('Robot','/Rconn1'),strcat('Object Sensor Visual ',num2str(idx),'/LConn1')); 121 | end 122 | end 123 | end 124 | end --------------------------------------------------------------------------------