Coding Help

#1

Hey, I’m new to coding in RobotC so if anyone could help me out I would be very grateful. Any resources, links, or videos that have in depth tutorials for everything from motors to sensors (like gyros) will be greatly appreciated. Thanks!

0 Likes

#2

https://renegaderobotics.org/tag/programming/ is a pretty good opener to how some of the sensors work.

0 Likes

#3

One of our teams is coding in RobotC. they have set up a pneumatics system for their intake and shooter. The problem is that they cannot drive and use the pneumatics? The Robot jitters and the pneumatics pulses ? The 2 pneumatics Solenoids will only work when they are actuated by themselves?

If anyone is willing to have a look at our code that would be greatly appreciated. See below:

#pragma config(Sensor, in1, potmeter1, sensorPotentiometer)
#pragma config(Sensor, in2, potmeter2, sensorPotentiometer)
#pragma config(Sensor, dgtl2, solenoid2, sensorDigitalOut)
#pragma config(Sensor, dgtl3, solenoid1, sensorDigitalOut)
#pragma config(Sensor, dgtl5, AutonomousA, sensorTouch)
#pragma config(Sensor, dgtl6, AutonomousB, sensorTouch)
#pragma config(Sensor, dgtl7, AutonomousC, sensorTouch)
#pragma config(Sensor, dgtl8, AutonomousD, sensorTouch)
#pragma config(Sensor, dgtl9, lEncoder, sensorQuadEncoder)
#pragma config(Sensor, dgtl11, rEncoder, sensorQuadEncoder)
#pragma config(Motor, port1, shooter, tmotorVex393_HBridge, openLoop, reversed)
#pragma config(Motor, port2, frontright, tmotorVex393_MC29, openLoop, encoderPort, None)
#pragma config(Motor, port3, midright, tmotorVex393_MC29, openLoop, reversed, encoderPort, None)
#pragma config(Motor, port4, backright, tmotorVex393_MC29, openLoop, encoderPort, None)
#pragma config(Motor, port5, frontleft, tmotorVex393_MC29, openLoop, reversed, encoderPort, None)
#pragma config(Motor, port6, barlift, tmotorVex393_MC29, openLoop)
#pragma config(Motor, port7, pivot, tmotorVex393_MC29, openLoop)
#pragma config(Motor, port8, midleft, tmotorVex393_MC29, openLoop)
#pragma config(Motor, port9, backleft, tmotorVex393_MC29, openLoop, reversed)
#pragma config(Motor, port10, feed, tmotorVex393_HBridge, openLoop)
//!!Code automatically generated by ‘ROBOTC’ configuration wizard !!//

//This code is for the VEX cortex platform//
#pragma platform(VEX2)

//Select Download method as “competition”//
#pragma competitionControl(Competition)

//Main competition background code…do not modify!//
#include “Vex_Competition_Includes.c”

//Pre-Autonomous, used for resetting different motors and sensors before the autonomous phase//
void pre_auton()
{
//Setup for Potentiometers//
SensorValue[potmeter1] = sensorNone;
SensorValue[potmeter1] = sensorPotentiometer;
SensorValue[potmeter1] = 0;

SensorValue[potmeter2] = sensorNone;
SensorValue[potmeter2] = sensorPotentiometer;
SensorValue[potmeter2] = 0;

//Setup for Solenoids//
SensorValue[solenoid1] = sensorNone;
SensorValue[solenoid1] = sensorDigitalOut;
SensorValue[solenoid1] = //0 for close, 1 for open//;

SensorValue[solenoid2] = sensorNone;
SensorValue[solenoid2] = sensorDigitalOut;
SensorValue[solenoid2] = //0 for close, 1 for open//;

//Setup for Encoders//
SensorValue[lEncoder] = sensorNone;
SensorValue[lEncoder] = sensorQuadEncoder;
SensorValue[lEncoder] = 0;

SensorValue[rEncoder] = sensorNone;
SensorValue[rEncoder] = sensorQuadEncoder;
SensorValue[rEncoder] = 0;

bStopTasksBetweenModes = true;

// Set bDisplayCompetitionStatusOnLcd to false if you don't want the LCD
// used by the competition include file, for example, you might want
// to display your team name on the LCD in this function.
// bDisplayCompetitionStatusOnLcd = false;

// All activities that occur before the competition starts
// Example: clearing encoders, setting servo positions, ...

}

//Autonomous//
task autonomous()
{
SensorValue[rEncoder] = 0;

while(SensorValue(rEncoder) < 2)
{
	motor[frontleft] = 100;
	motor[midleft] = 100;
	motor[backleft] = 100;
	motor[frontright] = 100;
	motor[midright] = 100;
	motor[backright] = 100;
}
if(SensorValue (rEncoder) == 2)
{
	motor[frontleft] = 0;
	motor[midleft] = 0;
	motor[backleft] = 0;
	motor[frontright] = 0;
	motor[midright] = 0;
	motor[backright] = 0;
}

}
//User Control//
task usercontrol()
{

while (true)
{

	//Driver Controls////ALL HIGH SPEED//
	motor[frontleft] = vexRT[Ch3];
	motor[backleft] = vexRT[Ch3];
	motor[midleft] = vexRT[Ch3];
	motor[frontright] = vexRT[Ch2];
	motor[backright] = vexRT[Ch2];
	motor[midright] = vexRT[Ch2];

	//Motor for Shooter//
	if (vexRT[Btn5D] == 1)
	{
		motor[shooter] = 100;
		wait1Msec(100);
		motor[shooter] = 0;
	}

	//Solenoid for Shooter//
	if (vexRT[Btn5U] == 1)
	{
		SensorValue[solenoid2] = 1;
		wait1Msec(100);
		SensorValue[solenoid2] = 0;
	}

	//Motor for Barlift//
	if (vexRT[Btn8R] == 1)
	{
		motor[barlift] = 100;
		wait1Msec(100);
		motor[barlift] = 0;
	}

	//Motor for Pivot//
	if (vexRT[Btn7L] == 1)
	{
		motor[pivot] = 50;
		wait1Msec(100);
		motor[pivot] = 0;
	}
	if (vexRT[Btn7R] == 1)
	{
		motor[pivot] = -50;
		wait1Msec(100);
		motor[pivot] = 0;
	}

	//Solenoid for Claw//
	if (vexRT[Btn6U] == 1)
	{
		SensorValue[solenoid1] = 1;
		wait1Msec(100);
		SensorValue[solenoid1] = 0;
	}
}

}
Copy of 5760B Competition Program V.2.c
Displaying Copy of 5760B Competition Program V.2.c.

0 Likes

#4

This is actually something that can’t really be fixed, we used pneumatics in the star-struck game and it did the same thing its just how the robot processes the code. I would honestly avoid pneumatics if i were you there are too many cons outweighing the pros

0 Likes

#5

Please make a dedicated thread for your question in an appropriate channel, making use of the



 tag (highlight your code, click the button in the toolbar between the image and quote buttons).
0 Likes

#6

This is a very vague claim that seems quite misinformed.

Upon just a cursory code examination, there a number of things that could be done so that “how the robot processes the code” is exactly how the user intends for the robot to process the code.

I will gladly list some such things in the aforementioned dedicated thread (I will not further the derailment of this thread).

0 Likes

#7

Is there any way to code two motors to run simultaneously in C++ in VCS?

0 Likes

#8

Nevermind

0 Likes